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