View Single Post
Posts: 456 | Thanked: 1,580 times | Joined on Dec 2009
#142
Originally Posted by Mentalist Traceur View Post
Wonko: Am I missing something here? Is there a way I can set a variable from within the clock style once, just so that it's initialized, and then have later looping parts of the draw clock code use it?
That's what the constructor (the __init__ method) is for.
There you can initialize member variables like this:
Code:
class DecimalClock(clock.Clock):
    def __init__(self, drawing_area):
        clock.Clock.__init__(self, drawing_area)
        self.my_member_variable = 0 #None, "some_string" whatsoever
And then later on you just use "self.my_member_variable" in your code to access it.


P.S.: I didn't read your complete post yet, just wanted to give you a quick feedback.
By the way, I seem to have missed what you're up to.
What exactly are you trying to do?

Edit: By the way, if you have the "Show Seconds" option disabled the clock is only updated once per minute.
Consequently, the draw_clock method is also only called once per minute.
__________________
 

The Following 2 Users Say Thank You to Wonko For This Useful Post: