]>
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
)
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|
28 ac
.SHOW_MINUTES_HAND| \
30 c2
.SetTickSize(12, target
=ac
.HOUR
)
32 # No minute tick marks
33 c3
= ac
.AnalogClock(self
, hoursStyle
=ac
.TICKS_CIRCLE
,
34 clockStyle
=ac
.SHOW_HOURS_TICKS| \
36 ac
.SHOW_MINUTES_HAND| \
37 ac
.SHOW_SECONDS_HAND| \
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| \
45 ac
.SHOW_MINUTES_HAND| \
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
)
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| \
62 ac
.SHOW_MINUTES_HAND| \
63 ac
.SHOW_SECONDS_HAND| \
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
)
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| \
86 ac
.SHOW_MINUTES_HAND| \
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
))
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
)
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)
116 self
.SetSizerAndFit(sizer
)
118 #----------------------------------------------------------------------
120 def runTest(frame
, nb
, log
):
121 win
= TestPanel(nb
, log
)
124 #----------------------------------------------------------------------
130 """ + ac
.__doc
__.replace("<", "").replace(">", "") + """
135 if __name__
== '__main__':
138 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])