]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FontEnumerator.py
moved vararg CRT functions wrappers to a new wxcrtvararg.h header
[wxWidgets.git] / wxPython / demo / FontEnumerator.py
CommitLineData
b1462dfa 1
8fa876ca 2import wx
b1462dfa
RD
3
4#----------------------------------------------------------------------
5
b1462dfa 6
8fa876ca 7class TestPanel(wx.Panel):
b1462dfa 8 def __init__(self, parent, log):
8fa876ca 9 wx.Panel.__init__(self, parent, -1)
b1462dfa 10
8fa876ca 11 e = wx.FontEnumerator()
b1462dfa 12 e.EnumerateFacenames()
65dd82cb
RD
13 list = e.GetFacenames()
14
b1462dfa
RD
15 list.sort()
16
8fa876ca 17 s1 = wx.StaticText(self, -1, "Face names:")
c6c593e8 18
8fa876ca
RD
19 self.lb1 = wx.ListBox(self, -1, wx.DefaultPosition, (200, 250),
20 list, wx.LB_SINGLE)
c6c593e8 21
8fa876ca 22 self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.lb1.GetId())
1e4a197e 23
8fa876ca
RD
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)
1e4a197e
RD
33 self.SetSizer(sizer)
34 self.Layout()
35
b1462dfa 36 self.lb1.SetSelection(0)
1fded56b 37 self.OnSelect(None)
8fa876ca 38 wx.FutureCall(300, self.SetTextSize)
1fded56b
RD
39
40
41 def SetTextSize(self):
42 self.txt.SetSize(self.txt.GetBestSize())
b1462dfa
RD
43
44
c6c593e8
RD
45 def OnSelect(self, evt):
46 face = self.lb1.GetStringSelection()
8fa876ca 47 font = wx.Font(28, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, face)
1fded56b 48 self.txt.SetLabel(face)
c6c593e8 49 self.txt.SetFont(font)
90f7e9c7 50 if wx.Platform == "__WXMAC__": self.Refresh()
c6c593e8 51
63b6646e 52## st = font.GetNativeFontInfo().ToString()
8fa876ca 53## ni2 = wx.NativeFontInfo()
63b6646e 54## ni2.FromString(st)
8fa876ca 55## font2 = wx.FontFromNativeInfo(ni2)
b1462dfa 56
b1462dfa
RD
57#----------------------------------------------------------------------
58
59def runTest(frame, nb, log):
60 win = TestPanel(nb, log)
61 return win
62
63#----------------------------------------------------------------------
64
65
66
1e4a197e
RD
67overview = """<html><body>
68wxFontEnumerator enumerates either all available fonts on the system or only
69the ones with given attributes - either only fixed-width (suited for use in
70programs such as terminal emulators and the like) or the fonts available in
71the given encoding.
72</body></html>
b1462dfa 73"""
63b6646e
RD
74
75
76if __name__ == '__main__':
77 import sys,os
78 import run
8eca4fef 79 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
63b6646e 80