]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AnalogClock.py
Added some overview text
[wxWidgets.git] / wxPython / demo / AnalogClock.py
1 # AnalogClock demo
2 # E. A. Tacao <e.a.tacao |at| estadao.com.br>
3 # http://j.domaindlx.com/elements28/wxpython/
4 # 12 Fev 2006, 22:00 GMT-03:00
5 # Distributed under the wxWidgets license.
6
7 import wx
8 import wx.lib.analogclock as ac
9
10 #----------------------------------------------------------------------
11
12 class TestPanel(wx.Panel):
13 def __init__(self, parent, log):
14 self.log = log
15 wx.Panel.__init__(self, parent)
16
17 # A mostly default clock
18 c1 = ac.AnalogClock(self)
19
20 # A plain clock, with square hour and round minute marks, no
21 # shadow, static border
22 c2 = ac.AnalogClock(self, style=wx.STATIC_BORDER,
23 hoursStyle=ac.TICKS_SQUARE,
24 minutesStyle=ac.TICKS_CIRCLE,
25 clockStyle=ac.SHOW_HOURS_TICKS| \
26 ac.SHOW_MINUTES_TICKS|
27 ac.SHOW_HOURS_HAND| \
28 ac.SHOW_MINUTES_HAND| \
29 ac.SHOW_SECONDS_HAND)
30 c2.SetTickSize(12, target=ac.HOUR)
31
32 # No minute tick marks
33 c3 = ac.AnalogClock(self, hoursStyle=ac.TICKS_CIRCLE,
34 clockStyle=ac.SHOW_HOURS_TICKS| \
35 ac.SHOW_HOURS_HAND| \
36 ac.SHOW_MINUTES_HAND| \
37 ac.SHOW_SECONDS_HAND| \
38 ac.SHOW_SHADOWS)
39 c3.SetTickSize(12)
40
41 # A clock with hex numbers no seconds hand and different colours.
42 c4 = ac.AnalogClock(self, hoursStyle=ac.TICKS_HEX,
43 clockStyle=ac.SHOW_HOURS_TICKS| \
44 ac.SHOW_HOURS_HAND| \
45 ac.SHOW_MINUTES_HAND| \
46 ac.SHOW_SHADOWS)
47 colour = wx.Colour(0, 255, 255)
48 c4.SetForegroundColour(colour)
49 colour = wx.Colour(0, 132, 132)
50 c4.SetShadowColour(colour)
51 c4.SetTickFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.BOLD))
52 c4.SetBackgroundColour(wx.BLACK)
53 c4.SetFaceBorderColour(wx.BLACK)
54 c4.SetFaceFillColour(wx.BLACK)
55
56 # A clock with binary numbers shown only at the quarter tick marks,
57 # no minutes ticks and different colours.
58 c5 = ac.AnalogClock(self, style = wx.RAISED_BORDER,
59 hoursStyle=ac.TICKS_BINARY,
60 clockStyle=ac.SHOW_QUARTERS_TICKS| \
61 ac.SHOW_HOURS_HAND| \
62 ac.SHOW_MINUTES_HAND| \
63 ac.SHOW_SECONDS_HAND| \
64 ac.SHOW_SHADOWS)
65 colour = wx.Colour(0, 128, 0)
66 c5.SetHandFillColour(colour, target=ac.SECOND)
67 c5.SetHandBorderColour(colour, target=ac.SECOND)
68 c5.SetBackgroundColour(colour)
69 colour = wx.Colour(128, 0, 64)
70 c5.SetTickFillColour(colour)
71 c5.SetFaceBorderColour(colour)
72 c5.SetFaceBorderWidth(1)
73 colour = wx.Colour(0, 198, 0)
74 c5.SetFaceFillColour(colour)
75 c5.SetShadowColour(wx.WHITE)
76
77 # A clock with a sunken border, roman numerals shown only at the
78 # quarter tick marks with a roman font, circular minutes ticks,
79 # no seconds hand, no shadows, tick overlapping and different colours.
80 c6 = ac.AnalogClock(self, style = wx.SUNKEN_BORDER,
81 hoursStyle=ac.TICKS_ROMAN,
82 minutesStyle=ac.TICKS_CIRCLE,
83 clockStyle=ac.SHOW_QUARTERS_TICKS| \
84 ac.SHOW_MINUTES_TICKS| \
85 ac.SHOW_HOURS_HAND| \
86 ac.SHOW_MINUTES_HAND| \
87 ac.OVERLAP_TICKS)
88 colour = wx.Colour(128, 0, 0)
89 c6.SetHandFillColour(colour)
90 colour = wx.Colour(179, 0, 89)
91 c6.SetHandBorderColour(colour)
92 c6.SetTickFillColour(colour)
93 c6.SetTickBorderColour(colour)
94 colour = wx.Colour(225, 255, 255)
95 c6.SetFaceBorderColour(colour)
96 c6.SetBackgroundColour(colour)
97 colour = wx.Colour(249, 255, 255)
98 c6.SetFaceFillColour(colour)
99 colour = wx.Colour(255, 213, 213)
100 c6.SetShadowColour(colour)
101 c6.SetTickFont(wx.Font(10, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.BOLD))
102
103 # layout the clocks in a grid
104 gs = wx.GridSizer(2, 3, 4, 4)
105 gs.Add(c1, 0, wx.EXPAND)
106 gs.Add(c2, 0, wx.EXPAND)
107 gs.Add(c3, 0, wx.EXPAND)
108 gs.Add(c4, 0, wx.EXPAND)
109 gs.Add(c5, 0, wx.EXPAND)
110 gs.Add(c6, 0, wx.EXPAND)
111
112 # put it in another sizer for a border
113 sizer = wx.BoxSizer(wx.VERTICAL)
114 sizer.Add(gs, 1, wx.EXPAND|wx.ALL, 10)
115
116 self.SetSizerAndFit(sizer)
117
118 #----------------------------------------------------------------------
119
120 def runTest(frame, nb, log):
121 win = TestPanel(nb, log)
122 return win
123
124 #----------------------------------------------------------------------
125
126
127
128 overview = """<html>
129 <PRE><FONT SIZE=-1>
130 """ + ac.__doc__.replace("<", "").replace(">", "") + """
131 </FONT></PRE>"""
132
133
134
135 if __name__ == '__main__':
136 import sys,os
137 import run
138 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
139