]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/FontEnumerator.py
reSWIGged
[wxWidgets.git] / wxPython / demo / FontEnumerator.py
... / ...
CommitLineData
1# 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for V2.5
4#
5
6import wx
7
8#----------------------------------------------------------------------
9
10
11class TestPanel(wx.Panel):
12 def __init__(self, parent, log):
13 wx.Panel.__init__(self, parent, -1)
14
15 e = wx.FontEnumerator()
16 e.EnumerateFacenames()
17 list = e.GetFacenames()
18
19 list.sort()
20
21 s1 = wx.StaticText(self, -1, "Face names:")
22
23 self.lb1 = wx.ListBox(self, -1, wx.DefaultPosition, (200, 250),
24 list, wx.LB_SINGLE)
25
26 self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.lb1.GetId())
27
28 self.txt = wx.StaticText(self, -1, "Sample text...", (285, 50))
29
30 row = wx.BoxSizer(wx.HORIZONTAL)
31 row.Add(s1, 0, wx.ALL, 5)
32 row.Add(self.lb1, 0, wx.ALL, 5)
33 row.Add(self.txt, 0, wx.ALL|wx.ADJUST_MINSIZE, 5)
34
35 sizer = wx.BoxSizer(wx.VERTICAL)
36 sizer.Add(row, 0, wx.ALL, 30)
37 self.SetSizer(sizer)
38 self.Layout()
39
40 self.lb1.SetSelection(0)
41 self.OnSelect(None)
42 wx.FutureCall(300, self.SetTextSize)
43
44
45 def SetTextSize(self):
46 self.txt.SetSize(self.txt.GetBestSize())
47
48
49 def OnSelect(self, evt):
50 #print "OnSelect: "
51 face = self.lb1.GetStringSelection()
52 #print '\t '+face
53 font = wx.Font(28, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, face)
54 #print "\t got font"
55 self.txt.SetLabel(face)
56 #print "\t set label"
57 self.txt.SetFont(font)
58 #print "\t set font"
59 #self.txt.SetSize(self.txt.GetBestSize())
60 #print "\t set size"
61
62
63## st = font.GetNativeFontInfo().ToString()
64## ni2 = wx.NativeFontInfo()
65## ni2.FromString(st)
66## font2 = wx.FontFromNativeInfo(ni2)
67
68#----------------------------------------------------------------------
69
70def runTest(frame, nb, log):
71 win = TestPanel(nb, log)
72 return win
73
74#----------------------------------------------------------------------
75
76
77
78overview = """<html><body>
79wxFontEnumerator enumerates either all available fonts on the system or only
80the ones with given attributes - either only fixed-width (suited for use in
81programs such as terminal emulators and the like) or the fonts available in
82the given encoding.
83</body></html>
84"""
85
86
87if __name__ == '__main__':
88 import sys,os
89 import run
90 run.main(['', os.path.basename(sys.argv[0])])
91