porting from Tkinter to pygtk

  • Thread starter Michele Simionato
  • Start date
M

Michele Simionato

I am in the process of learning pygtk and I would like to port
some custom made Tkinter widgets to pygtk, just an exercise.
For instance I have this code:

.. from Tkinter import *
..
.. class AnimatedLabel(Label):
.. def __init__(self, master, text, width=72, maxspc=16, deltat=100,
**kw):
.. self.text = text
.. self.width = width
.. self.maxspc = maxspc
.. self.deltat = deltat
.. self.stringvar = StringVar(master)
.. self.stringvar.set(text)
.. self.stop = False
.. Label.__init__(self, master, textvariable=self.stringvar,
**kw)
..
.. def startAnimation(self, spaces='', addspace=False):
.. if len(spaces) == 0 or len(spaces) == self.maxspc:
.. addspace = not addspace
.. if addspace: # add a space
.. spaces += ' '
.. else: # remove a space
.. spaces = spaces[1:]
.. if not self.stop: # repeat each 100 ms changing spaces and
addspace
..
self.stringvar.set(spaces.join(self.text).center(self.width))
.. self.after(self.deltat, self.startAnimation, spaces,
addspace)
..
.. def stopAnimation(self):
.. self.stop = True
..
..
.. if __name__ == "__main__":
.. t = Tk()
.. t.title('Example')
.. t.config(background='green')
..
.. a = AnimatedLabel(t, text="Hello", fg='blue', bg='green')
.. a.pack()
.. a.startAnimation()
.. t.mainloop()

what's the equivalent of the .after() method in pygtk?
BTW, is there any intro to pygtk thought for Tkinter users?
TIA,

Michele Simionato
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top