1 # -*- coding: iso-8859-1 -*-
2 #----------------------------------------------------------------------
3 # Name: wx.lib.analogclock
4 # Purpose: A simple analog clock window
6 # Author: several folks on wxPython-users
8 # Created: 16-April-2003
10 # Copyright: (c) 2003 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------
13 # 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
15 # o Updated for wx namespace
16 # o Tested with updated demo and with builtin test.
18 # 15-February-2004 - E. A. Tacao
31 from analogclockopts
import ACCustomizationFrame
35 SHOW_QUARTERS_TICKS
= 1
37 SHOW_MINUTES_TICKS
= 4
40 SHOW_MINUTES_HAND
= 32
41 SHOW_SECONDS_HAND
= 64
45 # self.tickMarkHoursStyle and self.tickMarkMinutesStyle:
54 class AnalogClockWindow(wx
.Window
):
55 """An analog clock window"""
57 def __init__(self
, parent
, ID
=-1, pos
=wx
.DefaultPosition
, size
=wx
.DefaultSize
,
58 style
=0, name
="clock"):
60 # Initialize the wxWindow...
61 wx
.Window
.__init
__(self
, parent
, ID
, pos
, size
, style
, name
)
63 # Initialize some variables and defaults...
65 self
.prefs_open
= False
67 self
.tickShapeHours
= self
.tickShapeMinutes
= [[0,0],
71 self
.handHoursThickness
= 5
72 self
.handHoursColour
= (0, 0, 0)
74 self
.handMinutesThickness
= 3
75 self
.handMinutesColour
= (0, 0, 0)
77 self
.handSecondsThickness
= 1
78 self
.handSecondsColour
= (0, 0, 0)
80 self
.tickMarkHoursPen
= wx
.Pen((0, 0, 0), 1, wx
.SOLID
)
81 self
.tickMarkHoursBrush
= wx
.Brush((0, 0, 0), wx
.SOLID
)
82 self
.markSizeHour
= 10
83 self
.tickMarkHoursFont
= wx
.Font(0, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
)
84 self
.tickMarkHoursFont
.SetPointSize(self
.markSizeHour
)
86 self
.tickMarkMinutesPen
= wx
.Pen((0, 0, 0), 1, wx
.SOLID
)
87 self
.tickMarkMinutesBrush
= wx
.Brush((0, 0, 0), wx
.SOLID
)
89 self
.tickMarkMinutesFont
= wx
.Font(self
.markSizeMin
, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
)
93 self
.shadowPenColour
= self
.shadowBrushColour
= (128,128,128)
96 self
.watchBrush
= None
98 self
.clockStyle
= SHOW_HOURS_TICKS | SHOW_MINUTES_TICKS | SHOW_SHADOWS | ROTATE_TICKS
99 self
.handsStyle
= SHOW_SECONDS_HAND
101 self
.tickMarkHoursStyle
= TICKS_POLY
102 self
.tickMarkMinutesStyle
= TICKS_CIRCLE
104 self
.currentTime
=None
106 # Make an initial bitmap for the face, it will be updated and
107 # painted at the first EVT_SIZE event.
109 self
.faceBitmap
= wx
.EmptyBitmap(max(W
,1), max(H
,1))
111 # Set event handlers...
112 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
113 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, lambda x
: None)
114 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
115 self
.Bind(wx
.EVT_TIMER
, self
.OnTimerExpire
)
116 self
.Bind(wx
.EVT_WINDOW_DESTROY
, self
.OnQuit
)
117 self
.Bind(wx
.EVT_RIGHT_DOWN
, self
.OnRightDown
)
118 self
.Bind(wx
.EVT_RIGHT_UP
, self
.OnRightClick
)
121 # Initialize the timer that drives the update of the clock
122 # face. Update every half second to ensure that there is at
123 # least one true update during each realtime second.
124 self
.timer
= wx
.Timer(self
)
125 self
.timer
.Start(500)
128 def OnPaint(self
, event
):
129 self
._doDrawHands
(wx
.BufferedPaintDC(self
), True)
132 def OnTimerExpire(self
, event
):
133 size
= self
.GetClientSize()
134 dc
= wx
.BufferedDC(wx
.ClientDC(self
), size
)
135 self
._doDrawHands
(dc
, True)
138 def OnQuit(self
, event
):
143 def OnRightDown(self
, event
):
144 self
.x
= event
.GetX()
145 self
.y
= event
.GetY()
149 def OnRightClick(self
, event
):
150 # only do this part the first time so the events are only bound once
151 if not hasattr(self
, "popupID1"):
152 self
.popupID1
= wx
.NewId()
153 self
.popupID2
= wx
.NewId()
154 self
.Bind(wx
.EVT_MENU
, self
.OnPopupOne
, id=self
.popupID1
)
155 self
.Bind(wx
.EVT_MENU
, self
.OnPopupTwo
, id=self
.popupID2
)
160 sm
.Append(self
.popupID1
, "Customize...")
161 sm
.Append(self
.popupID2
, "About...")
163 # If there already a setup window open, we must not appear...
164 if not self
.prefs_open
:
165 # Popup the menu. If an item is selected then its handler
166 # will be called before PopupMenu returns.
167 self
.PopupMenu(sm
, (self
.x
,self
.y
))
171 def OnPopupOne(self
, event
):
173 frame
= ACCustomizationFrame(self
, -1, "AnalogClock Preferences")
177 def OnPopupTwo(self
, event
):
178 dlg
= wx
.MessageDialog(self
, "AnalogClockWindow\n\nby Several folks on wxPython-users\nwith enhancements from E. A. Tacão",
179 'About', wx
.OK | wx
.ICON_INFORMATION
)
184 def OnSize(self
, event
):
185 # The faceBitmap init is done here, to make sure the buffer is always
186 # the same size as the Window
187 size
= self
.GetClientSize()
188 self
.faceBitmap
= wx
.EmptyBitmap(size
.width
, size
.height
)
190 # Update drawing coordinates...
192 if not hasattr(self
,"dim"):
196 self
.scale
= min([float(new_dim
[x
]) / self
.dim
[x
],
197 float(new_dim
[y
]) / self
.dim
[y
]])
199 self
.centerX
= self
.faceBitmap
.GetWidth() / 2
200 self
.centerY
= self
.faceBitmap
.GetHeight() / 2
202 self
.shadowDistance
= 2 * self
.scale
204 self
.radius_watch
= min(self
.centerX
, self
.centerY
)
210 def _doDrawHands(self
, drawDC
, force
=0):
211 currentTime
= list(time
.localtime(time
.time())[3:6])
213 if not (self
.handsStyle
& SHOW_SECONDS_HAND
):
216 if not (force
or currentTime
!= self
.currentTime
):
218 self
.currentTime
= currentTime
219 hour
, minutes
, seconds
= currentTime
221 # Start by drawing the face bitmap
222 drawDC
.DrawBitmap(self
.faceBitmap
, (0,0))
225 # NOTE: All this hand drawing code below should be refactored into a helper function.
228 # Draw hours hand shadow
229 mStep
= 6 * self
.clockStep
233 angle
= angle
+ round(minutes
/(mStep
*2)) * mStep
235 x
,y
,f
= self
._getCoords
("hand_hours", angle
)
237 if f
and self
.clockStyle
& SHOW_SHADOWS
:
238 drawDC
.SetPen(wx
.Pen(self
.shadowPenColour
,
239 int(self
.handHoursThickness
* self
.scale
),
241 drawDC
.DrawLineXY(int(self
.centerX
+ self
.shadowDistance
),
242 int(self
.centerY
+ self
.shadowDistance
),
243 int(x
+ self
.shadowDistance
),
244 int(y
+ self
.shadowDistance
))
246 # Draw minutes hand shadow
248 x
,y
,f
= self
._getCoords
("hand_minutes", angle
)
250 if f
and self
.clockStyle
& SHOW_SHADOWS
:
251 drawDC
.SetPen(wx
.Pen(self
.shadowPenColour
,
252 int(self
.handMinutesThickness
* self
.scale
),
254 drawDC
.DrawLineXY(int(self
.centerX
+ self
.shadowDistance
),
255 int(self
.centerY
+ self
.shadowDistance
),
256 int(x
+ self
.shadowDistance
),
257 int(y
+ self
.shadowDistance
))
259 # Draw seconds hand shadow if required
262 x
,y
,f
= self
._getCoords
("hand_seconds", angle
)
264 if f
and self
.clockStyle
& SHOW_SHADOWS
:
265 drawDC
.SetPen(wx
.Pen(self
.shadowPenColour
,
266 int(self
.handSecondsThickness
* self
.scale
),
268 drawDC
.DrawLineXY(int(self
.centerX
+ self
.shadowDistance
),
269 int(self
.centerY
+ self
.shadowDistance
),
270 int(x
+ self
.shadowDistance
),
271 int(y
+ self
.shadowDistance
))
278 angle
= angle
+ round(minutes
/(mStep
*2)) * mStep
280 x
,y
,f
= self
._getCoords
("hand_hours", angle
)
283 drawDC
.SetPen(wx
.Pen(self
.handHoursColour
,
284 int(self
.handHoursThickness
* self
.scale
),
286 drawDC
.DrawLineXY(int(self
.centerX
), int(self
.centerY
), int(x
), int(y
))
290 x
,y
,f
= self
._getCoords
("hand_minutes", angle
)
293 drawDC
.SetPen(wx
.Pen(self
.handMinutesColour
,
294 int(self
.handMinutesThickness
* self
.scale
),
296 drawDC
.DrawLineXY(int(self
.centerX
), int(self
.centerY
), int(x
), int(y
))
298 # Draw seconds hand if required
301 x
,y
,f
= self
._getCoords
("hand_seconds", angle
)
303 drawDC
.SetPen(wx
.Pen(self
.handSecondsColour
,
304 int(self
.handSecondsThickness
* self
.scale
),
306 drawDC
.DrawLineXY(int(self
.centerX
), int(self
.centerY
), int(x
), int(y
))
310 def _doDrawFace(self
):
311 backgroundBrush
= wx
.Brush(self
.GetBackgroundColour(), wx
.SOLID
)
312 drawDC
= wx
.MemoryDC()
313 drawDC
.SelectObject(self
.faceBitmap
)
314 drawDC
.SetBackground(backgroundBrush
)
317 self
.handHoursLength
= 0.65 * (self
.radius_watch
- self
._getMarkMaxSize
("ticks_hours", drawDC
))
318 self
.handMinutesLength
= 0.85 * (self
.radius_watch
- self
._getMarkMaxSize
("ticks_hours", drawDC
))
319 self
.handSecondsLength
= 0.85 * (self
.radius_watch
- self
._getMarkMaxSize
("ticks_hours", drawDC
))
321 self
.radius_ticks_hours
= self
.radius_watch
- self
.shadowDistance
- self
._getMarkMaxSize
("ticks_hours", drawDC
)
322 self
.radius_ticks_minutes
= self
.radius_ticks_hours
327 self
._drawWatch
(drawDC
)
329 # Draw the marks for hours and minutes...
331 mStep
= 6 * self
.clockStep
333 if self
.clockStyle
& SHOW_SHADOWS
:
334 for i
in range(0, circle
, mStep
):
335 for t
in self
.coords
.keys():
336 if t
.find("ticks") > -1:
337 x
,y
,f
= self
._getCoords
(t
, i
)
339 self
._doDrawTickMark
(i
, drawDC
, t
,
340 x
+ self
.shadowDistance
,
341 y
+ self
.shadowDistance
,
344 for i
in range(0, circle
, mStep
):
345 for t
in self
.coords
.keys():
346 if t
.find("ticks") > -1:
347 x
,y
,f
= self
._getCoords
(t
, i
)
349 self
._doDrawTickMark
(i
, drawDC
, t
, x
, y
)
353 def _doDrawTickMark(self
, angle
, drawDC
, tipo
, x
, y
, is_a_shadow
=None):
354 opts
= {"ticks_hours": [self
.tickMarkHoursPen
, self
.tickMarkHoursBrush
, self
.markSizeHour
, self
.tickMarkHoursStyle
],
355 "ticks_quarters": [self
.tickMarkHoursPen
, self
.tickMarkHoursBrush
, self
.markSizeHour
, self
.tickMarkHoursStyle
],
356 "ticks_minutes": [self
.tickMarkMinutesPen
, self
.tickMarkMinutesBrush
, self
.markSizeMin
, self
.tickMarkMinutesStyle
]}
358 pen
, brush
, size
, style
= opts
[tipo
];
359 size
= size
* self
.scale
362 drawDC
.SetPen(wx
.Pen(self
.shadowPenColour
, 1, wx
.SOLID
))
363 drawDC
.SetBrush(wx
.Brush(self
.shadowBrushColour
, wx
.SOLID
))
364 drawDC
.SetTextForeground(self
.shadowBrushColour
)
367 drawDC
.SetBrush(brush
)
368 drawDC
.SetTextForeground(brush
.GetColour())
370 if style
& TICKS_CIRCLE
:
371 x
, y
= self
._center
2corner
(x
, y
, tipo
)
372 drawDC
.DrawEllipse((x
, y
), (int(size
), int(size
)))
374 elif style
& TICKS_SQUARE
:
375 x
, y
= self
._center
2corner
(x
, y
, tipo
)
376 drawDC
.DrawRectangle((x
, y
), (int(size
), int(size
)))
378 elif (style
& TICKS_DECIMAL
) or (style
& TICKS_ROMAN
):
379 self
._draw
_rotate
_text
(drawDC
, x
, y
, tipo
, angle
)
381 elif style
& TICKS_POLY
:
382 self
._draw
_rotate
_polygon
(drawDC
, x
, y
, tipo
, angle
)
385 def _draw_rotate_text(self
, drawDC
, x
, y
, tipo
, angle
):
386 text
= self
._build
_text
(angle
, tipo
)
387 lX
, lY
= self
._center
2corner
(x
, y
, tipo
, drawDC
)
391 if self
.clockStyle
& ROTATE_TICKS
:
392 radiansPerDegree
= math
.pi
/ 180
394 ((math
.cos((angle
) * radiansPerDegree
)*lX
) +
395 (math
.sin((angle
) * radiansPerDegree
)*lY
)))
397 ((math
.cos((angle
) * radiansPerDegree
)*lY
) -
398 (math
.sin((angle
) * radiansPerDegree
)*lX
)))
399 drawDC
.DrawRotatedText(text
, (x
,y
), angle
)
404 drawDC
.DrawText(text
, (x
, y
))
407 def _draw_rotate_polygon(self
, drawDC
, x
, y
, tipo
, angle
):
408 if tipo
=="ticks_quarters":
411 # Add to empty list to prevent system-wide hard freezes under XP...
412 points
= {"ticks_hours":self.tickShapeHours+[], "ticks_minutes":self.tickShapeMinutes+[]}
[tipo
]
413 size
= self
.scale
* {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}
[tipo
]
415 maxX
= max(map(lambda x
:x
[0],points
))
416 minX
= min(map(lambda x
:x
[0],points
))
417 maxY
= max(map(lambda x
:x
[0],points
))
418 minY
= min(map(lambda x
:x
[0],points
))
420 maxB
= abs(max(maxX
, maxY
));
423 orgX
= (maxX
- minX
) / 2.
424 orgY
= (maxY
- minY
) / 2.
426 radiansPerDegree
= math
.pi
/ 180
430 for z
in range(0, len(points
)):
434 if self
.clockStyle
& ROTATE_TICKS
:
435 m
,t
= self
._rect
2pol
(x
,y
)
437 x
,y
= self
._pol
2rect
(m
,t
)
440 points
[z
] = [int(x
), int(y
)]
442 drawDC
.DrawPolygon(points
)
445 def _pol2rect(self
, r
, w
, deg
=1): # radian if deg=0; degree if deg=1
447 w
= math
.pi
* w
/ 180.0
448 return r
* math
.cos(w
), r
* math
.sin(w
)
451 def _rect2pol(self
, x
, y
, deg
=1): # radian if deg=0; degree if deg=1
453 return math
.hypot(x
, y
), 180.0 * math
.atan2(y
, x
) / math
.pi
455 return math
.hypot(x
, y
), math
.atan2(y
, x
)
458 def _center2corner(self
, x
, y
, tipo
, drawDC
=None):
459 if tipo
== "ticks_quarters":
462 style
= {"ticks_hours":self.tickMarkHoursStyle, "ticks_minutes":self.tickMarkMinutesStyle}
[tipo
]
463 size
= self
.scale
* {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}
[tipo
]
465 if style
& TICKS_DECIMAL
or style
& TICKS_ROMAN
:
466 font
= {"ticks_hours":self.tickMarkHoursFont, "ticks_minutes":self.tickMarkMinutesFont}
[tipo
]
467 font
.SetPointSize(int(size
));
469 lX
= drawDC
.GetCharWidth() / 2.
470 lY
= drawDC
.GetCharHeight() / 2.
474 size
= self
.scale
* {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}
[tipo
]
475 x
=x
-size
/2.;y
=y
-size
/2.
479 def _build_text(self
, angle
, tipo
):
480 if tipo
== "ticks_quarters":
485 divider
= {"ticks_hours":30,"ticks_minutes":6}
[tipo
]
488 style
= {"ticks_hours":self.tickMarkHoursStyle," ticks_minutes":self.tickMarkMinutesStyle}
[tipo
]
489 if style
& TICKS_ROMAN
:
490 text
=["I","II","III","IV","V","VI","VII","VIII","IX","X", \
491 "XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX", \
492 "XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX", \
493 "XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL", \
494 "XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L", \
495 "LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"][a
-1]
502 def _getMarkMaxSize(self
, tipo
, drawDC
=None):
503 if tipo
== "ticks_quarters":
506 style
= {"ticks_hours":self.tickMarkHoursStyle, "ticks_minutes":self.tickMarkMinutesStyle}
[tipo
]
507 size
= self
.scale
* {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}
[tipo
]
509 if style
& TICKS_DECIMAL
or style
& TICKS_ROMAN
:
510 lX
= 2 * drawDC
.GetCharWidth()
511 lY
= drawDC
.GetCharHeight()
512 size
= math
.sqrt(lX
**2 + lY
**2) * self
.scale
514 size
=math
.sqrt(2) * size
519 def _drawWatch(self
, drawDC
):
521 if self
.watchPen
or self
.watchBrush
:
523 drawDC
.SetPen(self
.watchPen
)
525 drawDC
.SetBrush(self
.watchBrush
)
527 drawDC
.SetBrush(wx
.Brush(self
.GetBackgroundColour(), wx
.SOLID
))
528 drawDC
.DrawCircle((self
.centerX
, self
.centerY
), self
.radius_watch
)
531 def _calcSteps(self
):
532 # Calcule todos os pontos para:
534 # - marcas de minutos
535 # - ponteiro de horas
536 # - ponteiro de minutos
537 # - ponteiro de segundos
540 mStep
= 6 * self
.clockStep
# Step in degrees...
542 vq
= 90 * (self
.clockStyle
& SHOW_QUARTERS_TICKS
) / SHOW_QUARTERS_TICKS
543 vh
= 30 * (self
.clockStyle
& SHOW_HOURS_TICKS
) / SHOW_HOURS_TICKS
544 vm
= 1 * (self
.clockStyle
& SHOW_MINUTES_TICKS
) / SHOW_MINUTES_TICKS
546 coords
= {"ticks_quarters": [self.radius_ticks_hours, 60,vq,{}
],
547 "ticks_hours": [self
.radius_ticks_hours
, 60,vh
,{}],
548 "ticks_minutes": [self
.radius_ticks_minutes
,60,vm
,{}],
549 "hand_hours": [self
.handHoursLength
, 60,1, {}],
550 "hand_minutes": [self
.handMinutesLength
, 60,1, {}],
551 "hand_seconds": [self
.handSecondsLength
, 60,1, {}]}
553 radiansPerDegree
= math
.pi
/ 180
555 for t
in coords
.keys():
556 for i
in range(0, circle
+mStep
, mStep
):
557 radius
= coords
[t
][0]
558 if t
== "ticks_minutes":
559 radius
= radius
- self
.offM
560 step_angle
= 360. / coords
[t
][1]
562 x
= self
.centerX
+ radius
* math
.sin(i
* radiansPerDegree
)
563 y
= self
.centerY
+ radius
* math
.cos(i
* radiansPerDegree
)
564 f
= (pre
and (i
/step_angle
== int(i
/step_angle
)) and (float(i
)/pre
== int(i
/pre
)))
565 coords
[t
][3][i
] = [x
,y
,f
]
567 if not self
.clockStyle
& OVERLAP_TICKS
:
568 for i
in range(0, circle
+ mStep
, mStep
):
569 f
=coords
["ticks_minutes"][3][i
][2]
571 (coords
["ticks_hours"][3].get(i
,[0,0,0])[2] or coords
["ticks_quarters"][3].get(i
,[0,0,0])[2]):
573 coords
["ticks_minutes"][3][i
][2]=f
578 def _getCoords(self
, tipo
, angle
):
579 # Returns coords and 'use flag' based on current angle...
580 k
= 360 - (angle
+ 180)
583 return self
.coords
[tipo
][3][k
]
586 # -----------------------------------------------------
588 def SetTickShapes(self
, tsh
, tsm
=None):
590 tsh, tsm: [[x0,y0], [x1,y1], ... [xn,yn]]
592 Sets lists of lists of points to be used as polygon shapes
593 when using the TICKS_POLY style. If tsm is ommitted,
594 we'll use tsh for both shapes.
600 self
.tickShapeHours
= tsh
601 self
.tickShapeMinutes
= tsm
604 def SetHandWeights(self
, h
=None, m
=None, s
=None):
608 Sets thickness of hands.
612 self
.handHoursThickness
= h
614 self
.handMinutesThickness
= m
616 self
.handSecondsThickness
= s
619 def SetHandColours(self
, h
=None, m
=None, s
=None):
623 Sets colours of hands. If m and s are ommitted,
627 if h
and not m
and not s
:
632 self
.handHoursColour
= h
634 self
.handMinutesColour
= m
636 self
.handSecondsColour
= s
639 def SetTickColours(self
, h
=None, m
=None):
643 Sets colours of ticks. If m is ommitted,
644 we'll use h for both.
651 self
.tickMarkHoursPen
= wx
.Pen(h
, 1, wx
.SOLID
)
652 self
.tickMarkHoursBrush
= wx
.Brush(h
, wx
.SOLID
)
655 self
.tickMarkMinutesPen
= wx
.Pen(m
, 1, wx
.SOLID
)
656 self
.tickMarkMinutesBrush
= wx
.Brush(m
, wx
.SOLID
)
659 def SetTickSizes(self
, h
=None, m
=None):
663 Sizes for tick marks.
667 self
.markSizeHour
= h
672 def SetTickFonts(self
, h
=None, m
=None):
676 Fonts for tick marks when using TICKS_DECIMAL or TICKS_ROMAN style.
677 If m is ommitted, we'll use h for both.
684 self
.tickMarkHoursFont
= h
685 self
.tickMarkHoursFont
.SetPointSize(self
.markSizeHour
)
687 self
.tickMarkMinutesFont
= m
688 self
.tickMarkMinutesFont
.SetPointSize(self
.markSizeMin
)
691 def SetMinutesOffset(self
, o
):
695 Sets the distance between tick marks for hours and minutes.
700 def SetShadowColour(self
, s
):
702 s = wx.Colour or (r,g,b) tuple.
704 Sets the colour to be used to draw shadows.
707 self
.shadowPenColour
= self
.shadowBrushColour
= s
710 def SetWatchPenBrush(self
, p
=None, b
=None):
712 p = wx.Pen; b = wx.Brush
714 Set the pen and brush for the watch.
723 def SetClockStyle(self
, style
):
725 Set the clock style, acording to the options:
727 SHOW_QUARTERS_TICKS - Show marks for hours 3, 6, 9, 12
728 SHOW_HOURS_TICKS - Show marks for all hours
729 SHOW_MINUTES_TICKS - Show marks for minutes
731 SHOW_HOURS_HAND - Show hours hand
732 SHOW_MINUTES_HAND - Show minutes hand
733 SHOW_SECONDS_HAND - Show seconds hand
735 SHOW_SHADOWS - Show hands and marks shadows
737 ROTATE_TICKS - Align tick marks to watch
738 OVERLAP_TICKS - Draw tick marks for minutes even
739 when they match the hours marks.
742 self
.clockStyle
= style
745 def SetTickStyles(self
, h
=None, m
=None):
747 Set the ticks styles, acording to the options below.
749 TICKS_NONE = Don't show tick marks.
750 TICKS_SQUARE = Use squares as tick marks.
751 TICKS_CIRCLE = Use circles as tick marks.
752 TICKS_POLY = Use a polygon as tick marks. The polygon
753 must be passed using SetTickShapes,
754 otherwise the default polygon will be used.
755 TICKS_DECIMAL = Use decimal numbers.
756 TICKS_ROMAN = Use Roman numbers.
760 self
.tickMarkHoursStyle
= h
762 self
.tickMarkMinutesStyle
= m
764 # -----------------------------------------------------
767 if __name__
== "__main__":
768 print wx
.VERSION_STRING
771 frame
= wx
.Frame(None, -1, "AnalogClockWindow", size
=(375,375))
773 clock
= AnalogClockWindow(frame
)
775 # Settings below are used by default...
776 #clock.SetClockStyle(SHOW_HOURS_TICKS|SHOW_MINUTES_TICKS|SHOW_SHADOWS|ROTATE_TICKS)
777 #clock.SetTickStyles(TICKS_POLY, TICKS_CIRCLE)
779 frame
.Centre(wx
.BOTH
)
781 self
.SetTopWindow(frame
)