wx.ListBox: SetBackgroundColour and SetFont

Raffaello Barella wrote:

Working on OS Windows XP, SetBackgroundColour and SetFont seem to have no effect on a wx.ListBox. Anybody knows how to change these attributes?

Works for me. Can you provide a sample app that shows the problem?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

The instructions that do not work are in the lines 90-95. Many thanks again.

rbmultichoicegrid.py (8.17 KB)

···

2008/2/24, Robin Dunn robin@alldunn.com:

Raffaello Barella wrote:

Working on OS Windows XP, SetBackgroundColour and SetFont seem to have
no effect on a wx.ListBox. Anybody knows how to change these attributes?

Works for me. Can you provide a sample app that shows the problem?


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Raffaello Barella wrote:

The instructions that do not work are in the lines 90-95. Many thanks again.

It does work the first time, but you can't see it because of a logic error in your code. The self.height hasn't been set yet when you try to use it in SetSize so you resize the edit control to be almost invisible. The attributes are being reset on subsequent showings because the grid has code in place to set the edit control's attributes to match the cell's font and color attributes. You can override this behavior by overriding the editor's Show method, like this:

     def Show(self, show, attr):
         self.choice.Show(show)
         font = self.choice.Parent.GetFont()
         font.SetStyle(wx.FONTSTYLE_ITALIC)
         self.choice.SetFont(font)
         self.choice.SetBackgroundColour(wx.Colour(223, 223, 223))

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Is it correct to understand that this behavior (as far as the cell’s attributes are concerned) will apply to practically all kind of control in a cell editor?

Meanwhile, all my thanks.

···

2008/2/25, Robin Dunn robin@alldunn.com:

Raffaello Barella wrote:

The instructions that do not work are in the lines 90-95. Many thanks again.

It does work the first time, but you can’t see it because of a logic
error in your code. The self.height hasn’t been set yet when you try to

use it in SetSize so you resize the edit control to be almost invisible.
The attributes are being reset on subsequent showings because the
grid has code in place to set the edit control’s attributes to match the

cell’s font and color attributes. You can override this behavior by
overriding the editor’s Show method, like this:

 def Show(self, show, attr):
     self.choice.Show(show)
     font = self.choice.Parent.GetFont()

     font.SetStyle(wx.FONTSTYLE_ITALIC)
     self.choice.SetFont(font)
     self.choice.SetBackgroundColour(wx.Colour(223, 223, 223))

Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org