📄 setup.py
字号:
# AnalogClock setup dialog
# E. A. Tacao <e.a.tacao |at| estadao.com.br>
# http://j.domaindlx.com/elements28/wxpython/
# 15 Fev 2006, 22:00 GMT-03:00
# Distributed under the wxWidgets license.
import wx
import styles
import lib_setup.colourselect as csel
import lib_setup.fontselect as fsel
import lib_setup.buttontreectrlpanel as bt
#----------------------------------------------------------------------
_window_styles = ['wx.SIMPLE_BORDER', 'wx.DOUBLE_BORDER', 'wx.SUNKEN_BORDER',
'wx.RAISED_BORDER', 'wx.STATIC_BORDER', 'wx.NO_BORDER']
#----------------------------------------------------------------------
class _GroupBase(wx.Panel):
def __init__(self, parent, title, group):
wx.Panel.__init__(self, parent)
self.parent = parent
self.clock = self.parent.clock
self.group = group
self.target = {"Hours": styles.HOUR,
"Minutes": styles.MINUTE,
"Seconds": styles.SECOND}.get(title)
self.Bind(fsel.EVT_FONTSELECT, self.OnSelectFont)
self.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
self.Bind(wx.EVT_SPINCTRL, self.OnSpin)
self.Bind(wx.EVT_TEXT_ENTER, self.OnSpin)
self.Bind(wx.EVT_CHOICE, self.OnChoice)
def OnSelectFont(self, evt):
self.clock.SetTickFont(evt.val, self.target)
def OnSelectColour(self, evt):
obj = evt.obj; val = evt.val
if hasattr(self, "fc") and obj == self.fc:
if self.group == "Hands":
self.clock.SetHandFillColour(val, self.target)
elif self.group == "Ticks":
self.clock.SetTickFillColour(val, self.target)
elif self.group == "Face":
self.clock.SetFaceFillColour(val)
elif hasattr(self, "bc") and obj == self.bc:
if self.group == "Hands":
self.clock.SetHandBorderColour(val, self.target)
elif self.group == "Ticks":
self.clock.SetTickBorderColour(val, self.target)
elif self.group == "Face":
self.clock.SetFaceBorderColour(val)
elif hasattr(self, "sw") and obj == self.sw:
self.clock.SetShadowColour(val)
elif hasattr(self, "bg") and obj == self.bg:
self.clock.SetBackgroundColour(val)
elif hasattr(self, "fg") and obj == self.fg:
self.clock.SetForegroundColour(val)
self.parent.GetGrandParent().UpdateControls()
def OnSpin(self, evt):
obj = evt.GetEventObject(); val = evt.GetInt()
if hasattr(self, "bw") and obj == self.bw:
if self.group == "Hands":
self.clock.SetHandBorderWidth(val, self.target)
elif self.group == "Ticks":
self.clock.SetTickBorderWidth(val, self.target)
elif self.group == "Face":
self.clock.SetFaceBorderWidth(val)
elif hasattr(self, "sz") and obj == self.sz:
if self.group == "Hands":
self.clock.SetHandSize(val, self.target)
elif self.group == "Ticks":
self.clock.SetTickSize(val, self.target)
elif hasattr(self, "of") and obj == self.of:
self.clock.SetTickOffset(val, self.target)
def OnChoice(self, evt):
self.clock.SetWindowStyle(eval(evt.GetString()))
def UpdateControls(self):
if hasattr(self, "ft"):
self.ft.SetValue(self.clock.GetTickFont(self.target)[0])
if hasattr(self, "fc"):
if self.group == "Hands":
self.fc.SetValue(self.clock.GetHandFillColour(self.target)[0])
elif self.group == "Ticks":
self.fc.SetValue(self.clock.GetTickFillColour(self.target)[0])
elif self.group == "Face":
self.fc.SetValue(self.clock.GetFaceFillColour())
if hasattr(self, "bc"):
if self.group == "Hands":
self.bc.SetValue(self.clock.GetHandBorderColour(self.target)[0])
elif self.group == "Ticks":
self.bc.SetValue(self.clock.GetTickBorderColour(self.target)[0])
elif self.group == "Face":
self.bc.SetValue(self.clock.GetFaceBorderColour())
if hasattr(self, "sw"):
self.sw.SetValue(self.clock.GetShadowColour())
if hasattr(self, "bg"):
self.bg.SetValue(self.clock.GetBackgroundColour())
if hasattr(self, "fg"):
self.fg.SetValue(self.clock.GetForegroundColour())
if hasattr(self, "bw"):
if self.group == "Hands":
self.bw.SetValue(self.clock.GetHandBorderWidth(self.target)[0])
elif self.group == "Ticks":
self.bw.SetValue(self.clock.GetTickBorderWidth(self.target)[0])
elif self.group == "Face":
self.bw.SetValue(self.clock.GetFaceBorderWidth())
if hasattr(self, "sz"):
if self.group == "Hands":
self.sz.SetValue(self.clock.GetHandSize(self.target)[0])
elif self.group == "Ticks":
self.sz.SetValue(self.clock.GetTickSize(self.target)[0])
if hasattr(self, "of"):
self.of.SetValue(self.clock.GetTickOffset(self.target)[0])
if hasattr(self, "ws"):
for style in _window_styles:
if self.clock.GetWindowStyleFlag() & eval(style):
self.ws.SetStringSelection(style)
break
#----------------------------------------------------------------------
class _Group_1(_GroupBase):
def __init__(self, parent, title, group="Hands"):
_GroupBase.__init__(self, parent, title, group)
box = wx.StaticBoxSizer(wx.StaticBox(self, label=title), wx.VERTICAL)
sizer = self.sizer = wx.GridBagSizer(2, 6)
p = wx.StaticText(self, label="Border:")
sizer.Add(p, pos=(0, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.bc = csel.ColourSelect(self)
sizer.Add(p, pos=(0, 1), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.bw = wx.SpinCtrl(self, size=(75, 21),
min=0, max=100, value="75")
sizer.Add(p, pos=(0, 2), span=(1, 2), flag=wx.ALIGN_CENTRE_VERTICAL)
p = wx.StaticText(self, label="Fill:")
sizer.Add(p, pos=(1, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.fc = csel.ColourSelect(self)
sizer.Add(p, pos=(1, 1), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.ls = wx.StaticText(self, label="Size:")
sizer.Add(p, pos=(2, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.sz = wx.SpinCtrl(self, size=(75, 21),
min=0, max=100, value="75")
sizer.Add(p, pos=(2, 1), span=(1, 3), flag=wx.ALIGN_CENTRE_VERTICAL)
box.Add(sizer)
self.SetSizer(box)
#----------------------------------------------------------------------
class _Group_2(_Group_1):
def __init__(self, parent, title, group="Ticks"):
_Group_1.__init__(self, parent, title, group)
sizer = self.sizer
p = wx.StaticText(self, label="Offset:")
sizer.Add(p, pos=(3, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.of = wx.SpinCtrl(self, size=(75, 21),
min=0, max=100, value="75")
sizer.Add(p, pos=(3, 1), span=(1, 3), flag=wx.ALIGN_CENTRE_VERTICAL)
p = wx.StaticText(self, label="Font:")
sizer.Add(p, pos=(4, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.ft = fsel.FontSelect(self)
sizer.Add(p, pos=(4, 1), span=(1, 3), flag=wx.ALIGN_CENTRE_VERTICAL)
self.GetSizer().Layout()
#----------------------------------------------------------------------
class _Group_3(_Group_1):
def __init__(self, parent, title, group="Face"):
_Group_1.__init__(self, parent, title, group)
sizer = self.sizer
for widget in [self.ls, self.sz]:
sizer.Detach(widget)
widget.Destroy()
sizer.Layout()
p = wx.StaticText(self, label="Shadow:")
sizer.Add(p, pos=(2, 0), flag=wx.ALIGN_CENTRE_VERTICAL)
p = self.sw = csel.ColourSelect(self)
sizer.Add(p, pos=(2, 1), span=(1, 3), flag=wx.ALIGN_CENTRE_VERTICAL)
self.GetSizer().Layout()
#----------------------------------------------------------------------
class _Group_4(_GroupBase):
def __init__(self, parent, title, group="Window"):
_GroupBase.__init__(self, parent, title, group)
box = wx.StaticBoxSizer(wx.StaticBox(self, label=title), wx.VERTICAL)
sizer = self.sizer = wx.GridBagSizer(2, 6)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -