X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7403ad2d154a8e2974fdc5fc215258f3a75cdde..3d2d9036037d9ee51f47d878c3dcef4af4a6ef41:/wxPython/wx/lib/analogclock.py diff --git a/wxPython/wx/lib/analogclock.py b/wxPython/wx/lib/analogclock.py index 116ce17093..ce30eaa68d 100644 --- a/wxPython/wx/lib/analogclock.py +++ b/wxPython/wx/lib/analogclock.py @@ -20,6 +20,9 @@ # o Many ehnacements # +""" +`AnalogClockWindow` is a simple analog clock class. +""" import math import sys @@ -80,7 +83,7 @@ class AnalogClockWindow(wx.PyWindow): self.tickMarkHoursPen = wx.Pen((0, 0, 0), 1, wx.SOLID) self.tickMarkHoursBrush = wx.Brush((0, 0, 0), wx.SOLID) self.markSizeHour = 10 - self.tickMarkHoursFont = wx.Font(0, wx.SWISS, wx.NORMAL, wx.BOLD) + self.tickMarkHoursFont = wx.Font(1, wx.SWISS, wx.NORMAL, wx.BOLD) self.tickMarkHoursFont.SetPointSize(self.markSizeHour) self.tickMarkMinutesPen = wx.Pen((0, 0, 0), 1, wx.SOLID) @@ -136,7 +139,8 @@ class AnalogClockWindow(wx.PyWindow): def OnPaint(self, event): dc = wx.BufferedPaintDC(self) - self._doDrawHands(dc, True) + if hasattr(self, 'coords'): + self._doDrawHands(dc, True) def OnTimerExpire(self, event): @@ -455,17 +459,17 @@ class AnalogClockWindow(wx.PyWindow): drawDC.DrawPolygon(points) - def _pol2rect(self, r, w, deg=1): # radian if deg=0; degree if deg=1 + def _pol2rect(self, r, w, deg=1): # radian if deg=0; degree if deg=1 if deg: - w = math.pi * w / 180.0 + w = math.pi * w / 180.0 return r * math.cos(w), r * math.sin(w) - def _rect2pol(self, x, y, deg=1): # radian if deg=0; degree if deg=1 + def _rect2pol(self, x, y, deg=1): # radian if deg=0; degree if deg=1 if deg: - return math.hypot(x, y), 180.0 * math.atan2(y, x) / math.pi + return math.hypot(x, y), 180.0 * math.atan2(y, x) / math.pi else: - return math.hypot(x, y), math.atan2(y, x) + return math.hypot(x, y), math.atan2(y, x) def _center2corner(self, x, y, tipo, drawDC=None): @@ -735,21 +739,23 @@ class AnalogClockWindow(wx.PyWindow): def SetClockStyle(self, style): """ - Set the clock style, acording to the options: + Set the clock style, acording to these options: - SHOW_QUARTERS_TICKS - Show marks for hours 3, 6, 9, 12 - SHOW_HOURS_TICKS - Show marks for all hours - SHOW_MINUTES_TICKS - Show marks for minutes + ==================== ================================ + SHOW_QUARTERS_TICKS Show marks for hours 3, 6, 9, 12 + SHOW_HOURS_TICKS Show marks for all hours + SHOW_MINUTES_TICKS Show marks for minutes - SHOW_HOURS_HAND - Show hours hand - SHOW_MINUTES_HAND - Show minutes hand - SHOW_SECONDS_HAND - Show seconds hand + SHOW_HOURS_HAND Show hours hand + SHOW_MINUTES_HAND Show minutes hand + SHOW_SECONDS_HAND Show seconds hand - SHOW_SHADOWS - Show hands and marks shadows + SHOW_SHADOWS Show hands and marks shadows - ROTATE_TICKS - Align tick marks to watch - OVERLAP_TICKS - Draw tick marks for minutes even + ROTATE_TICKS Align tick marks to watch + OVERLAP_TICKS Draw tick marks for minutes even when they match the hours marks. + ==================== ================================ """ self.clockStyle = style @@ -759,14 +765,17 @@ class AnalogClockWindow(wx.PyWindow): """ Set the ticks styles, acording to the options below. - TICKS_NONE = Don't show tick marks. - TICKS_SQUARE = Use squares as tick marks. - TICKS_CIRCLE = Use circles as tick marks. - TICKS_POLY = Use a polygon as tick marks. The polygon - must be passed using SetTickShapes, - otherwise the default polygon will be used. - TICKS_DECIMAL = Use decimal numbers. - TICKS_ROMAN = Use Roman numbers. + ================= ===================================== + TICKS_NONE Don't show tick marks. + TICKS_SQUARE Use squares as tick marks. + TICKS_CIRCLE Use circles as tick marks. + TICKS_POLY Use a polygon as tick marks. The + polygon must be passed using + SetTickShapes, otherwise the default + polygon will be used. + TICKS_DECIMAL Use decimal numbers. + TICKS_ROMAN Use Roman numbers. + ================= ===================================== """ if h: