Color of wx.StaticLine

1,091 views
Skip to first unread message

R. P. Hintze

unread,
Feb 24, 2010, 8:23:54 AM2/24/10
to wxpytho...@googlegroups.com
I apologize in advance for what for another newbie (and probably dumb) question...
 
If I have a wx.StaticLine, is it possible to control its color?
 
I tried to search for an answer, but I don't seem to find any results on point, and I am still having trouble wading thru the documentation.
 
Thank you for you time and patience.
 
Regards,
 
Russ
 
 

Cody Precord

unread,
Feb 24, 2010, 8:34:44 AM2/24/10
to wxpytho...@googlegroups.com
Hi,

On Feb 24, 2010, at 7:23 AM, R. P. Hintze wrote:

I apologize in advance for what for another newbie (and probably dumb) question...
 
If I have a wx.StaticLine, is it possible to control its color?
 
I tried to search for an answer, but I don't seem to find any results on point, and I am still having trouble wading thru the documentation.

Have you tried staticLine.SetForegroundColour(some_colour)?



Cody

Robin Dunn

unread,
Feb 24, 2010, 8:31:01 PM2/24/10
to wxpytho...@googlegroups.com
On 2/24/10 5:23 AM, R. P. Hintze wrote:
> I apologize in advance for what for another newbie (and probably dumb)
> question...
> If I have a wx.StaticLine, is it possible to control its color?

It's up to the native widget whether it does anything with
Set[Back|Fore]groundColour, and as far as I know none of the platforms
do for wx.StaticLine. You can do it with a generic control where you
draw the lines yourself.

--
Robin Dunn
Software Craftsman
http://wxPython.org

gatoruss

unread,
Feb 25, 2010, 7:24:27 AM2/25/10
to wxPython-users

On Feb 24, 8:31 pm, Robin Dunn <ro...@alldunn.com> wrote:
> It's up to the native widget whether it does anything with
> Set[Back|Fore]groundColour, and as far as I know none of the platforms
> do for wx.StaticLine.  You can do it with a generic control where you
> draw the lines yourself.

Yes, I was playing around with Set[Back|Fore]groundColour (I am using
WindowsXP), and the color of the wx.StaticLine does not change.

I will look into how one draws a line...

As a practical exercise (in learning python and wxpython), I am trying
to write a program that my little girl can use to learn/re-enforce
math facts. The program will show random "problems" - such as, "13 +
6" - as a statictext, and she will enter the answer (key pad will be
displayed for mouse or she can use keyboard). I wanted the "problem"
to be presented as:

13
+ 6

With the " 6" underlined and with a text control beneath the underline
for her to enter her answer. I have formatted the "problem" with the
following code:

self.num_one = 13
self.num_two = 6
self.problem = "{0: >2}\n{1: >2}".format(self.num_one,
self.num_two)

In the actual program, self.num_one and self.num_two will be randomly
generated. I am struggling on how to add the underline. I guess I
could break self.num_one and self.num_two into 2 statictext widgets,
and apply a different font to self.num_two - which set "underline" as
"TRUE"? I thought that there should be an easier way.

Mike Driscoll

unread,
Feb 25, 2010, 1:34:50 PM2/25/10
to wxPython-users

You could use a small HtmlWindow. That would give you quite a few more
options, although it doesn't support advanced HTML or CSS, you could
do a one column table along with <u/> or whatever.

Alternatively, you might look at some of the styled text controls,
like RichTextCtrl or StyleTextCtrl.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Reply all
Reply to author
Forward
0 new messages