954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Put a clock (analog or digital) in pygtk window

I need to put a digital (or analogic) clock in a pygtk window with a exit button.

I was looking a example with Tkinter but I do not know how to integrate in a pygtk window

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( )


And the same with this example: http://www.pygame.org/project-Analog-digital+Clock-994-.html

Thanks

Patagonikus
Newbie Poster
2 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Example pygtk.
http://www.oluyede.org/blog/writing-a-widget-using-cairo-and-pygtk-28-part-2/

Strong gui-toolkit for python are wxpython,PyQT,PyGTK

Here is a picturer off a alrmarclock a made with wxpython for fun.
http://www.esnips.com/doc/e8f216fc-bf2c-4ddc-b0e2-a5b2ee97fd6b/alarm_win_7

snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294
 

I used te cairo example (the analog clock as a popup window)

I still have not found how to insert a digital clock in the window. I will continue trying to do.


Thanks for the reply!


Bye

Example pygtk. http://www.oluyede.org/blog/writing-a-widget-using-cairo-and-pygtk-28-part-2/

Strong gui-toolkit for python are wxpython,PyQT,PyGTK

Here is a picturer off a alrmarclock a made with wxpython for fun. http://www.esnips.com/doc/e8f216fc-bf2c-4ddc-b0e2-a5b2ee97fd6b/alarm_win_7

Patagonikus
Newbie Poster
2 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: