PyGTK: Digital Clock
Linux tutorials and code.
1 post
Page 1 of 1
Source - http://stackoverflow.com/questions/6892 ... gtk-window
I added some additional options so you can change the color if you like.
I added some additional options so you can change the color if you like.
Code: Select all
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import pango
import time
class Clock:
def __init__(self):
me = gtk.Window(gtk.WINDOW_TOPLEVEL)
me.connect("destroy", lambda w: gtk.main_quit())
me.set_resizable(False)
me.set_property('skip-taskbar-hint', True)
self.label = gtk.Label()
self.label.modify_font(pango.FontDescription("FreeSerif Bold 50"))
attr = pango.AttrList()
fg_color = pango.AttrForeground(65535, 0, 0, 0, 65535)
attr.insert(fg_color)
self.label.set_attributes(attr)
me.add(self.label)
me.show_all()
def update(self):
self.label.set_text(time.strftime('%H:%M:%S'))
return True # needed to keep the update method in the schedule
clock = Clock()
gtk.timeout_add(200, clock.update) # add to the main loop scheduled tasks
gtk.main()
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023