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