Try
self.panelname.SetBackgroundColour("GREEN")
instead of
self.panelname.SetBackgoundColour('GREEN')
:-)
Vlasta
oh well... that happens when you concentrate too much on one piece of
code :/ sry 'bout that and thx :)
anyways. now it doesnt throw the error anymore but it just colors the
LAST panel of the frame.
and this only after i move the frame out of
the screen or minimize it.
You may try
self.panelname.SetBackgroundColour('GREEN')
self.panelname.Refresh()
if the background colour isn't updated instantly.
But without the external file lotto.txt we probably cannot reasonably
run your script, to see.
hth
Vlasta
2009/8/24 Sheepherd <sheep...@gmail.com>:
>You may try
> oh well... that happens when you concentrate too much on one piece of
> code :/ sry 'bout that and thx :)
>
> anyways. now it doesnt throw the error anymore but it just colors the
> LAST panel of the frame. and this only after i move the frame out of
> the screen or minimize it. an easy solution for this one too? :)
> and again: when i use print number just before the actual coloring, it
> returns the correct values
>
self.panelname.SetBackgroundColour('GREEN')
self.panelname.Refresh()
Here's the problem: in both this code and the previous code, you
are treating two things as if they are the same, when they are not.
Note this function in your latest code:
def setColors(self, number):
panelname = self.paneldict[number].SetBackgroundColour('GREEN')
self.panelname.Refresh()
So you define something here, and it is named "panelname". You say
that this thing called panelname should be made green. Fine. But now
you know you have to .Refresh() whatever panel's color has been changed.
So one would expect to see this:
panelname.Refresh()
But what is seen is
self.panelname.Refresh()
The point is that panelname is different object than self.panelname. Self
panelname is an attribute of the whole instance of your class. panelname
is only a local name within this setColors() function. So, if you are going
to use this variable in other parts of this class, just do this:
def setColors(self, number):
self.panelname = self.paneldict[number].SetBackgroundColour('GREEN')
self.panelname.Refresh()
> 2nd is that i have no idea how to reset the color of the panel
> (probably with an empty .SetBackgroundColor() ? )
Not sure how to set that. You want it to be the "system" color, right?
Che
[This is not wxPython but Python stuff, but FWIW]
The way I wrote it above could have been clearer because I wrote what
should have been self.panelname as Self panelname. Maybe a simple
way to think about these things is: if you want a variable (in Python,
called a "name") to be accessible from anywhere in your class, put
a self. in front of it. If you want to just use it within a function and have
it only be defined within that function (within that "scope"), don't put a
self. in front of it. (the choice of the word "self" is just the convention,
it could be anything, but just use "self"). It is considered good form to
only make something self.name instead of just name if you *have* to
access it outside the function it is defined in, because otherwise you
are just cluttering up the class's namespace for no reason.
Che
>>
>>> 2nd is that i have no idea how to reset the color of the panel
>>> (probably with an empty .SetBackgroundColor() ? )
>> Not sure how to set that. You want it to be the "system" color, right?
>>
>> Che
>
> I tried to find the docs on this earlier today and didn't have much
> luck. I know Robin has told folks how to do this on several
> occasions...fortunately, the term "system" was the one I was looking
> for.
>
> The docs here give a clue: http://www.wxpython.org/docs/api/wx.Colour-class.html
>
> It looks like you want wx.SystemSettings.GetColour
>
> Or something like this:
>
> panel.SetBackgroundColour(wx.SystemSettings.GetColour
> (wx.SYS_COLOUR_BACKGROUND))
There's a better way, just use wx.NullColour. That will tell wx that
the widget has no specific color set and so it will use whatever the
platform wants to use, which may be controlled by the active theme and
may not be a solid color at all. This is a little different from using
the system settings color as then wx will act as if a custom color has
been set and it doesn't care if it happens to be the same as the system
color.
--
Robin Dunn
Software Craftsman
http://wxPython.org