wx.StaticText on Solaris 10 vs. Windows

Hi,

I created a panel with some wx.StaticText objects on Windows, and was able to set the background colors and border styles without difficulty. For example:

txt = wx.StaticText(self, -1, “Shift”)

txt.SetWindowStyle(wx.SIMPLE_BORDER)
txt.SetBackgroundColour(wx.RED)

When I do the same thing in Solaris, the SetWindowStyle and SetBackgroundColour have no effect. I tried several border types to no avail.

The widgets are in a FlexGridSizer, where the top row and first column of the table are labels (and have no borders), and the other locations contain read-only data.

I’m using wxPython
2.6.3.3
, compiled with gtk2 on Solaris 10 x86.
I’d appreciate any help or suggestions.

Regards,

  • Chris Botos

Hello Chris,

txt = wx.StaticText(self, -1, "Shift")
txt.SetWindowStyle(wx.SIMPLE_BORDER)
txt.SetBackgroundColour(wx.RED)

I am not sure I remember correctly, but I seem to recall that Robin
said that on GTK the wx.StaticText is not a "real" widget, but it is
directly drawn by the platform with the current wx.DC. So, few
properties of the StaticText can not be set by the user and they are
simply ignored by the platform.
That said, I have no idea about WindowStyles and BackgroundColours on
GTK: if it can not work because of the above limitations, you may want
to try wx.lib.stattext.GenStaticText (or something like that) to
achieve what you need.

HTH.

Andrea.

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

···

On 9/27/06, chris botos <chris.botos@gmail.com> wrote:

Andrea Gavana wrote:

Hello Chris,

txt = wx.StaticText(self, -1, "Shift")
txt.SetWindowStyle(wx.SIMPLE_BORDER)
txt.SetBackgroundColour(wx.RED)

I am not sure I remember correctly, but I seem to recall that Robin
said that on GTK the wx.StaticText is not a "real" widget, but it is
directly drawn by the platform with the current wx.DC.

Almost. It is drawn directly on the parent window, but not necessarily the current or same DC. (But the essence of your statement is the same.)

So, few
properties of the StaticText can not be set by the user and they are
simply ignored by the platform.
That said, I have no idea about WindowStyles and BackgroundColours on
GTK: if it can not work because of the above limitations, you may want
to try wx.lib.stattext.GenStaticText (or something like that) to
achieve what you need.

Yep, that's my recommendation as well.

···

On 9/27/06, chris botos <chris.botos@gmail.com> wrote:

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

Thanks Andrea and Robin! I’m giving GenStaticText a try. I found an old email of Andrea’s and the response that described how to get it sized, so I’m past that hurdle. Setting colors also worked. It appears though that I cannot set a border using SetWindowsStyle(
wx.SIMPLE_BORDER). I also tried wx.SUNKEN_BORDER.

-Chris

···

On 9/27/06, Robin Dunn robin@alldunn.com wrote:

Andrea Gavana wrote:

I am not sure I remember correctly, but I seem to recall that Robin
said that on GTK the wx.StaticText is not a “real” widget, but it is
directly drawn by the platform with the current wx.DC.

Almost. It is drawn directly on the parent window, but not necessarily
the current or same DC. (But the essence of your statement is the same.)

So, few
properties of the StaticText can not be set by the user and they are

simply ignored by the platform.
That said, I have no idea about WindowStyles and BackgroundColours on
GTK: if it can not work because of the above limitations, you may want
to try wx.lib.stattext.GenStaticText
(or something like that) to
achieve what you need.

Yep, that’s my recommendation as well.

chris botos wrote:

···

On 9/27/06, *Robin Dunn* <robin@alldunn.com <mailto:robin@alldunn.com>> > wrote:

Thanks Andrea and Robin! I'm giving GenStaticText a try. I found an old email of Andrea's and the response that described how to get it sized, so I'm past that hurdle. Setting colors also worked. It appears though that I cannot set a border using SetWindowsStyle( wx.SIMPLE_BORDER). I also tried wx.SUNKEN_BORDER.

Try setting the style as part of the call to the object's constructor. Some styles can't be changed after a widget has been created. Also, IIRC the wx.SIMPLE_BORDER is ignored on wxGTK for some reason.

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

Yep, putting it in the constructor worked. And BTW, SIMPLE_BORDER also worked.
Thanks, Robin!
-Chris

···

On 9/28/06, Robin Dunn robin@alldunn.com wrote:

chris botos wrote:

On 9/27/06, Robin Dunn <robin@alldunn.com mailto:robin@alldunn.com> > > wrote:

Thanks Andrea and Robin! I’m giving GenStaticText a try. I found an

old email of Andrea’s and the response that described how to get it
sized, so I’m past that hurdle. Setting colors also worked. It appears
though that I cannot set a border using SetWindowsStyle(

wx.SIMPLE_BORDER). I also tried wx.SUNKEN_BORDER.

Try setting the style as part of the call to the object’s constructor.
Some styles can’t be changed after a widget has been created. Also,
IIRC the wx.SIMPLE_BORDER is ignored on wxGTK for some reason.