Updated the AnalogClockWindow with many enhancements from from
E. A. Tacão. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a27d1f42e2
commit
f04ad14aa1
@ -1,6 +1,9 @@
|
||||
|
||||
|
||||
|
||||
import wx
|
||||
import wx.lib.analogclock as aclock
|
||||
from wx.lib import analogclock as ac
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@ -9,36 +12,56 @@ class TestPanel(wx.Panel):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
# A red background with blue hands and white markings
|
||||
c1 = aclock.AnalogClockWindow(self)
|
||||
# A mostly default clock
|
||||
c1 = ac.AnalogClockWindow(self)
|
||||
c1.SetBackgroundColour("RED")
|
||||
c1.SetHandsColour("BLUE")
|
||||
c1.SetTickMarkColours("WHITE")
|
||||
c1.SetHandColours("BLUE")
|
||||
c1.SetTickColours("WHITE")
|
||||
c1.SetTickSizes(h=5, m=2)
|
||||
|
||||
# A white background with red hands and blue markings
|
||||
c2 = aclock.AnalogClockWindow(self)
|
||||
|
||||
# A clock with roman numerals, shown only at the quarter
|
||||
# marks, and a separatly coloured watch face.
|
||||
c2 = ac.AnalogClockWindow(self)
|
||||
c2.SetBackgroundColour("WHITE")
|
||||
c2.SetHandsColour("RED")
|
||||
c2.SetTickMarkColours("BLUE")
|
||||
c2.SetHandColours("RED")
|
||||
c2.SetTickColours("BLUE")
|
||||
c2.SetTickStyles(ac.TICKS_ROMAN)
|
||||
c2.SetClockStyle(ac.SHOW_QUARTERS_TICKS | ac.SHOW_SHADOWS)
|
||||
c2.SetWatchPenBrush(p=wx.Pen((238, 238, 227), 1, wx.SOLID),
|
||||
b=wx.Brush("CADET BLUE", wx.SOLID))
|
||||
c2.SetTickSizes(h=12)
|
||||
|
||||
# A blue background with white hands and red markings
|
||||
c3 = aclock.AnalogClockWindow(self)
|
||||
# A clock with rotated decimal numbers, shown at all twelve
|
||||
# hour marks
|
||||
c3 = ac.AnalogClockWindow(self)
|
||||
c3.SetBackgroundColour("BLUE")
|
||||
c3.SetHandsColour("WHITE")
|
||||
c3.SetTickMarkColours("RED")
|
||||
c3.SetHandColours("WHITE")
|
||||
c3.SetTickColours("RED")
|
||||
c3.SetTickStyles(h=ac.TICKS_DECIMAL)
|
||||
c3.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.ROTATE_TICKS)
|
||||
c3.SetTickSizes(h=14)
|
||||
|
||||
# Raised border, circular tick marks.
|
||||
c4 = aclock.AnalogClockWindow(self, style=wx.RAISED_BORDER)
|
||||
c4.SetTickMarkStyle(aclock.AnalogClockWindow.TICKS_CIRCLE)
|
||||
# a plain clock, with square hour and round minute marks, no
|
||||
# shadow raised border
|
||||
c4 = ac.AnalogClockWindow(self, style=wx.RAISED_BORDER)
|
||||
c4.SetTickStyles(h=ac.TICKS_SQUARE, m=ac.TICKS_CIRCLE)
|
||||
c4.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.SHOW_MINUTES_TICKS)
|
||||
c4.SetTickSizes(h=5, m=2)
|
||||
|
||||
# No tick marks
|
||||
c5 = aclock.AnalogClockWindow(self)
|
||||
c5.SetTickMarkStyle(aclock.AnalogClockWindow.TICKS_NONE)
|
||||
|
||||
# Sunken into window
|
||||
c6 = aclock.AnalogClockWindow(self, style=wx.SUNKEN_BORDER)
|
||||
# no minute tick marks
|
||||
c5 = ac.AnalogClockWindow(self)
|
||||
c5.SetTickStyles(h=ac.TICKS_CIRCLE)
|
||||
c5.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.SHOW_SHADOWS | ac.ROTATE_TICKS)
|
||||
c5.SetTickSizes(h=5, m=2)
|
||||
|
||||
# layout the clocks in a grid sizer
|
||||
# sunken border
|
||||
c6 = ac.AnalogClockWindow(self, style=wx.SUNKEN_BORDER)
|
||||
c6.SetTickSizes(h=5, m=2)
|
||||
|
||||
|
||||
# layout the clocks in a grid
|
||||
gs = wx.GridSizer(2, 3, 4, 4)
|
||||
gs.Add(c1, 0, wx.EXPAND)
|
||||
gs.Add(c2, 0, wx.EXPAND)
|
||||
@ -49,7 +72,7 @@ class TestPanel(wx.Panel):
|
||||
|
||||
# put it in another sizer for a border
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(gs, 1, wx.EXPAND|wx.ALL, 10)
|
||||
sizer.Add(gs, 1, wx.EXPAND | wx.ALL, 10)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
|
||||
@ -69,10 +92,13 @@ overview = """<html><body>
|
||||
|
||||
This is a nice little clock class that was contributed to by several
|
||||
members of the wxPython-users group.
|
||||
|
||||
<p>
|
||||
Check the options available by right-clicking the clock.
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
|
@ -51,6 +51,11 @@ want to put them.
|
||||
The wxWave class has been renamed to wxSound, and now has a slightly
|
||||
different API.
|
||||
|
||||
Updated the AnalogClockWindow with many enhancements from from
|
||||
E. A. Tacão.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2.4.2.4
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
#----------------------------------------------------------------------
|
||||
# Name: wxPython.lib.analogclock
|
||||
# Name: wx.lib.analogclock
|
||||
# Purpose: A simple analog clock window
|
||||
#
|
||||
# Author: several folks on wxPython-users
|
||||
@ -14,20 +15,44 @@
|
||||
# o Updated for wx namespace
|
||||
# o Tested with updated demo and with builtin test.
|
||||
#
|
||||
# 15-February-2004 - E. A. Tacao
|
||||
#
|
||||
# o Many ehnacements
|
||||
#
|
||||
|
||||
|
||||
import math
|
||||
import string
|
||||
import sys
|
||||
import string
|
||||
import time
|
||||
|
||||
import wx
|
||||
|
||||
class AnalogClockWindow(wx.Window):
|
||||
"""A simple analog clock window"""
|
||||
from analogclockopts import ACCustomizationFrame
|
||||
|
||||
TICKS_NONE = 0
|
||||
TICKS_SQUARE = 1
|
||||
TICKS_CIRCLE = 2
|
||||
|
||||
# self.clockStyle:
|
||||
SHOW_QUARTERS_TICKS = 1
|
||||
SHOW_HOURS_TICKS = 2
|
||||
SHOW_MINUTES_TICKS = 4
|
||||
ROTATE_TICKS = 8
|
||||
SHOW_HOURS_HAND = 16
|
||||
SHOW_MINUTES_HAND = 32
|
||||
SHOW_SECONDS_HAND = 64
|
||||
SHOW_SHADOWS = 128
|
||||
OVERLAP_TICKS = 256
|
||||
|
||||
# self.tickMarkHoursStyle and self.tickMarkMinutesStyle:
|
||||
TICKS_NONE = 1
|
||||
TICKS_SQUARE = 2
|
||||
TICKS_CIRCLE = 4
|
||||
TICKS_POLY = 8
|
||||
TICKS_DECIMAL = 16
|
||||
TICKS_ROMAN = 32
|
||||
|
||||
|
||||
class AnalogClockWindow(wx.Window):
|
||||
"""An analog clock window"""
|
||||
|
||||
def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, size=wx.DefaultSize,
|
||||
style=0, name="clock"):
|
||||
@ -35,70 +60,79 @@ class AnalogClockWindow(wx.Window):
|
||||
# Initialize the wxWindow...
|
||||
wx.Window.__init__(self, parent, ID, pos, size, style, name)
|
||||
|
||||
# Initialize the default clock settings...
|
||||
self.minuteMarks = 60
|
||||
self.hourMarks = 12
|
||||
self.tickMarksBrushC = self.GetForegroundColour()
|
||||
self.tickMarksPenC = self.GetForegroundColour()
|
||||
self.tickMarkStyle = self.TICKS_SQUARE
|
||||
# Initialize some variables and defaults...
|
||||
self.clockStep = 1
|
||||
self.prefs_open = False
|
||||
|
||||
self.tickShapeHours = self.tickShapeMinutes= [[0,0],
|
||||
[1,-1],
|
||||
[2,0],
|
||||
[1,4]]
|
||||
self.handHoursThickness = 5
|
||||
self.handHoursColour = (0, 0, 0)
|
||||
|
||||
self.handMinutesThickness = 3
|
||||
self.handMinutesColour = (0, 0, 0)
|
||||
|
||||
self.handSecondsThickness = 1
|
||||
self.handSecondsColour = (0, 0, 0)
|
||||
|
||||
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.SetPointSize(self.markSizeHour)
|
||||
|
||||
self.tickMarkMinutesPen = wx.Pen((0, 0, 0), 1, wx.SOLID)
|
||||
self.tickMarkMinutesBrush = wx.Brush((0, 0, 0), wx.SOLID)
|
||||
self.markSizeMin = 6
|
||||
self.tickMarkMinutesFont = wx.Font(self.markSizeMin, wx.SWISS, wx.NORMAL, wx.BOLD)
|
||||
|
||||
self.offM = 0
|
||||
|
||||
self.shadowPenColour = self.shadowBrushColour = (128,128,128)
|
||||
|
||||
self.watchPen = None
|
||||
self.watchBrush = None
|
||||
|
||||
self.clockStyle = SHOW_HOURS_TICKS | SHOW_MINUTES_TICKS | SHOW_SHADOWS | ROTATE_TICKS
|
||||
self.handsStyle = SHOW_SECONDS_HAND
|
||||
|
||||
self.tickMarkHoursStyle = TICKS_POLY
|
||||
self.tickMarkMinutesStyle = TICKS_CIRCLE
|
||||
|
||||
self.currentTime=None
|
||||
|
||||
# Make an initial bitmap for the face, it will be updated and
|
||||
# painted at the first EVT_SIZE event.
|
||||
W, H = size
|
||||
self.faceBitmap = wx.EmptyBitmap(max(W,1), max(H,1))
|
||||
|
||||
# Initialize the timer that drives the update of the clock
|
||||
# face. Update every half second to ensure that there is at
|
||||
# least one true update during each realtime second.
|
||||
self.timer = wx.Timer(self)
|
||||
self.timer.Start(500)
|
||||
|
||||
# Set event handlers...
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
|
||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||
self.Bind(wx.EVT_TIMER, self.OnTimerExpire)
|
||||
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnQuit)
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
|
||||
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
|
||||
|
||||
|
||||
def SetTickMarkStyle(self, style):
|
||||
"""
|
||||
Set the style of the marks around the edge of the clock.
|
||||
Options are TICKS_NONE, TICKS_SQUARE, and TICKS_CIRCLE
|
||||
"""
|
||||
self.tickMarkStyle = style
|
||||
|
||||
|
||||
def SetTickMarkColours(self, brushC, penC="BLACK"):
|
||||
"""
|
||||
Set the brush colour and optionally the pen colour of
|
||||
the marks around the edge of the clock.
|
||||
"""
|
||||
self.tickMarksBrushC = brushC
|
||||
self.tickMarksPenC = penC
|
||||
|
||||
SetTickMarkColour = SetTickMarkColours
|
||||
|
||||
|
||||
def SetHandsColour(self, c):
|
||||
"""An alias for SetForegroundColour"""
|
||||
self.SetForegroundColour(c) # the hands just use the foreground colour
|
||||
|
||||
|
||||
# Using the current settings, render the points and line endings for the
|
||||
# circle inside the specified device context. In this case, the DC is
|
||||
# a memory based device context that will be blitted to the actual
|
||||
# display DC inside the OnPaint() event handler.
|
||||
def OnSize(self, event):
|
||||
# The faceBitmap init is done here, to make sure the buffer is always
|
||||
# the same size as the Window
|
||||
size = self.GetClientSize()
|
||||
self.faceBitmap = wx.EmptyBitmap(size.width, size.height)
|
||||
self.DrawFace()
|
||||
# Initialize the timer that drives the update of the clock
|
||||
# face. Update every half second to ensure that there is at
|
||||
# least one true update during each realtime second.
|
||||
self.timer = wx.Timer(self)
|
||||
self.timer.Start(500)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
self.DrawHands(wx.PaintDC(self))
|
||||
self._doDrawHands(wx.BufferedPaintDC(self), True)
|
||||
|
||||
|
||||
def OnTimerExpire(self, event):
|
||||
size = self.GetClientSize()
|
||||
dc = wx.BufferedDC(wx.ClientDC(self), size)
|
||||
self._doDrawHands(dc, True)
|
||||
|
||||
|
||||
def OnQuit(self, event):
|
||||
@ -106,96 +140,641 @@ class AnalogClockWindow(wx.Window):
|
||||
del self.timer
|
||||
|
||||
|
||||
def OnTimerExpire(self, event):
|
||||
self.DrawHands(wx.ClientDC(self))
|
||||
def OnRightDown(self, event):
|
||||
self.x = event.GetX()
|
||||
self.y = event.GetY()
|
||||
event.Skip()
|
||||
|
||||
|
||||
def DrawHands(self, drawDC):
|
||||
def OnRightClick(self, event):
|
||||
# only do this part the first time so the events are only bound once
|
||||
if not hasattr(self, "popupID1"):
|
||||
self.popupID1 = wx.NewId()
|
||||
self.popupID2 = wx.NewId()
|
||||
self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
|
||||
self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
|
||||
|
||||
# make a menu
|
||||
sm = wx.Menu()
|
||||
|
||||
sm.Append(self.popupID1, "Customize...")
|
||||
sm.Append(self.popupID2, "About...")
|
||||
|
||||
# If there already a setup window open, we must not appear...
|
||||
if not self.prefs_open:
|
||||
# Popup the menu. If an item is selected then its handler
|
||||
# will be called before PopupMenu returns.
|
||||
self.PopupMenu(sm, (self.x,self.y))
|
||||
sm.Destroy()
|
||||
|
||||
|
||||
def OnPopupOne(self, event):
|
||||
self.prefs_open=True
|
||||
frame = ACCustomizationFrame(self, -1, "AnalogClock Preferences")
|
||||
frame.Show(True)
|
||||
|
||||
|
||||
def OnPopupTwo(self, event):
|
||||
dlg = wx.MessageDialog(self, "AnalogClockWindow\n\nby Several folks on wxPython-users\nwith enhancements from E. A. Tacão",
|
||||
'About', wx.OK | wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
# The faceBitmap init is done here, to make sure the buffer is always
|
||||
# the same size as the Window
|
||||
size = self.GetClientSize()
|
||||
self.faceBitmap = wx.EmptyBitmap(size.width, size.height)
|
||||
|
||||
# Update drawing coordinates...
|
||||
new_dim = size.Get()
|
||||
if not hasattr(self,"dim"):
|
||||
self.dim = new_dim
|
||||
|
||||
x,y=[0,1]
|
||||
self.scale = min([float(new_dim[x]) / self.dim[x],
|
||||
float(new_dim[y]) / self.dim[y]])
|
||||
|
||||
self.centerX = self.faceBitmap.GetWidth() / 2
|
||||
self.centerY = self.faceBitmap.GetHeight() / 2
|
||||
|
||||
self.shadowDistance = 2 * self.scale
|
||||
|
||||
self.radius_watch = min(self.centerX, self.centerY)
|
||||
|
||||
self._doDrawFace()
|
||||
|
||||
|
||||
|
||||
def _doDrawHands(self, drawDC, force=0):
|
||||
currentTime = list(time.localtime(time.time())[3:6])
|
||||
|
||||
if not (self.handsStyle & SHOW_SECONDS_HAND):
|
||||
currentTime[2]=-1
|
||||
|
||||
if not (force or currentTime != self.currentTime):
|
||||
return
|
||||
self.currentTime = currentTime
|
||||
hour, minutes, seconds = currentTime
|
||||
|
||||
# Start by drawing the face bitmap
|
||||
drawDC.DrawBitmap(self.faceBitmap, (0,0))
|
||||
|
||||
currentTime = time.localtime(time.time())
|
||||
hour, minutes, seconds = currentTime[3:6]
|
||||
|
||||
W,H = self.faceBitmap.GetWidth(), self.faceBitmap.GetHeight()
|
||||
centerX = W / 2
|
||||
centerY = H / 2
|
||||
|
||||
radius = min(centerX, centerY)
|
||||
hour += minutes / 60.0 # added so the hour hand moves continuously
|
||||
x, y = self.point(hour, 12, (radius * .65))
|
||||
hourX, hourY = (x + centerX), (centerY - y)
|
||||
x, y = self.point(minutes, 60, (radius * .85))
|
||||
minutesX, minutesY = (x + centerX), (centerY - y)
|
||||
x, y = self.point(seconds, 60, (radius * .85))
|
||||
secondsX, secondsY = (x + centerX), (centerY - y)
|
||||
|
||||
# Draw the hour hand...
|
||||
drawDC.SetPen(wx.Pen(self.GetForegroundColour(), 5, wx.SOLID))
|
||||
drawDC.DrawLine((centerX, centerY), (hourX, hourY))
|
||||
|
||||
# Draw the minutes hand...
|
||||
drawDC.SetPen(wx.Pen(self.GetForegroundColour(), 3, wx.SOLID))
|
||||
drawDC.DrawLine((centerX, centerY), (minutesX, minutesY))
|
||||
|
||||
# Draw the seconds hand...
|
||||
drawDC.SetPen(wx.Pen(self.GetForegroundColour(), 1, wx.SOLID))
|
||||
drawDC.DrawLine((centerX, centerY), (secondsX, secondsY))
|
||||
# NOTE: All this hand drawing code below should be refactored into a helper function.
|
||||
|
||||
|
||||
# Draw the specified set of line marks inside the clock face for the
|
||||
# hours or minutes...
|
||||
def DrawFace(self):
|
||||
# Draw hours hand shadow
|
||||
mStep = 6 * self.clockStep
|
||||
angle = hour * 30
|
||||
if angle > 360:
|
||||
angle = angle - 360
|
||||
angle = angle + round(minutes/(mStep*2)) * mStep
|
||||
|
||||
x,y,f = self._getCoords("hand_hours", angle)
|
||||
|
||||
if f and self.clockStyle & SHOW_SHADOWS:
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handHoursThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
|
||||
# Draw minutes hand shadow
|
||||
angle = minutes * 6
|
||||
x,y,f = self._getCoords("hand_minutes", angle)
|
||||
|
||||
if f and self.clockStyle & SHOW_SHADOWS:
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handMinutesThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
|
||||
# Draw seconds hand shadow if required
|
||||
if seconds >= 0:
|
||||
angle = seconds * 6
|
||||
x,y,f = self._getCoords("hand_seconds", angle)
|
||||
|
||||
if f and self.clockStyle & SHOW_SHADOWS:
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handSecondsThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
|
||||
|
||||
# Draw hours hand
|
||||
angle = hour * 30
|
||||
if angle > 360:
|
||||
angle = angle - 360
|
||||
angle = angle + round(minutes/(mStep*2)) * mStep
|
||||
|
||||
x,y,f = self._getCoords("hand_hours", angle)
|
||||
|
||||
if f:
|
||||
drawDC.SetPen(wx.Pen(self.handHoursColour,
|
||||
int(self.handHoursThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
|
||||
# Draw minutes hand
|
||||
angle = minutes * 6
|
||||
x,y,f = self._getCoords("hand_minutes", angle)
|
||||
|
||||
if f:
|
||||
drawDC.SetPen(wx.Pen(self.handMinutesColour,
|
||||
int(self.handMinutesThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
|
||||
# Draw seconds hand if required
|
||||
if seconds >= 0:
|
||||
angle = seconds * 6
|
||||
x,y,f = self._getCoords("hand_seconds", angle)
|
||||
if f:
|
||||
drawDC.SetPen(wx.Pen(self.handSecondsColour,
|
||||
int(self.handSecondsThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
|
||||
|
||||
|
||||
def _doDrawFace(self):
|
||||
backgroundBrush = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
|
||||
drawDC = wx.MemoryDC()
|
||||
drawDC.SelectObject(self.faceBitmap)
|
||||
drawDC.SetBackground(backgroundBrush)
|
||||
drawDC.Clear()
|
||||
|
||||
W,H = self.faceBitmap.GetWidth(), self.faceBitmap.GetHeight()
|
||||
centerX = W / 2
|
||||
centerY = H / 2
|
||||
self.handHoursLength = 0.65 * (self.radius_watch - self._getMarkMaxSize("ticks_hours", drawDC))
|
||||
self.handMinutesLength = 0.85 * (self.radius_watch - self._getMarkMaxSize("ticks_hours", drawDC))
|
||||
self.handSecondsLength = 0.85 * (self.radius_watch - self._getMarkMaxSize("ticks_hours", drawDC))
|
||||
|
||||
self.radius_ticks_hours = self.radius_watch - self.shadowDistance - self._getMarkMaxSize("ticks_hours", drawDC)
|
||||
self.radius_ticks_minutes = self.radius_ticks_hours
|
||||
|
||||
self._calcSteps()
|
||||
|
||||
# Draw the watch...
|
||||
self._drawWatch(drawDC)
|
||||
|
||||
# Draw the marks for hours and minutes...
|
||||
self.DrawTimeMarks(drawDC, self.minuteMarks, centerX, centerY, 4)
|
||||
self.DrawTimeMarks(drawDC, self.hourMarks, centerX, centerY, 9)
|
||||
circle = 360
|
||||
mStep = 6 * self.clockStep
|
||||
|
||||
if self.clockStyle & SHOW_SHADOWS:
|
||||
for i in range(0, circle, mStep):
|
||||
for t in self.coords.keys():
|
||||
if t.find("ticks") > -1:
|
||||
x,y,f = self._getCoords(t, i)
|
||||
if f:
|
||||
self._doDrawTickMark(i, drawDC, t,
|
||||
x + self.shadowDistance,
|
||||
y + self.shadowDistance,
|
||||
True)
|
||||
|
||||
for i in range(0, circle, mStep):
|
||||
for t in self.coords.keys():
|
||||
if t.find("ticks") > -1:
|
||||
x,y,f = self._getCoords(t, i)
|
||||
if f:
|
||||
self._doDrawTickMark(i, drawDC, t, x, y)
|
||||
|
||||
|
||||
def DrawTimeMarks(self, drawDC, markCount, centerX, centerY, markSize):
|
||||
for i in range(markCount):
|
||||
x, y = self.point(i + 1, markCount, min(centerX,centerY) - 16)
|
||||
scaledX = x + centerX - markSize/2
|
||||
scaledY = centerY - y - markSize/2
|
||||
|
||||
drawDC.SetBrush(wx.Brush(self.tickMarksBrushC, wx.SOLID))
|
||||
drawDC.SetPen(wx.Pen(self.tickMarksPenC, 1, wx.SOLID))
|
||||
def _doDrawTickMark(self, angle, drawDC, tipo, x, y, is_a_shadow=None):
|
||||
opts = {"ticks_hours": [self.tickMarkHoursPen, self.tickMarkHoursBrush, self.markSizeHour, self.tickMarkHoursStyle],
|
||||
"ticks_quarters": [self.tickMarkHoursPen, self.tickMarkHoursBrush, self.markSizeHour, self.tickMarkHoursStyle],
|
||||
"ticks_minutes": [self.tickMarkMinutesPen, self.tickMarkMinutesBrush, self.markSizeMin, self.tickMarkMinutesStyle]}
|
||||
|
||||
if self.tickMarkStyle != self.TICKS_NONE:
|
||||
if self.tickMarkStyle == self.TICKS_CIRCLE:
|
||||
drawDC.DrawEllipse((scaledX - 2, scaledY), (markSize, markSize))
|
||||
pen, brush, size, style = opts[tipo];
|
||||
size = size * self.scale
|
||||
|
||||
if is_a_shadow:
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour, 1, wx.SOLID))
|
||||
drawDC.SetBrush(wx.Brush(self.shadowBrushColour, wx.SOLID))
|
||||
drawDC.SetTextForeground(self.shadowBrushColour)
|
||||
else:
|
||||
drawDC.DrawRectangle((scaledX - 3, scaledY), (markSize, markSize))
|
||||
drawDC.SetPen(pen)
|
||||
drawDC.SetBrush(brush)
|
||||
drawDC.SetTextForeground(brush.GetColour())
|
||||
|
||||
if style & TICKS_CIRCLE:
|
||||
x, y = self._center2corner(x, y, tipo)
|
||||
drawDC.DrawEllipse((x, y), (int(size), int(size)))
|
||||
|
||||
elif style & TICKS_SQUARE:
|
||||
x, y = self._center2corner(x, y, tipo)
|
||||
drawDC.DrawRectangle((x, y), (int(size), int(size)))
|
||||
|
||||
elif (style & TICKS_DECIMAL) or (style & TICKS_ROMAN):
|
||||
self._draw_rotate_text(drawDC, x, y, tipo, angle)
|
||||
|
||||
elif style & TICKS_POLY:
|
||||
self._draw_rotate_polygon(drawDC, x, y, tipo, angle)
|
||||
|
||||
|
||||
def point(self, tick, range, radius):
|
||||
angle = tick * (360.0 / range)
|
||||
def _draw_rotate_text(self, drawDC, x, y, tipo, angle):
|
||||
text = self._build_text(angle, tipo)
|
||||
lX, lY = self._center2corner(x, y, tipo, drawDC)
|
||||
lX = lX * len(text)
|
||||
angle = 360 - angle
|
||||
|
||||
if self.clockStyle & ROTATE_TICKS:
|
||||
radiansPerDegree = math.pi / 180
|
||||
pointX = int(round(radius * math.sin(angle * radiansPerDegree)))
|
||||
pointY = int(round(radius * math.cos(angle * radiansPerDegree)))
|
||||
return wx.Point(pointX, pointY)
|
||||
x = int(x -
|
||||
((math.cos((angle) * radiansPerDegree)*lX) +
|
||||
(math.sin((angle) * radiansPerDegree)*lY)))
|
||||
y = int(y -
|
||||
((math.cos((angle) * radiansPerDegree)*lY) -
|
||||
(math.sin((angle) * radiansPerDegree)*lX)))
|
||||
drawDC.DrawRotatedText(text, (x,y), angle)
|
||||
|
||||
else:
|
||||
x = x - lX
|
||||
y = y - lY
|
||||
drawDC.DrawText(text, (x, y))
|
||||
|
||||
|
||||
def _draw_rotate_polygon(self, drawDC, x, y, tipo, angle):
|
||||
if tipo=="ticks_quarters":
|
||||
tipo="ticks_hours"
|
||||
|
||||
# Add to empty list to prevent system-wide hard freezes under XP...
|
||||
points = {"ticks_hours":self.tickShapeHours+[], "ticks_minutes":self.tickShapeMinutes+[]}[tipo]
|
||||
size = self.scale * {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}[tipo]
|
||||
|
||||
maxX = max(map(lambda x:x[0],points))
|
||||
minX = min(map(lambda x:x[0],points))
|
||||
maxY = max(map(lambda x:x[0],points))
|
||||
minY = min(map(lambda x:x[0],points))
|
||||
|
||||
maxB = abs(max(maxX, maxY));
|
||||
f = size / maxB
|
||||
|
||||
orgX = (maxX - minX) / 2.
|
||||
orgY = (maxY - minY) / 2.
|
||||
|
||||
radiansPerDegree = math.pi / 180
|
||||
scaledX = x
|
||||
scaledY = y
|
||||
|
||||
for z in range(0, len(points)):
|
||||
x,y = points[z]
|
||||
x = x * f - orgX * f
|
||||
y = y * f - orgY * f
|
||||
if self.clockStyle & ROTATE_TICKS:
|
||||
m,t = self._rect2pol(x,y)
|
||||
t = t + angle
|
||||
x,y = self._pol2rect(m,t)
|
||||
x = x + scaledX
|
||||
y = y + scaledY
|
||||
points[z] = [int(x), int(y)]
|
||||
|
||||
drawDC.DrawPolygon(points)
|
||||
|
||||
|
||||
def _pol2rect(self, r, w, deg=1): # radian if deg=0; degree if deg=1
|
||||
if deg:
|
||||
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
|
||||
if deg:
|
||||
return math.hypot(x, y), 180.0 * math.atan2(y, x) / math.pi
|
||||
else:
|
||||
return math.hypot(x, y), math.atan2(y, x)
|
||||
|
||||
|
||||
def _center2corner(self, x, y, tipo, drawDC=None):
|
||||
if tipo == "ticks_quarters":
|
||||
tipo = "ticks_hours"
|
||||
|
||||
style = {"ticks_hours":self.tickMarkHoursStyle, "ticks_minutes":self.tickMarkMinutesStyle}[tipo]
|
||||
size = self.scale * {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}[tipo]
|
||||
|
||||
if style & TICKS_DECIMAL or style & TICKS_ROMAN:
|
||||
font = {"ticks_hours":self.tickMarkHoursFont, "ticks_minutes":self.tickMarkMinutesFont}[tipo]
|
||||
font.SetPointSize(int(size));
|
||||
drawDC.SetFont(font)
|
||||
lX = drawDC.GetCharWidth() / 2.
|
||||
lY = drawDC.GetCharHeight() / 2.
|
||||
x = lX
|
||||
y = lY
|
||||
else:
|
||||
size = self.scale * {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}[tipo]
|
||||
x=x-size/2.;y=y-size/2.
|
||||
return x, y
|
||||
|
||||
|
||||
def _build_text(self, angle, tipo):
|
||||
if tipo == "ticks_quarters":
|
||||
tipo = "ticks_hours"
|
||||
a = angle
|
||||
if a <= 0:
|
||||
a = a + 360
|
||||
divider = {"ticks_hours":30,"ticks_minutes":6}[tipo]
|
||||
a = int(a / divider)
|
||||
|
||||
style = {"ticks_hours":self.tickMarkHoursStyle," ticks_minutes":self.tickMarkMinutesStyle}[tipo]
|
||||
if style & TICKS_ROMAN:
|
||||
text=["I","II","III","IV","V","VI","VII","VIII","IX","X", \
|
||||
"XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX", \
|
||||
"XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX", \
|
||||
"XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL", \
|
||||
"XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L", \
|
||||
"LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"][a-1]
|
||||
else:
|
||||
text = "%s" % a
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def _getMarkMaxSize(self, tipo, drawDC=None):
|
||||
if tipo == "ticks_quarters":
|
||||
tipo = "ticks_hours"
|
||||
|
||||
style = {"ticks_hours":self.tickMarkHoursStyle, "ticks_minutes":self.tickMarkMinutesStyle}[tipo]
|
||||
size = self.scale * {"ticks_hours":self.markSizeHour, "ticks_minutes":self.markSizeMin}[tipo]
|
||||
|
||||
if style & TICKS_DECIMAL or style & TICKS_ROMAN:
|
||||
lX = 2 * drawDC.GetCharWidth()
|
||||
lY = drawDC.GetCharHeight()
|
||||
size = math.sqrt(lX**2 + lY**2) * self.scale
|
||||
else:
|
||||
size=math.sqrt(2) * size
|
||||
|
||||
return size
|
||||
|
||||
|
||||
def _drawWatch(self, drawDC):
|
||||
# Draw the watch...
|
||||
if self.watchPen or self.watchBrush:
|
||||
if self.watchPen:
|
||||
drawDC.SetPen(self.watchPen)
|
||||
if self.watchBrush:
|
||||
drawDC.SetBrush(self.watchBrush)
|
||||
else:
|
||||
drawDC.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
|
||||
drawDC.DrawCircle((self.centerX, self.centerY), self.radius_watch)
|
||||
|
||||
|
||||
def _calcSteps(self):
|
||||
# Calcule todos os pontos para:
|
||||
# - marcas de horas
|
||||
# - marcas de minutos
|
||||
# - ponteiro de horas
|
||||
# - ponteiro de minutos
|
||||
# - ponteiro de segundos
|
||||
|
||||
circle = 360
|
||||
mStep = 6 * self.clockStep # Step in degrees...
|
||||
|
||||
vq = 90 * (self.clockStyle & SHOW_QUARTERS_TICKS) / SHOW_QUARTERS_TICKS
|
||||
vh = 30 * (self.clockStyle & SHOW_HOURS_TICKS) / SHOW_HOURS_TICKS
|
||||
vm = 1 * (self.clockStyle & SHOW_MINUTES_TICKS) / SHOW_MINUTES_TICKS
|
||||
|
||||
coords = {"ticks_quarters": [self.radius_ticks_hours, 60,vq,{}],
|
||||
"ticks_hours": [self.radius_ticks_hours, 60,vh,{}],
|
||||
"ticks_minutes": [self.radius_ticks_minutes,60,vm,{}],
|
||||
"hand_hours": [self.handHoursLength, 60,1, {}],
|
||||
"hand_minutes": [self.handMinutesLength, 60,1, {}],
|
||||
"hand_seconds": [self.handSecondsLength, 60,1, {}]}
|
||||
|
||||
radiansPerDegree = math.pi / 180
|
||||
|
||||
for t in coords.keys():
|
||||
for i in range(0, circle+mStep, mStep):
|
||||
radius = coords[t][0]
|
||||
if t == "ticks_minutes":
|
||||
radius = radius - self.offM
|
||||
step_angle = 360. / coords[t][1]
|
||||
pre = coords[t][2]
|
||||
x = self.centerX + radius * math.sin(i * radiansPerDegree)
|
||||
y = self.centerY + radius * math.cos(i * radiansPerDegree)
|
||||
f = (pre and (i/step_angle == int(i/step_angle)) and (float(i)/pre == int(i/pre)))
|
||||
coords[t][3][i] = [x,y,f]
|
||||
|
||||
if not self.clockStyle & OVERLAP_TICKS:
|
||||
for i in range(0, circle + mStep, mStep):
|
||||
f=coords["ticks_minutes"][3][i][2]
|
||||
if f and \
|
||||
(coords["ticks_hours"][3].get(i,[0,0,0])[2] or coords["ticks_quarters"][3].get(i,[0,0,0])[2]):
|
||||
f=False
|
||||
coords["ticks_minutes"][3][i][2]=f
|
||||
|
||||
self.coords=coords
|
||||
|
||||
|
||||
def _getCoords(self, tipo, angle):
|
||||
# Returns coords and 'use flag' based on current angle...
|
||||
k = 360 - (angle + 180)
|
||||
if k <= 0:
|
||||
k = k + 360
|
||||
return self.coords[tipo][3][k]
|
||||
|
||||
|
||||
# -----------------------------------------------------
|
||||
#
|
||||
def SetTickShapes(self, tsh, tsm=None):
|
||||
"""
|
||||
tsh, tsm: [[x0,y0], [x1,y1], ... [xn,yn]]
|
||||
|
||||
Sets lists of lists of points to be used as polygon shapes
|
||||
when using the TICKS_POLY style. If tsm is ommitted,
|
||||
we'll use tsh for both shapes.
|
||||
"""
|
||||
|
||||
if not tsm:
|
||||
tsm=tsh
|
||||
|
||||
self.tickShapeHours = tsh
|
||||
self.tickShapeMinutes = tsm
|
||||
|
||||
|
||||
def SetHandWeights(self, h=None, m=None, s=None):
|
||||
"""
|
||||
h, m, s: value
|
||||
|
||||
Sets thickness of hands.
|
||||
"""
|
||||
|
||||
if h:
|
||||
self.handHoursThickness = h
|
||||
if m:
|
||||
self.handMinutesThickness = m
|
||||
if s:
|
||||
self.handSecondsThickness = s
|
||||
|
||||
|
||||
def SetHandColours(self, h=None, m=None, s=None):
|
||||
"""
|
||||
h, m, s: wx.Colour
|
||||
|
||||
Sets colours of hands. If m and s are ommitted,
|
||||
we'll use h for all.
|
||||
"""
|
||||
|
||||
if h and not m and not s:
|
||||
m=h
|
||||
s=h
|
||||
|
||||
if h:
|
||||
self.handHoursColour = h
|
||||
if m:
|
||||
self.handMinutesColour = m
|
||||
if s:
|
||||
self.handSecondsColour = s
|
||||
|
||||
|
||||
def SetTickColours(self, h=None, m=None):
|
||||
"""
|
||||
h, m: wx.Colour
|
||||
|
||||
Sets colours of ticks. If m is ommitted,
|
||||
we'll use h for both.
|
||||
"""
|
||||
|
||||
if not m:
|
||||
m=h
|
||||
|
||||
if h:
|
||||
self.tickMarkHoursPen = wx.Pen(h, 1, wx.SOLID)
|
||||
self.tickMarkHoursBrush = wx.Brush(h, wx.SOLID)
|
||||
|
||||
if m:
|
||||
self.tickMarkMinutesPen = wx.Pen(m, 1, wx.SOLID)
|
||||
self.tickMarkMinutesBrush = wx.Brush(m, wx.SOLID)
|
||||
|
||||
|
||||
def SetTickSizes(self, h=None, m=None):
|
||||
"""
|
||||
h, m: value
|
||||
|
||||
Sizes for tick marks.
|
||||
"""
|
||||
|
||||
if h:
|
||||
self.markSizeHour = h
|
||||
if m:
|
||||
self.markSizeMin = m
|
||||
|
||||
|
||||
def SetTickFonts(self, h=None, m=None):
|
||||
"""
|
||||
h, m: wx.Font
|
||||
|
||||
Fonts for tick marks when using TICKS_DECIMAL or TICKS_ROMAN style.
|
||||
If m is ommitted, we'll use h for both.
|
||||
"""
|
||||
|
||||
if not m:
|
||||
m=h
|
||||
|
||||
if h:
|
||||
self.tickMarkHoursFont = h
|
||||
self.tickMarkHoursFont.SetPointSize(self.markSizeHour)
|
||||
if m:
|
||||
self.tickMarkMinutesFont = m
|
||||
self.tickMarkMinutesFont.SetPointSize(self.markSizeMin)
|
||||
|
||||
|
||||
def SetMinutesOffset(self, o):
|
||||
"""
|
||||
s = value
|
||||
|
||||
Sets the distance between tick marks for hours and minutes.
|
||||
"""
|
||||
self.offM = o
|
||||
|
||||
|
||||
def SetShadowColour(self, s):
|
||||
"""
|
||||
s = wx.Colour or (r,g,b) tuple.
|
||||
|
||||
Sets the colour to be used to draw shadows.
|
||||
"""
|
||||
|
||||
self.shadowPenColour = self.shadowBrushColour = s
|
||||
|
||||
|
||||
def SetWatchPenBrush(self, p=None, b=None):
|
||||
"""
|
||||
p = wx.Pen; b = wx.Brush
|
||||
|
||||
Set the pen and brush for the watch.
|
||||
"""
|
||||
|
||||
if p:
|
||||
self.watchPen = p
|
||||
if b:
|
||||
self.watchBrush = b
|
||||
|
||||
|
||||
def SetClockStyle(self, style):
|
||||
"""
|
||||
Set the clock style, acording to the 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_HOURS_HAND - Show hours hand
|
||||
SHOW_MINUTES_HAND - Show minutes hand
|
||||
SHOW_SECONDS_HAND - Show seconds hand
|
||||
|
||||
SHOW_SHADOWS - Show hands and marks shadows
|
||||
|
||||
ROTATE_TICKS - Align tick marks to watch
|
||||
OVERLAP_TICKS - Draw tick marks for minutes even
|
||||
when they match the hours marks.
|
||||
"""
|
||||
|
||||
self.clockStyle = style
|
||||
|
||||
|
||||
def SetTickStyles(self, h=None, m=None):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
if h:
|
||||
self.tickMarkHoursStyle = h
|
||||
if m:
|
||||
self.tickMarkMinutesStyle = m
|
||||
#
|
||||
# -----------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print wx.VERSION_STRING
|
||||
class App(wx.App):
|
||||
def OnInit(self):
|
||||
frame = wx.Frame(None, -1, "AnalogClockWindow Test", size=(375,375))
|
||||
frame = wx.Frame(None, -1, "AnalogClockWindow", size=(375,375))
|
||||
|
||||
clock = AnalogClockWindow(frame)
|
||||
clock.SetTickMarkColours("RED")
|
||||
clock.SetHandsColour("WHITE")
|
||||
clock.SetBackgroundColour("BLUE")
|
||||
|
||||
# Settings below are used by default...
|
||||
#clock.SetClockStyle(SHOW_HOURS_TICKS|SHOW_MINUTES_TICKS|SHOW_SHADOWS|ROTATE_TICKS)
|
||||
#clock.SetTickStyles(TICKS_POLY, TICKS_CIRCLE)
|
||||
|
||||
frame.Centre(wx.BOTH)
|
||||
frame.Show(True)
|
||||
@ -206,4 +785,6 @@ if __name__ == "__main__":
|
||||
theApp.MainLoop()
|
||||
|
||||
|
||||
|
||||
#
|
||||
##
|
||||
### eof
|
||||
|
501
wxPython/wx/lib/analogclockopts.py
Normal file
501
wxPython/wx/lib/analogclockopts.py
Normal file
@ -0,0 +1,501 @@
|
||||
#----------------------------------------------------------------------
|
||||
# Name: wxPython.lib.YAanalogclockOpts
|
||||
# Purpose: An analog clock window - setup frame
|
||||
#
|
||||
# Author: E. A. Tacao
|
||||
#
|
||||
# Created: 15-February-2004
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# generated by wxGlade 0.3.1 on Wed Feb 18 00:05:35 2004
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.dialogs import wxMultipleChoiceDialog
|
||||
from wxPython.lib.colourselect import ColourSelect, wxEVT_COMMAND_COLOURSELECT
|
||||
import string
|
||||
|
||||
class ACCustomizationFrame(wxFrame):
|
||||
def __init__(self, parent, id, name, pos=wxDefaultPosition, size=wxDefaultSize,
|
||||
style=wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT | wxWANTS_CHARS):
|
||||
k=wxNewId();ide=map(lambda x: x+k, range(0,100))
|
||||
# begin wxGlade: ACCustomizationFrame.__init__
|
||||
#kwds["style"] = wxCAPTION|wxSYSTEM_MENU
|
||||
#wxFrame.__init__(self, *args, **kwds)
|
||||
wxFrame.__init__(self, parent, id, name, pos, size, style)
|
||||
self.parent=parent
|
||||
self.panel_1 = wxPanel(self, -1)
|
||||
self.notebook_1 = wxNotebook(self.panel_1, -1, style=0)
|
||||
self.notebook_1_pane_3 = wxPanel(self.notebook_1, -1)
|
||||
self.notebook_1_pane_2 = wxPanel(self.notebook_1, -1)
|
||||
self.notebook_1_pane_1 = wxPanel(self.notebook_1, -1)
|
||||
self.label_top = wxStaticText(self.panel_1, -1, "Use the options below to change the clock;\nthe main buttons on top of each category reset to its defaults.")
|
||||
self.static_line_1 = wxStaticLine(self.panel_1, -1)
|
||||
self.button_1 = wxButton(self.notebook_1_pane_1, ide[1], "SetClockStyle")
|
||||
self.static_line_2 = wxStaticLine(self.notebook_1_pane_1, -1)
|
||||
self.button_2 = wxButton(self.notebook_1_pane_1, ide[3], "styles...")
|
||||
self.static_line_3 = wxStaticLine(self.notebook_1_pane_1, -1, style=wxLI_VERTICAL)
|
||||
self.button_3 = wxButton(self.notebook_1_pane_1, ide[2], "SetTickStyles")
|
||||
self.static_line_4 = wxStaticLine(self.notebook_1_pane_1, -1)
|
||||
self.button_4 = wxButton(self.notebook_1_pane_1, ide[4], "styles...")
|
||||
self.button_22 = wxButton(self.notebook_1_pane_1, ide[22], "minutes...")
|
||||
self.static_line_5 = wxStaticLine(self.notebook_1_pane_1, -1)
|
||||
self.button_5 = wxButton(self.notebook_1_pane_1, ide[5], "SetShadowColour")
|
||||
self.static_line_6 = wxStaticLine(self.notebook_1_pane_1, -1)
|
||||
self.button_6 = ColourSelect(self.notebook_1_pane_1, ide[6], "all...")
|
||||
self.static_line_7 = wxStaticLine(self.notebook_1_pane_1, -1, style=wxLI_VERTICAL)
|
||||
self.button_7 = wxButton(self.notebook_1_pane_1, ide[7], "SetWatchPenBrush")
|
||||
self.static_line_8 = wxStaticLine(self.notebook_1_pane_1, -1)
|
||||
self.button_8 = ColourSelect(self.notebook_1_pane_1, ide[8], "Pen colour...")
|
||||
self.button_9 = ColourSelect(self.notebook_1_pane_1, ide[9], "Brush colour...")
|
||||
self.button_10 = wxButton(self.notebook_1_pane_2, ide[10], "SetTickColours")
|
||||
self.static_line_8 = wxStaticLine(self.notebook_1_pane_2, -1)
|
||||
self.button_11 = ColourSelect(self.notebook_1_pane_2, ide[11], "hours...", colour=self.parent.tickMarkHoursPen.GetColour())
|
||||
self.button_12 = ColourSelect(self.notebook_1_pane_2, ide[12], "minutes...", colour=self.parent.tickMarkMinutesPen.GetColour())
|
||||
self.static_line_10 = wxStaticLine(self.notebook_1_pane_2, -1, style=wxLI_VERTICAL)
|
||||
self.button_13 = wxButton(self.notebook_1_pane_2, ide[13], "SetTickSizes")
|
||||
self.static_line_11 = wxStaticLine(self.notebook_1_pane_2, -1)
|
||||
self.label_1 = wxStaticText(self.notebook_1_pane_2, -1, "hours")
|
||||
self.spin_ctrl_1 = wxSpinCtrl(self.notebook_1_pane_2, ide[71], "10", min=1, max=100)
|
||||
self.label_2 = wxStaticText(self.notebook_1_pane_2, -1, "minutes")
|
||||
self.spin_ctrl_2 = wxSpinCtrl(self.notebook_1_pane_2, ide[72], "5", min=0, max=100)
|
||||
self.label_3 = wxStaticText(self.notebook_1_pane_2, -1, "offset")
|
||||
self.spin_ctrl_3 = wxSpinCtrl(self.notebook_1_pane_2, ide[73], "0", min=0, max=100)
|
||||
self.static_line_12 = wxStaticLine(self.notebook_1_pane_2, -1, style=wxLI_VERTICAL)
|
||||
self.button_14 = wxButton(self.notebook_1_pane_2, ide[14], "SetTickFonts")
|
||||
self.static_line_13 = wxStaticLine(self.notebook_1_pane_2, -1)
|
||||
self.button_15 = wxButton(self.notebook_1_pane_2, ide[15], "hours...")
|
||||
self.button_16 = wxButton(self.notebook_1_pane_2, ide[16], "minutes...")
|
||||
self.button_17 = wxButton(self.notebook_1_pane_3, ide[17], "SetHandWeights")
|
||||
self.static_line_14 = wxStaticLine(self.notebook_1_pane_3, -1)
|
||||
self.label_4 = wxStaticText(self.notebook_1_pane_3, -1, "hours")
|
||||
self.spin_ctrl_4 = wxSpinCtrl(self.notebook_1_pane_3, ide[74], "5", min=0, max=100)
|
||||
self.label_5 = wxStaticText(self.notebook_1_pane_3, -1, "minutes")
|
||||
self.spin_ctrl_5 = wxSpinCtrl(self.notebook_1_pane_3, ide[75], "3", min=0, max=100)
|
||||
self.label_6 = wxStaticText(self.notebook_1_pane_3, -1, "seconds")
|
||||
self.spin_ctrl_6 = wxSpinCtrl(self.notebook_1_pane_3, ide[76], "1", min=0, max=100)
|
||||
self.static_line_15 = wxStaticLine(self.notebook_1_pane_3, -1, style=wxLI_VERTICAL)
|
||||
self.button_18 = wxButton(self.notebook_1_pane_3, ide[18], "SetHandColours")
|
||||
self.static_line_16 = wxStaticLine(self.notebook_1_pane_3, -1)
|
||||
self.button_19 = ColourSelect(self.notebook_1_pane_3, ide[19], "hours...")
|
||||
self.button_20 = ColourSelect(self.notebook_1_pane_3, ide[20], "minutes...")
|
||||
self.button_21 = ColourSelect(self.notebook_1_pane_3, ide[21], "seconds...")
|
||||
|
||||
self.__set_properties()
|
||||
self.__do_layout()
|
||||
# end wxGlade
|
||||
|
||||
EVT_COMMAND_RANGE(self, ide[0], ide[29],
|
||||
wxEVT_COMMAND_BUTTON_CLICKED, self.OnEventsHook)
|
||||
EVT_COMMAND_RANGE(self, ide[0], ide[29],
|
||||
wxEVT_COMMAND_COLOURSELECT, self.OnEventsHook)
|
||||
EVT_COMMAND_RANGE(self, ide[71], ide[80],
|
||||
wxEVT_COMMAND_SPINCTRL_UPDATED, self.OnEventsHook)
|
||||
EVT_COMMAND_RANGE(self, ide[51], ide[60],
|
||||
wxEVT_COMMAND_RADIOBUTTON_SELECTED, self.OnEventsHook)
|
||||
EVT_WINDOW_DESTROY(self, self.OnQuit)
|
||||
|
||||
self.ide=ide
|
||||
|
||||
def __set_properties(self):
|
||||
# begin wxGlade: ACCustomizationFrame.__set_properties
|
||||
#self.SetTitle("AnalogClock Test")
|
||||
self.spin_ctrl_1.SetSize((50, -1))
|
||||
self.spin_ctrl_2.SetSize((50, -1))
|
||||
self.spin_ctrl_3.SetSize((50, -1))
|
||||
self.spin_ctrl_4.SetSize((50, -1))
|
||||
self.spin_ctrl_5.SetSize((50, -1))
|
||||
self.spin_ctrl_6.SetSize((50, -1))
|
||||
# end wxGlade
|
||||
|
||||
def __do_layout(self):
|
||||
# begin wxGlade: ACCustomizationFrame.__do_layout
|
||||
sizer_frame = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_main = wxBoxSizer(wxVERTICAL)
|
||||
sizer_25 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_26 = wxStaticBoxSizer(wxStaticBox(self.notebook_1_pane_3, -1, ""), wxVERTICAL)
|
||||
sizer_27 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_31 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_33 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_32 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_28 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_30 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_29 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_12 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_13 = wxStaticBoxSizer(wxStaticBox(self.notebook_1_pane_2, -1, ""), wxVERTICAL)
|
||||
sizer_14 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_22 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_24 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_23 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_18 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_21 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_20 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_19 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_15 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_17 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_16 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_1 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_2 = wxStaticBoxSizer(wxStaticBox(self.notebook_1_pane_1, -1, ""), wxVERTICAL)
|
||||
sizer_8 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_11 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_12b = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_9 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_10 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_3 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_6 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_7 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_4 = wxBoxSizer(wxVERTICAL)
|
||||
sizer_5 = wxBoxSizer(wxHORIZONTAL)
|
||||
sizer_main.Add(self.label_top, 0, wxLEFT|wxTOP, 5)
|
||||
sizer_main.Add(self.static_line_1, 0, wxTOP|wxBOTTOM|wxEXPAND, 10)
|
||||
sizer_4.Add(self.button_1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_4.Add(self.static_line_2, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_5.Add(self.button_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_4.Add(sizer_5, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_3.Add(sizer_4, 1, wxEXPAND, 0)
|
||||
sizer_3.Add(self.static_line_3, 0, wxEXPAND, 0)
|
||||
sizer_6.Add(self.button_3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_6.Add(self.static_line_4, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_7.Add(self.button_4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_7.Add(self.button_22, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_6.Add(sizer_7, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_3.Add(sizer_6, 1, wxEXPAND, 0)
|
||||
sizer_2.Add(sizer_3, 1, wxEXPAND, 0)
|
||||
sizer_2.Add(self.static_line_5, 0, wxEXPAND, 0)
|
||||
sizer_9.Add(self.button_5, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_9.Add(self.static_line_6, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_10.Add(self.button_6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_9.Add(sizer_10, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_8.Add(sizer_9, 1, wxEXPAND, 0)
|
||||
sizer_8.Add(self.static_line_7, 0, wxEXPAND, 0)
|
||||
sizer_11.Add(self.button_7, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_11.Add(self.static_line_8, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_12b.Add(self.button_8, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_12b.Add(self.button_9, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_11.Add(sizer_12b, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_8.Add(sizer_11, 1, wxEXPAND, 0)
|
||||
sizer_2.Add(sizer_8, 1, wxEXPAND, 0)
|
||||
sizer_1.Add(sizer_2, 1, wxEXPAND, 0)
|
||||
self.notebook_1_pane_1.SetAutoLayout(1)
|
||||
self.notebook_1_pane_1.SetSizer(sizer_1)
|
||||
sizer_1.Fit(self.notebook_1_pane_1)
|
||||
sizer_1.SetSizeHints(self.notebook_1_pane_1)
|
||||
sizer_15.Add(self.button_10, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_15.Add(self.static_line_8, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_16.Add(self.button_11, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_15.Add(sizer_16, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_17.Add(self.button_12, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_15.Add(sizer_17, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_14.Add(sizer_15, 1, wxEXPAND, 0)
|
||||
sizer_14.Add(self.static_line_10, 0, wxEXPAND, 0)
|
||||
sizer_18.Add(self.button_13, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_18.Add(self.static_line_11, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_19.Add(self.label_1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_19.Add(self.spin_ctrl_1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_18.Add(sizer_19, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_20.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_20.Add(self.spin_ctrl_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_18.Add(sizer_20, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_21.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_21.Add(self.spin_ctrl_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_18.Add(sizer_21, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_14.Add(sizer_18, 1, wxEXPAND, 0)
|
||||
sizer_14.Add(self.static_line_12, 0, wxEXPAND, 0)
|
||||
sizer_22.Add(self.button_14, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_22.Add(self.static_line_13, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_23.Add(self.button_15, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_22.Add(sizer_23, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_24.Add(self.button_16, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_22.Add(sizer_24, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_14.Add(sizer_22, 1, wxEXPAND, 0)
|
||||
sizer_13.Add(sizer_14, 1, wxEXPAND, 0)
|
||||
sizer_12.Add(sizer_13, 1, wxEXPAND, 0)
|
||||
self.notebook_1_pane_2.SetAutoLayout(1)
|
||||
self.notebook_1_pane_2.SetSizer(sizer_12)
|
||||
sizer_12.Fit(self.notebook_1_pane_2)
|
||||
sizer_12.SetSizeHints(self.notebook_1_pane_2)
|
||||
sizer_28.Add(self.button_17, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_28.Add(self.static_line_14, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_29.Add(self.label_4, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_29.Add(self.spin_ctrl_4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_29.Add(self.label_5, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_29.Add(self.spin_ctrl_5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_28.Add(sizer_29, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_30.Add(self.label_6, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_30.Add(self.spin_ctrl_6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_28.Add(sizer_30, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_27.Add(sizer_28, 1, wxEXPAND, 0)
|
||||
sizer_27.Add(self.static_line_15, 0, wxEXPAND, 0)
|
||||
sizer_31.Add(self.button_18, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_31.Add(self.static_line_16, 0, wxLEFT|wxRIGHT|wxEXPAND, 20)
|
||||
sizer_32.Add(self.button_19, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_32.Add(self.button_20, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_31.Add(sizer_32, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_33.Add(self.button_21, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5)
|
||||
sizer_31.Add(sizer_33, 1, wxALIGN_CENTER_HORIZONTAL, 0)
|
||||
sizer_27.Add(sizer_31, 1, wxEXPAND, 0)
|
||||
sizer_26.Add(sizer_27, 1, wxEXPAND, 0)
|
||||
sizer_25.Add(sizer_26, 1, wxEXPAND, 0)
|
||||
self.notebook_1_pane_3.SetAutoLayout(1)
|
||||
self.notebook_1_pane_3.SetSizer(sizer_25)
|
||||
sizer_25.Fit(self.notebook_1_pane_3)
|
||||
sizer_25.SetSizeHints(self.notebook_1_pane_3)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_1, "Clock")
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_2, "Ticks")
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_3, "Hands")
|
||||
sizer_main.Add(wxNotebookSizer(self.notebook_1), 1, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5)
|
||||
self.panel_1.SetAutoLayout(1)
|
||||
self.panel_1.SetSizer(sizer_main)
|
||||
sizer_main.Fit(self.panel_1)
|
||||
sizer_main.SetSizeHints(self.panel_1)
|
||||
sizer_frame.Add(self.panel_1, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0)
|
||||
self.SetAutoLayout(1)
|
||||
self.SetSizer(sizer_frame)
|
||||
sizer_frame.Fit(self)
|
||||
sizer_frame.SetSizeHints(self)
|
||||
self.Layout()
|
||||
# end wxGlade
|
||||
|
||||
self.UpdateWidgets()
|
||||
|
||||
def UpdateAll(self):
|
||||
self.UpdateWidgets()
|
||||
self.parent.OnSize(None)
|
||||
|
||||
def UpdateWidgets(self):
|
||||
self.button_6.SetColour(self.parent.shadowPenColour)
|
||||
|
||||
bc=self.parent.watchPen
|
||||
if bc:
|
||||
bc=bc.GetColour()
|
||||
else:
|
||||
bc=self.parent.GetBackgroundColour()
|
||||
self.button_8.SetColour(bc)
|
||||
|
||||
bc=self.parent.watchBrush
|
||||
if bc:
|
||||
bc=bc.GetColour()
|
||||
else:
|
||||
bc=self.parent.GetBackgroundColour()
|
||||
self.button_9.SetColour(bc)
|
||||
|
||||
self.button_11.SetColour(self.parent.tickMarkHoursPen.GetColour())
|
||||
self.button_12.SetColour(self.parent.tickMarkMinutesPen.GetColour())
|
||||
self.button_19.SetColour(self.parent.handHoursColour)
|
||||
self.button_20.SetColour(self.parent.handMinutesColour)
|
||||
self.button_21.SetColour(self.parent.handSecondsColour)
|
||||
|
||||
self.spin_ctrl_1.SetValue(self.parent.markSizeHour)
|
||||
self.spin_ctrl_2.SetValue(self.parent.markSizeMin)
|
||||
self.spin_ctrl_3.SetValue(self.parent.offM)
|
||||
self.spin_ctrl_4.SetValue(self.parent.handHoursThickness)
|
||||
self.spin_ctrl_5.SetValue(self.parent.handMinutesThickness)
|
||||
self.spin_ctrl_6.SetValue(self.parent.handSecondsThickness)
|
||||
|
||||
|
||||
def gfid(self, id, lista):
|
||||
for x in lista:
|
||||
if id==self.ide[x]:
|
||||
f=True
|
||||
break
|
||||
else:
|
||||
f=False
|
||||
return f
|
||||
|
||||
def OnEventsHook(self, evt):
|
||||
id=evt.GetId()
|
||||
|
||||
if self.gfid(id, [6,8,9,11,12,19,20,21,23]):
|
||||
self.OnSelectColour(evt)
|
||||
|
||||
elif self.gfid(id, [15,16]):
|
||||
self.OnSelectFont(evt)
|
||||
|
||||
elif self.gfid(id, [71,72,73,74,75,76]):
|
||||
self.OnSpinChange(evt)
|
||||
|
||||
elif self.gfid(id, [3,4,22]):
|
||||
self.OnChangeStyle(evt)
|
||||
|
||||
elif self.gfid(id, [1,2,5,7,10,13,14,17,18]):
|
||||
self.OnDefaults(evt)
|
||||
|
||||
|
||||
def OnSelectColour(self, evt):
|
||||
id=evt.GetId();colour=evt.GetValue()
|
||||
|
||||
if id==self.ide[6]:
|
||||
self.parent.SetShadowColour(colour)
|
||||
elif id==self.ide[8]:
|
||||
self.parent.SetWatchPenBrush(p=wxPen(colour, 1, wxSOLID))
|
||||
elif id==self.ide[9]:
|
||||
self.parent.SetWatchPenBrush(b=wxBrush(colour, wxSOLID))
|
||||
elif id==self.ide[11]:
|
||||
self.parent.SetTickColours(h=colour)
|
||||
elif id==self.ide[12]:
|
||||
self.parent.SetTickColours(m=colour)
|
||||
elif id==self.ide[19]:
|
||||
self.parent.SetHandColours(h=colour)
|
||||
elif id==self.ide[20]:
|
||||
self.parent.SetHandColours(m=colour)
|
||||
elif id==self.ide[21]:
|
||||
self.parent.SetHandColours(s=colour)
|
||||
|
||||
|
||||
self.UpdateAll()
|
||||
|
||||
|
||||
|
||||
def OnSelectFont(self, evt):
|
||||
id=evt.GetId()
|
||||
if id==self.ide[15]:
|
||||
font=self.parent.tickMarkHoursFont;font.SetPointSize(self.parent.markSizeHour)
|
||||
colour=self.parent.tickMarkHoursPen.GetColour()
|
||||
else:
|
||||
font=self.parent.tickMarkMinutesFont;font.SetPointSize(self.parent.markSizeMin)
|
||||
colour=self.parent.tickMarkMinutesPen.GetColour()
|
||||
|
||||
data = wxFontData()
|
||||
data.EnableEffects(True)
|
||||
data.SetColour(colour)
|
||||
data.SetInitialFont(font)
|
||||
|
||||
dlg = wxFontDialog(self, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetFontData()
|
||||
font = data.GetChosenFont()
|
||||
colour = data.GetColour()
|
||||
if id==self.ide[15]:
|
||||
self.parent.SetTickFonts(h=font)
|
||||
self.parent.SetTickColours(h=colour.Get())
|
||||
else:
|
||||
self.parent.SetTickFonts(m=font)
|
||||
self.parent.SetTickColours(m=colour.Get())
|
||||
dlg.Destroy()
|
||||
|
||||
self.UpdateAll()
|
||||
|
||||
def OnSpinChange(self, evt):
|
||||
id=evt.GetId();v=evt.GetInt()
|
||||
if id==self.ide[71]:
|
||||
self.parent.SetTickSizes(h=v)
|
||||
if id==self.ide[72]:
|
||||
self.parent.SetTickSizes(m=v)
|
||||
if id==self.ide[73]:
|
||||
self.parent.SetMinutesOffset(v)
|
||||
if id==self.ide[74]:
|
||||
self.parent.SetHandWeights(h=v)
|
||||
if id==self.ide[75]:
|
||||
self.parent.SetHandWeights(m=v)
|
||||
if id==self.ide[76]:
|
||||
self.parent.SetHandWeights(s=v)
|
||||
|
||||
self.UpdateAll()
|
||||
|
||||
def OnChangeStyle(self, evt):
|
||||
id=evt.GetId()
|
||||
|
||||
if id==self.ide[3]:
|
||||
x="""SHOW_QUARTERS_TICKS
|
||||
SHOW_HOURS_TICKS
|
||||
SHOW_MINUTES_TICKS
|
||||
ROTATE_TICKS
|
||||
SHOW_HOURS_HAND
|
||||
SHOW_MINUTES_HAND
|
||||
SHOW_SECONDS_HAND
|
||||
SHOW_SHADOWS
|
||||
OVERLAP_TICKS""".split()
|
||||
m=map(lambda f: (self.parent.clockStyle & f)/f, map(lambda f: 2**x.index(f),x))
|
||||
|
||||
dlg = wxMultipleChoiceDialog(self,
|
||||
"Select some styles for the clock:",
|
||||
"Styles", x)
|
||||
for i in range(0,len(m)):
|
||||
if m[i]:
|
||||
dlg.lbox.SetSelection(i)
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK):
|
||||
v=reduce(lambda x,y:x+y,map(lambda f: 2**f,dlg.GetValue()))
|
||||
self.parent.SetClockStyle(v)
|
||||
|
||||
elif id==self.ide[4]:
|
||||
x="""TICKS_NONE
|
||||
TICKS_SQUARE
|
||||
TICKS_CIRCLE
|
||||
TICKS_POLY
|
||||
TICKS_DECIMAL
|
||||
TICKS_ROMAN""".split()
|
||||
m=map(lambda f: (self.parent.tickMarkHoursStyle & f)/f, map(lambda f: 2**x.index(f),x))
|
||||
|
||||
dlg = wxSingleChoiceDialog(self,
|
||||
"Select a style for the hours:",
|
||||
"Styles", x, wxCHOICEDLG_STYLE)
|
||||
for i in range(0,len(m)):
|
||||
if m[i]:
|
||||
dlg.SetSelection(i)
|
||||
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
v=2**dlg.GetSelection()
|
||||
self.parent.SetTickStyles(h=v)
|
||||
dlg.Destroy()
|
||||
|
||||
elif id==self.ide[22]:
|
||||
tipo="for the minutes"
|
||||
x="""TICKS_NONE
|
||||
TICKS_SQUARE
|
||||
TICKS_CIRCLE
|
||||
TICKS_POLY
|
||||
TICKS_DECIMAL
|
||||
TICKS_ROMAN""".split()
|
||||
m=map(lambda f: (self.parent.tickMarkMinutesStyle & f)/f, map(lambda f: 2**x.index(f),x))
|
||||
|
||||
dlg = wxSingleChoiceDialog(self,
|
||||
"Select a style for the minutes:",
|
||||
"Styles", x, wxCHOICEDLG_STYLE)
|
||||
for i in range(0,len(m)):
|
||||
if m[i]:
|
||||
dlg.SetSelection(i)
|
||||
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
v=2**dlg.GetSelection()
|
||||
self.parent.SetTickStyles(m=v)
|
||||
dlg.Destroy()
|
||||
|
||||
self.UpdateAll()
|
||||
|
||||
def OnDefaults(self, evt):
|
||||
id=evt.GetId()
|
||||
if id==self.ide[1]:
|
||||
self.parent.SetClockStyle(142)
|
||||
elif id==self.ide[2]:
|
||||
self.parent.SetTickStyles(8, 4)
|
||||
elif id==self.ide[5]:
|
||||
self.parent.SetShadowColour((128,128,128))
|
||||
elif id==self.ide[7]:
|
||||
colour=self.parent.GetBackgroundColour()
|
||||
self.parent.SetWatchPenBrush(p=wxPen(colour, 1, wxSOLID), b=wxBrush(colour, wxSOLID))
|
||||
elif id==self.ide[10]:
|
||||
colour=(0, 0, 0)
|
||||
self.parent.SetTickColours(h=colour, m=colour)
|
||||
elif id==self.ide[13]:
|
||||
self.parent.SetTickSizes(h=10, m=5)
|
||||
self.parent.SetMinutesOffset(0)
|
||||
elif id==self.ide[14]:
|
||||
self.parent.SetTickFonts(wxFont(1, wxSWISS, wxNORMAL, wxBOLD))
|
||||
elif id==self.ide[17]:
|
||||
self.parent.SetHandWeights(h=5, m=3, s=1)
|
||||
elif id==self.ide[18]:
|
||||
colour=(0, 0, 0)
|
||||
self.parent.SetHandColours(h=colour, m=colour, s=colour)
|
||||
|
||||
self.UpdateAll()
|
||||
|
||||
|
||||
def OnQuit(self, evt):
|
||||
self.parent.prefs_open=False
|
||||
|
||||
|
||||
#
|
||||
##
|
||||
### eof
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user