]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AnalogClock.py
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.
8 import wx
.lib
.analogclock
as ac
10 #----------------------------------------------------------------------
12 class TestPanel(wx
.Panel
):
13 def __init__(self
, parent
, log
):
15 wx
.Panel
.__init
__(self
, parent
)
17 # A mostly default clock
18 c1
= ac
.AnalogClock(self
, size
=(200,200))
20 if True: # for a simpler test case just set this to False and
21 # only the one clock will be created
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|
31 ac
.SHOW_MINUTES_HAND| \
33 c2
.SetTickSize(12, target
=ac
.HOUR
)
35 # No minute tick marks
36 c3
= ac
.AnalogClock(self
, hoursStyle
=ac
.TICKS_CIRCLE
,
37 clockStyle
=ac
.SHOW_HOURS_TICKS| \
39 ac
.SHOW_MINUTES_HAND| \
40 ac
.SHOW_SECONDS_HAND| \
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| \
48 ac
.SHOW_MINUTES_HAND| \
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
)
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| \
65 ac
.SHOW_MINUTES_HAND| \
66 ac
.SHOW_SECONDS_HAND| \
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
)
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| \
89 ac
.SHOW_MINUTES_HAND| \
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
))
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
)
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)
119 self
.SetSizerAndFit(sizer
)
121 #----------------------------------------------------------------------
123 def runTest(frame
, nb
, log
):
124 win
= TestPanel(nb
, log
)
127 #----------------------------------------------------------------------
133 """ + ac
.__doc
__.replace("<", "").replace(">", "") + """
138 if __name__
== '__main__':
141 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])