]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-18/timer.py
4 class ClockWindow(wx
.Window
):
5 def __init__(self
, parent
):
6 wx
.Window
.__init
__(self
, parent
)
7 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
8 self
.timer
= wx
.Timer(self
)
9 self
.Bind(wx
.EVT_TIMER
, self
.OnTimer
, self
.timer
)
10 self
.timer
.Start(1000)
13 t
= time
.localtime(time
.time())
14 st
= time
.strftime("%I:%M:%S", t
)
15 w
, h
= self
.GetClientSize()
16 dc
.SetBackground(wx
.Brush(self
.GetBackgroundColour()))
18 dc
.SetFont(wx
.Font(30, wx
.SWISS
, wx
.NORMAL
, wx
.NORMAL
))
19 tw
, th
= dc
.GetTextExtent(st
)
20 dc
.DrawText(st
, (w
-tw
)/2, (h
)/2 - th
/2)
22 def OnTimer(self
, evt
):
23 dc
= wx
.BufferedDC(wx
.ClientDC(self
))
26 def OnPaint(self
, evt
):
27 dc
= wx
.BufferedPaintDC(self
)
30 class MyFrame(wx
.Frame
):
32 wx
.Frame
.__init
__(self
, None, title
="wx.Timer")
36 app
= wx
.PySimpleApp()