fork download
  1. # -*- coding: utf-8 -*-
  2. import wx
  3. import datetime
  4.  
  5. class Sample(wx.Frame):
  6. def __init__(self, parent):
  7. wx.Frame.__init__(self, None, wx.ID_ANY, title=u"時間", size=(350,200))
  8.  
  9. self.Bind(wx.EVT_PAINT, self.OnPaint)
  10. self.timer = wx.Timer(self)
  11. self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
  12. self.timer.Start(1000)
  13.  
  14. def Draw(self, dc):
  15. t = datetime.datetime.now()
  16. st1 = t.strftime("%Y/%m/%d %H:%M:%S")
  17. st = u"現在時刻: " + st1
  18. dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
  19. dc.Clear()
  20. dc.SetFont(wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL))
  21. dc.DrawText(st, 20, 20)
  22.  
  23. def OnTimer(self, evt):
  24. dc = wx.BufferedDC(wx.ClientDC(self))
  25. self.Draw(dc)
  26.  
  27. def OnPaint(self, evt):
  28. dc = wx.BufferedPaintDC(self)
  29. self.Draw(dc)
  30.  
  31. if __name__ == '__main__':
  32. app = wx.App()
  33. frm = Sample(app)
  34. frm.Show()
  35. app.MainLoop()
  36.  
Runtime error #stdin #stdout #stderr 0s 23352KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
ImportError: No module named wx