1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import wx, time
class Frame(wx.Frame):
def __init__(s,parent=None):
wx.Frame.__init__(s,parent,-1,'clock')
panel=wx.Panel(s,-1)
s.txtC=wx.TextCtrl(panel,-1,style=wx.NO_BORDER|wx.TE_READONLY,size=(100,50))
s.txtC.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
s.txtC.SetBackgroundColour((236,233,216,255))
font=wx.Font(12, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
s.txtC.SetFont(font)
s.txtC.SetValue('%s:%s:%s'%tuple([str(x).rjust(2,'0') for x in time.localtime()[3:6]]))
s.SetSize(s.txtC.GetSize())
s.timer=wx.Timer(s)
s.Bind(wx.EVT_TIMER,s.onTimer,s.timer)
s.timer.Start(1000)
def onTimer(s,e=None):
s.txtC.Clear()
s.txtC.SetValue('%s:%s:%s'%tuple([str(x).rjust(2,'0') for x in time.localtime()[3:6]]))
class App(wx.App):
def OnInit(s):
frame=Frame()
frame.Show()
return True
def main():
app=App(redirect=False)
app.MainLoop()
if __name__=='__main__':
main() |
Partager