wx.StaticBox(): Change Color of name?

Is there a way to change the color of the name attribute of a
wx.StaticBox()? It apparently will accept a style of wx.TEXT_RICH, but I
cannot find the proper syntax to Set.Foreground.Colour(wx.RED) on that
string.

TIA,

Rich

Try this:

my_box = wx.StaticBox(self, -1, “My box”,size=wx.Size(250,40), name=“My box”)
my_box.SetForegroundColour(wx.RED)

···

On Thursday, July 24, 2014 2:25:22 AM UTC+3, fuzzydoc wrote:

Is there a way to change the color of the name attribute of a

wx.StaticBox()? It apparently will accept a style of wx.TEXT_RICH, but I

cannot find the proper syntax to Set.Foreground.Colour(wx.RED) on that

string.

TIA,

Rich

Thanks, Steve.

   I did not realize that I needed the name in there twice, once without the
style label, once with the label. And, the example I found used
'self.my_box' and removing the self was necessary ... at least it works
without it.

Much appreciated,

Rich

···

On Wed, 23 Jul 2014, steve wrote:

my_box = wx.StaticBox(self, -1, "My box",size=wx.Size(250,40), name="My
box")
my_box.SetForegroundColour(wx.RED)

my_box = wx.StaticBox(self, -1, "My box",size=wx.Size(250,40), name="My
box")
my_box.SetForegroundColour(wx.RED)

  Thanks, Steve.

  I did not realize that I needed the name in there twice, once without the
style label, once with the label. And, the example I found used
'self.my_box' and removing the self was necessary ... at least it works
without it.

That's a slight misunderstanding... the third parameter is NOT
"name"; it's "label". From the docs
(wxPython API Documentation — wxPython Phoenix 4.2.2 documentation):

  __init__(self, parent, id=-1, label=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, name=StaticBoxNameStr)

"name" is an optional property for wx widgets; it can be very useful,
but it's not used by default - and it's also not visible, so
ForegroundColor has no effect on it. "label" is the property you're
interested in. The fact that you've set them both to the same string
is coincidental - test this by making them different, and see which
one shows up as your box's caption.

···

On Wed, Jul 23, 2014 at 5:02 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 23 Jul 2014, steve wrote:

Marc,

   Got it. When I looked at the docs I saw the name but not the label.
Explicitly adding 'lable=' will certainly do the trick.

Thanks for the clarification,

Rich

···

On Wed, 23 Jul 2014, Marc Tompkins wrote:

That's a slight misunderstanding... the third parameter is NOT
"name"; it's "label".

^^
   correction: label. Need more cafine.

Rich

···

On Thu, 24 Jul 2014, Rich Shepard wrote:

Explicitly adding 'lable=' will certainly do the trick.

Explicitly adding 'label=' will certainly do the trick.

No - I haven't made myself clear. "label" is the third parameter,
whether you write "label=" or not. "label" is the text that appears
on the control; that's what the ForegroundColor applies to.

"name" is a behind-the-scenes attribute that DOES NOT PRINT.
ForegroundColor does not apply to it. You can assign "name", or not;
it's up to you. It's very useful if you manipulate your controls
programmatically after placing them; otherwise, it does nothing.

To see what's going on behind the scenes, add

import wx.lib.inspection

at the top of your script, and

wx.lib.inspection.InspectionTool().Show()

just before MainLoop(). The InspectionTool opens in a separate window
alongside your program, and allows you to browse through the various
widgets/controls/sizers and see their properties.

···

On Thu, Jul 24, 2014 at 5:59 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Thu, 24 Jul 2014, Rich Shepard wrote: