]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FontEnumerator.py
Don't allow parameterless wxDropSource
[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 45 def OnSelect(self, evt):
1fded56b 46 #print "OnSelect: "
c6c593e8 47 face = self.lb1.GetStringSelection()
1fded56b 48 #print '\t '+face
8fa876ca 49 font = wx.Font(28, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, face)
1fded56b
RD
50 #print "\t got font"
51 self.txt.SetLabel(face)
52 #print "\t set label"
c6c593e8 53 self.txt.SetFont(font)
1fded56b
RD
54 #print "\t set font"
55 #self.txt.SetSize(self.txt.GetBestSize())
56 #print "\t set size"
57
c6c593e8 58
63b6646e 59## st = font.GetNativeFontInfo().ToString()
8fa876ca 60## ni2 = wx.NativeFontInfo()
63b6646e 61## ni2.FromString(st)
8fa876ca 62## font2 = wx.FontFromNativeInfo(ni2)
b1462dfa 63
b1462dfa
RD
64#----------------------------------------------------------------------
65
66def runTest(frame, nb, log):
67 win = TestPanel(nb, log)
68 return win
69
70#----------------------------------------------------------------------
71
72
73
1e4a197e
RD
74overview = """<html><body>
75wxFontEnumerator enumerates either all available fonts on the system or only
76the ones with given attributes - either only fixed-width (suited for use in
77programs such as terminal emulators and the like) or the fonts available in
78the given encoding.
79</body></html>
b1462dfa 80"""
63b6646e
RD
81
82
83if __name__ == '__main__':
84 import sys,os
85 import run
86 run.main(['', os.path.basename(sys.argv[0])])
87