[Sugar-devel] Help Request - Python Timer
Walter Bender
walter.bender at gmail.com
Tue Jan 25 21:46:21 EST 2011
On Tue, Jan 25, 2011 at 8:58 PM, Art Hunkins <abhunkin at uncg.edu> wrote:
> I'd like help to create a timer in my activity.
>
> The following code works fine. A callback button alternately selects START
> and STOP options in playcsd() (only crucial lines of code are included):
>
> import csndsugui
> from timeit import Timer
>
> self.p = False
>
> def playcsd(self, widget):
> if self.p == False:
> self.p = True
> self.but.child.set_label("STOP !")
> else:
> self.p = False
> self.but.child.set_label("START !")
>
> self.but = self.w.cbbutton(self.b7, self.playcsd, "START !")
>
>
> I need to add timer code that will call playcsd() after a specified time
> period (here, 30 seconds), as an option to pressing the callback button. I
> thought the following added code should work, but it doesn't. No errors are
> reported, but the desired switch to START (call to playcsd() with self.p ==
> True) doesn't happen either. (The code follows immediately the last line
> above):
>
> if self.p == True:
> self.t = Timer(30.0, self.playcsd(self.but))
Maybe try gobject.timeout_add instead of Timer?
-walter
> self.t = start()
>
>
> Art Hunkins
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
--
Walter Bender
Sugar Labs
http://www.sugarlabs.org
More information about the Sugar-devel
mailing list