]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FontEnumerator.py
reSWIGged
[wxWidgets.git] / wxPython / demo / FontEnumerator.py
CommitLineData
8fa876ca
RD
1# 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for V2.5
4#
b1462dfa 5
8fa876ca 6import wx
b1462dfa
RD
7
8#----------------------------------------------------------------------
9
b1462dfa 10
8fa876ca 11class TestPanel(wx.Panel):
b1462dfa 12 def __init__(self, parent, log):
8fa876ca 13 wx.Panel.__init__(self, parent, -1)
b1462dfa 14
8fa876ca 15 e = wx.FontEnumerator()
b1462dfa 16 e.EnumerateFacenames()
65dd82cb
RD
17 list = e.GetFacenames()
18
b1462dfa
RD
19 list.sort()
20
8fa876ca 21 s1 = wx.StaticText(self, -1, "Face names:")
c6c593e8 22
8fa876ca
RD
23 self.lb1 = wx.ListBox(self, -1, wx.DefaultPosition, (200, 250),
24 list, wx.LB_SINGLE)
c6c593e8 25
8fa876ca 26 self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.lb1.GetId())
1e4a197e 27
8fa876ca
RD
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)
1e4a197e
RD
37 self.SetSizer(sizer)
38 self.Layout()
39
b1462dfa 40 self.lb1.SetSelection(0)
1fded56b 41 self.OnSelect(None)
8fa876ca 42 wx.FutureCall(300, self.SetTextSize)
1fded56b
RD
43
44
45 def SetTextSize(self):
46 self.txt.SetSize(self.txt.GetBestSize())
b1462dfa
RD
47
48
c6c593e8 49 def OnSelect(self, evt):
1fded56b 50 #print "OnSelect: "
c6c593e8 51 face = self.lb1.GetStringSelection()
1fded56b 52 #print '\t '+face
8fa876ca 53 font = wx.Font(28, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, face)
1fded56b
RD
54 #print "\t got font"
55 self.txt.SetLabel(face)
56 #print "\t set label"
c6c593e8 57 self.txt.SetFont(font)
1fded56b
RD
58 #print "\t set font"
59 #self.txt.SetSize(self.txt.GetBestSize())
60 #print "\t set size"
61
c6c593e8 62
63b6646e 63## st = font.GetNativeFontInfo().ToString()
8fa876ca 64## ni2 = wx.NativeFontInfo()
63b6646e 65## ni2.FromString(st)
8fa876ca 66## font2 = wx.FontFromNativeInfo(ni2)
b1462dfa 67
b1462dfa
RD
68#----------------------------------------------------------------------
69
70def runTest(frame, nb, log):
71 win = TestPanel(nb, log)
72 return win
73
74#----------------------------------------------------------------------
75
76
77
1e4a197e
RD
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>
b1462dfa 84"""
63b6646e
RD
85
86
87if __name__ == '__main__':
88 import sys,os
89 import run
90 run.main(['', os.path.basename(sys.argv[0])])
91