axel
axel

Reputation: 4127

wxPython - how to colour the text of a statusbar

I searched for the answer in the forum, but I didn't find anything, if I am wrong, I am sorry. Anyway, question is simple, I have this Frame, with a Status Bar I use to print messages or notifies.

I would like to use it for mistakes or not permitted operations. But I would like these messages to be coloured. I am looking for a solution on wxPython demo -because i read somewhere on the web to get some inspirations by it-, but i still did not find anything.

Do you have any ideas or solutions?

thank you in advance.

Upvotes: 2

Views: 2319

Answers (2)

Martin Finke
Martin Finke

Reputation: 96

Simple solution: pin wx.StaticText on the status bar and write text in it. Text coloring in wx.StaticText works well.

For example:

    self.sb = self.ws.CreateStatusBar()
    self.sbtext = wx.StaticText(self.sb, -1, '', pos=(8, 4))
    ...
    self.sbtext.SetForegroundColour(wx.Colour(color))
    self.sbtext.SetLabel(text)

Upvotes: 0

Mike Driscoll
Mike Driscoll

Reputation: 33071

I would try the SetForegroundColour or SetBackgroundColour methods of the status bar widget. These methods don't always work on every platform though as each OS has its own rules and wxPython follows those rules. If they do not work, then you'll have to roll your own statusbar, probably by using a couple of panels in a sizer or a splitter window.

There is also the 3rd party EnhancedStatusbar widget which might work for you. It can be found at http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html

Upvotes: 1

Related Questions