]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FontEnumerator.py
fix Union(empty rect) bug
[wxWidgets.git] / wxPython / demo / FontEnumerator.py
CommitLineData
b1462dfa
RD
1
2from wxPython.wx import *
3
4#----------------------------------------------------------------------
5
65dd82cb
RD
6## class MyFontEnumerator(wxFontEnumerator):
7## def __init__(self, list):
8## wxFontEnumerator.__init__(self)
9## self.list = list
b1462dfa 10
65dd82cb
RD
11## def OnFacename(self, face):
12## self.list.append(face)
13## return true
b1462dfa
RD
14
15
16
17class TestPanel(wxPanel):
18 def __init__(self, parent, log):
19 wxPanel.__init__(self, parent, -1)
20
65dd82cb
RD
21## list = []
22## e = MyFontEnumerator(list)
23## e.EnumerateFacenames()
24
25 e = wxFontEnumerator()
b1462dfa 26 e.EnumerateFacenames()
65dd82cb
RD
27 list = e.GetFacenames()
28
b1462dfa
RD
29 list.sort()
30
c6c593e8
RD
31 wxStaticText(self, -1, "Face names:", (15, 50), (65, 18))
32 self.lb1 = wxListBox(self, -1, (80, 50), (200, 250),
b1462dfa 33 list, wxLB_SINGLE)
c6c593e8
RD
34 EVT_LISTBOX(self, self.lb1.GetId(), self.OnSelect)
35
36 self.txt = wxStaticText(self, -1, "Sample text...", (285, 50))
37
b1462dfa
RD
38 self.lb1.SetSelection(0)
39
40
c6c593e8
RD
41 def OnSelect(self, evt):
42 face = self.lb1.GetStringSelection()
43 font = wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, false, face)
44 self.txt.SetFont(font)
45 self.txt.SetSize(self.txt.GetBestSize())
46
63b6646e
RD
47## st = font.GetNativeFontInfo().ToString()
48## ni2 = wxNativeFontInfo()
49## ni2.FromString(st)
50## font2 = wxFontFromNativeInfo(ni2)
b1462dfa 51
b1462dfa
RD
52#----------------------------------------------------------------------
53
54def runTest(frame, nb, log):
55 win = TestPanel(nb, log)
56 return win
57
58#----------------------------------------------------------------------
59
60
61
62
63
64
65
66
b1462dfa
RD
67overview = """\
68wxFontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding.
69
70"""
63b6646e
RD
71
72
73if __name__ == '__main__':
74 import sys,os
75 import run
76 run.main(['', os.path.basename(sys.argv[0])])
77