]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/wx/lib/analogclock/lib_setup/fontselect.py
redirect to the page only the help events coming from this control itself to avoid...
[wxWidgets.git] / wxPython / wx / lib / analogclock / lib_setup / fontselect.py
... / ...
CommitLineData
1# AnalogClock's font selector for setup dialog
2# E. A. Tacao <e.a.tacao |at| estadao.com.br>
3# http://j.domaindlx.com/elements28/wxpython/
4# 15 Fev 2006, 22:00 GMT-03:00
5# Distributed under the wxWidgets license.
6
7import wx
8from wx.lib.newevent import NewEvent
9from wx.lib.buttons import GenButton
10
11#----------------------------------------------------------------------------
12
13(FontSelectEvent, EVT_FONTSELECT) = NewEvent()
14
15#----------------------------------------------------------------------------
16
17class FontSelect(GenButton):
18 def __init__(self, parent, size=(75, 21), value=None):
19 GenButton.__init__(self, parent, wx.ID_ANY, label="Select...",
20 size=size)
21 self.SetBezelWidth(1)
22
23 self.parent = parent
24 self.SetValue(value)
25
26 self.parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
27
28
29 def GetValue(self):
30 return self.value
31
32
33 def SetValue(self, value):
34 if value is None:
35 value = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
36 self.value = value
37
38
39 def OnClick(self, event):
40 data = wx.FontData()
41 data.EnableEffects(False)
42 font = self.value; font.SetPointSize(10)
43 data.SetInitialFont(font)
44
45 dlg = wx.FontDialog(self, data)
46 changed = dlg.ShowModal() == wx.ID_OK
47
48 if changed:
49 data = dlg.GetFontData()
50 self.value = data.GetChosenFont()
51 self.Refresh()
52 dlg.Destroy()
53
54 if changed:
55 nevt = FontSelectEvent(id=self.GetId(), obj=self, val=self.value)
56 wx.PostEvent(self.parent, nevt)
57
58
59#
60##
61### eof