Possible to construct a wx.TextCtrl inside a wx.ListCtrl column header through the use of a mixin class?

I am wondering whether I can construct a wx.TextCtrl inside a wx.ListCtrl column header.

Although I have looked at the GridLabelRenderer.py demo
(http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRenderer.py?revision=59664&view=markup&pathrev=59664)
and understand that the code draws wx.Grid column headers from scratch using a wx.Grid mixin class, I
am new enough to wxPython that I don’t yet know whether it’s possible to create a similar mixin class for wx.ListCtrl and whether I can have such a class draw something more complex, like a wx.TextCtrl, inside a column header.

I would use the mixin to create column filter functionality wx.ListCtrl. Below is a graphic mock-up of what I have in mind (if you do not see the image below, it is available at http://i40.tinypic.com/2zrdsh0.jpg). Note the header label at the very top, followed by a text box, then followed by the column data.

http://i40.tinypic.com/2zrdsh0.jpg

I would appreciate any thoughts or suggestions you may have.

Thanks,
Daniel

Hi Daniel,

···

On May 31, 9:08 pm, Daniel Lipovetsky <daniel.lipovet...@gmail.com> wrote:

I am wondering whether I can construct a wx.TextCtrl inside a wx.ListCtrl
column header.

Although I have looked at the GridLabelRenderer.py demo (http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRende…)
and understand that the code draws wx.Grid column headers from scratch using
a wx.Grid mixin class, I am new enough to wxPython that I don't yet know
whether it's possible to create a similar mixin class for wx.ListCtrl and
whether I can have such a class draw something more complex, like a
wx.TextCtrl, inside a column header.

I would use the mixin to create column filter functionality wx.ListCtrl.
Below is a graphic mock-up of what I have in mind (if you do not see the
image below, it is available athttp://i40.tinypic.com/2zrdsh0.jpg). Note
the header label at the very top, followed by a text box, then followed by
the column data.

[image:http://i40.tinypic.com/2zrdsh0.jpg\]

I would appreciate any thoughts or suggestions you may have.

Thanks,
Daniel

You might try Andrea's UltimateListCtrl. I think it's pure python, so
it can probably do that:

http://xoomer.virgilio.it/infinity77/main/UltimateListCtrl.html

- Mike

Daniel Lipovetsky wrote:

I am wondering whether I can construct a wx.TextCtrl inside a wx.ListCtrl column header.

Although I have looked at the GridLabelRenderer.py demo (http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRenderer.py?revision=59664&view=markup&pathrev=59664) and understand that the code draws wx.Grid column headers from scratch using a wx.Grid mixin class, I am new enough to wxPython that I don't yet know whether it's possible to create a similar mixin class for wx.ListCtrl and whether I can have such a class draw something more complex, like a wx.TextCtrl, inside a column header.

It would be a kludge but you may be able to get something like that working. Look at the wx.lib.mixins.listctrl.TextEditMixin class. It positions a wx.TextCtrl on the listctrl for editing, it could probably be gleaned for ideas for positioning textctrls on the header too. One complication you'll run into is that the header is actually a separate widget on GTK and OSX (if not using the native listctrl on OSX).

···

--
Robin Dunn
Software Craftsman

Thank you for letting me know about Andrea's UltimateListCtrl, Mike!
(And thanks to Andrea for writing it and making it available). I think
I could use to implement what I have in mind. Still, I'm curious to
see what I could do using the native wx.ListCtrl :slight_smile:

Daniel

···

On Jun 1, 9:23 am, Mike Driscoll <kyoso...@gmail.com> wrote:

Hi Daniel,

On May 31, 9:08 pm, Daniel Lipovetsky <daniel.lipovet...@gmail.com> > wrote:

> I am wondering whether I can construct a wx.TextCtrl inside a wx.ListCtrl
> column header.

> Although I have looked at the GridLabelRenderer.py demo (http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRende…)
> and understand that the code draws wx.Grid column headers from scratch using
> a wx.Grid mixin class, I am new enough to wxPython that I don't yet know
> whether it's possible to create a similar mixin class for wx.ListCtrl and
> whether I can have such a class draw something more complex, like a
> wx.TextCtrl, inside a column header.

> I would use the mixin to create column filter functionality wx.ListCtrl.
> Below is a graphic mock-up of what I have in mind (if you do not see the
> image below, it is available athttp://i40.tinypic.com/2zrdsh0.jpg). Note
> the header label at the very top, followed by a text box, then followed by
> the column data.

> [image:http://i40.tinypic.com/2zrdsh0.jpg\]

> I would appreciate any thoughts or suggestions you may have.

> Thanks,
> Daniel

You might try Andrea's UltimateListCtrl. I think it's pure python, so
it can probably do that:

http://xoomer.virgilio.it/infinity77/main/UltimateListCtrl.html

- Mike

Thank you for your insight, Robin.

From what I understand you to say, I could overlay a textctrl widget
on top of the header widget. Since it doesn't appear possible to
increase the height of the header widget while maintaining a small
font size, I would have to place the TextCtrl next to the header
label, like so:

···

+--------------,---+-------------+

Header Text | TextCtrl | | Header Text |

+--------------````````````---+-------------+

                            > >

(one header with a TextCtrl, the other without)

Since the TextCtrl would be visible continuously, I believe I would
have to make the header widget aware of the TextCtrl boundaries so
that a header containing a TextCtrl could not be resized narrower than
the combined width of the header text and the TextCtrl. I don't know
how to inform ListCtrl of this yet, but it's never too late to
learn :slight_smile:

I had one other idea, but it smelled funny: hijacking the first row of
the ListCtrl widget and using it for the above functionality. Does
that smell bad to you, too?

Thanks again,
Daniel

On Jun 1, 11:09 am, Robin Dunn <ro...@alldunn.com> wrote:

Daniel Lipovetsky wrote:
> I am wondering whether I can construct a wx.TextCtrl inside a
> wx.ListCtrl column header.

> Although I have looked at the GridLabelRenderer.py demo
> (http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRende
> <http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/demo/GridLabelRende...&gt;\)
> and understand that the code draws wx.Grid column headers from scratch
> using a wx.Grid mixin class, I am new enough to wxPython that I don't
> yet know whether it's possible to create a similar mixin class for
> wx.ListCtrl and whether I can have such a class draw something more
> complex, like a wx.TextCtrl, inside a column header.

It would be a kludge but you may be able to get something like that
working. Look at the wx.lib.mixins.listctrl.TextEditMixin class. It
positions a wx.TextCtrl on the listctrl for editing, it could probably
be gleaned for ideas for positioning textctrls on the header too. One
complication you'll run into is that the header is actually a separate
widget on GTK and OSX (if not using the native listctrl on OSX).

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Daniel Lipovetsky wrote:

Thank you for your insight, Robin.

From what I understand you to say, I could overlay a textctrl widget

on top of the header widget. Since it doesn't appear possible to
increase the height of the header widget while maintaining a small
font size, I would have to place the TextCtrl next to the header
label, like so:

+--------------,---+-------------+
> Header Text | TextCtrl | | Header Text |
+--------------````````````---+-------------+
> > >

(one header with a TextCtrl, the other without)

Since the TextCtrl would be visible continuously, I believe I would
have to make the header widget aware of the TextCtrl boundaries so
that a header containing a TextCtrl could not be resized narrower than
the combined width of the header text and the TextCtrl. I don't know
how to inform ListCtrl of this yet, but it's never too late to
learn :slight_smile:

You can catch the column drag events and deal with it there.

I had one other idea, but it smelled funny: hijacking the first row of
the ListCtrl widget and using it for the above functionality. Does
that smell bad to you, too?

Yes, there is a kludgy odor wafting about.

···

--
Robin Dunn
Software Craftsman