-
Notifications
You must be signed in to change notification settings - Fork 21
/
Clock.py
executable file
·55 lines (38 loc) · 1.44 KB
/
Clock.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import wx
from wx.lib.analogclock import *
class MainWindow(wx.Dialog):
""" This window displays a clock and a button """
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(800,600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
self.SetBackgroundColour(wx.WHITE)
self.SetDoubleBuffered(True)
clock = AnalogClockWindow(self)
clock.SetBackgroundColour("RED")
clock.SetHandColours("BLUE")
clock.SetTickColours("WHITE")
btn = wx.Button(self, wx.ID_OK, "OK")
box = wx.BoxSizer(wx.VERTICAL)
box.Add(clock,1, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL | wx.SHAPED, 10)
box.Add(btn, 0, wx.ALIGN_CENTER | wx.ALL, 10)
self.SetAutoLayout(True)
self.SetSizer(box)
self.Layout()
self.ShowModal()
self.Destroy()
class MyApp(wx.App):
def OnInit(self):
Dw, Dh = wx.DisplaySize()
Dw_mm, Dh_mm = wx.DisplaySizeMM()
Dw_i = Dw_mm / 25.4
Dh_i = Dh_mm / 25.4
print("The display is %i by %i pixels" %(Dw, Dh))
print("The display is %i by %i inches" %(Dw_i, Dh_i))
print("resulting in %i by %i ppi" %(Dw / Dw_i, Dh / Dh_i))
frame = MainWindow(None, -1, "Clock")
self.SetTopWindow(frame)
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()