[pygtk] Clock in Pygtk but in one or more windows

svabodafree at libero.it svabodafree at libero.it
Fri Nov 5 23:19:59 WST 2010


Hello !
I need to show the updated time in a window (or label).I was looking a example with Tkinter but I do not know how to integrate in a pygtk window or do it in different way. Any help will be appreciate.
Code :
# use Tkinter to show a digital clock 
# tested with Python24    vegaseat    10sep2006 
from Tkinter import * import time 
root = Tk() time1 = '' clock = Label(root, font=('times', 20, 'bold'), bg='white') clock.pack(fill=BOTH, expand=1) 
def tick():     global time1     # get the current local time from the PC     time2 = time.strftime('%H:%M:%S')     # if time string has changed, update it     if time2 != time1:         time1 = time2         clock.config(text=time2)     # calls itself every 200 milliseconds     # to update the time display as needed     # could use >200 ms, but display gets jerky     clock.after(200, tick) 
tick() root.mainloop(  )  # use Tkinter to show a digital clock 
# tested with Python24    vegaseat    10sep2006 

from Tkinter import * 
import time 

root = Tk() 
time1 = '' 
clock = Label(root, font=('times', 20, 'bold'), bg='white') 
clock.pack(fill=BOTH, expand=1) 

def tick(): 
    global time1 
    # get the current local time from the PC 
    time2 = time.strftime('%H:%M:%S') 
    # if time string has changed, update it 
    if time2 != time1: 
        time1 = time2 
        clock.config(text=time2) 
    # calls itself every 200 milliseconds 
    # to update the time display as needed 
    # could use >200 ms, but display gets jerky 
    clock.after(200, tick) 

tick() 
root.mainloop(  )  
Thanks
Gio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20101105/166b5ad3/attachment.html>


More information about the pygtk mailing list