Getting ListCtrl to behave more like ListBox

Hi,
I just started using wxPython, I'm making a simple (but very
application-specific) file browser/launcher app.

All the user needs to do is arrow up and down the list of filenames
and select one. There is only one column. I'd like the list to
behave exactly like ListBox (and look almost exactly the same), but I
need to be able to set text and background colors individually per
item, so I have to use ListCtrl.

My main problem is that I don't know how to get the selection box of
an LC_LIST ListCtrl to go all the way across the ListCtrl. Is it
possible to get it to behave this way, or do I have to use LC_REPORT
somehow?

I'm using XRC to layout my gui, I don't have to stick with XRC, but if
it's possibly to get the functionality I want with an XRC layout I'd
like to keep it that way.

Thanks,
Luke

Yes, use wx.LC_REPORT and also wx.LC_NO_HEADER to get rid of the column header. Create one column and set it to have the same width as the listctrl.

···

On 7/12/11 12:26 PM, Hospadar wrote:

Hi,
I just started using wxPython, I'm making a simple (but very
application-specific) file browser/launcher app.

All the user needs to do is arrow up and down the list of filenames
and select one. There is only one column. I'd like the list to
behave exactly like ListBox (and look almost exactly the same), but I
need to be able to set text and background colors individually per
item, so I have to use ListCtrl.

My main problem is that I don't know how to get the selection box of
an LC_LIST ListCtrl to go all the way across the ListCtrl. Is it
possible to get it to behave this way, or do I have to use LC_REPORT
somehow?

--
Robin Dunn
Software Craftsman

Sounds good,

I presume if I want the column to remain constant with the list width I need to catch any resize events on the listctrl and resize the column?

Thanks again,

Luke

···

On Tue, Jul 12, 2011 at 6:23 PM, Robin Dunn robin@alldunn.com wrote:

On 7/12/11 12:26 PM, Hospadar wrote:

Hi,

I just started using wxPython, I’m making a simple (but very

application-specific) file browser/launcher app.

All the user needs to do is arrow up and down the list of filenames

and select one. There is only one column. I’d like the list to

behave exactly like ListBox (and look almost exactly the same), but I

need to be able to set text and background colors individually per

item, so I have to use ListCtrl.

My main problem is that I don’t know how to get the selection box of

an LC_LIST ListCtrl to go all the way across the ListCtrl. Is it

possible to get it to behave this way, or do I have to use LC_REPORT

somehow?

Yes, use wx.LC_REPORT and also wx.LC_NO_HEADER to get rid of the column header. Create one column and set it to have the same width as the listctrl.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Sounds good,
I presume if I want the column to remain constant with the list width I need
to catch any resize events on the listctrl and resize the column?

Or you could try the ListCtrlAutoWidthMixin in wx.lib.mixins.listctrl.
The wx.ListCtrl demo shows how to use it, and it will automagically
resize the column for you every time you resize the parent window.

HTH.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 13 July 2011 15:02, Luke Hospadaruk wrote: