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