Skip to content

Commit a470670

Browse files
author
Metallicow
committed
Cleanup/FONT/Readability
1 parent 3ff843e commit a470670

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

FontSizeTest.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,47 @@ def __init__(self, *args, **kwargs):
1515
def OnPaint(self, event):
1616
dc = wx.PaintDC(self)
1717
self.Draw(dc)
18-
18+
1919
def Draw(self, dc):
2020
dc.Clear()
2121
x,y = 20, 0
22-
for fs in [8, 10, 12, 14, 18, 20, 30, 60]:
23-
y += 1.2*fs
22+
for fs in [8, 10, 12, 14, 18, 20, 30, 60, 72]:
23+
y += 1.2 * fs
2424
w = fs * 11
25-
S = (0.45*fs, fs) # this hieght/width ratio seems to match what I get on OS-X and GTK
26-
text = "%i pixel Font and Box"%fs
27-
Font = wx.FontFromPixelSize(S, wx.SWISS, wx.NORMAL, wx.NORMAL, underlined=True)
25+
S = (0.45 * fs, fs) # this hieght/width ratio seems to match what I get on OS-X and GTK.
26+
text = "%i pixel Font and Box" %fs
27+
Font = wx.FontFromPixelSize(S, wx.FONTFAMILY_SWISS,
28+
wx.FONTSTYLE_NORMAL,
29+
wx.FONTWEIGHT_NORMAL,
30+
underlined=True)
2831
dc.SetFont(Font)
2932
E = dc.GetTextExtent(text)
3033
dc.SetFont(Font)
3134
E = dc.GetTextExtent(text)
32-
print "Font size: %s, Extent ratio: %s"%(S, E[0] / E[1])
33-
print "font point size::", Font.GetPointSize()
35+
print("Font size: %s, Extent ratio: %s"%(S, E[0] / E[1]))
36+
print("font point size::", Font.GetPointSize())
3437
dc.DrawText(text, x, y)
3538
dc.DrawRectangle(x, y, w, fs)
3639
dc.DrawText(text, x, y)
3740

3841
class MyFrame(wx.Frame):
3942
def __init__(self, parent):
40-
wx.Frame.__init__(self, parent, title="test", size = (500, 500))
43+
wx.Frame.__init__(self, parent, title="test", size=(500, 500))
4144

4245
self.Panel = MyPanel(self)
4346

4447
sizer = wx.BoxSizer(wx.VERTICAL)
45-
sizer.Add(self.Panel,1,wx.EXPAND)
48+
sizer.Add(self.Panel, 1, wx.EXPAND)
4649

4750
self.SetSizer(sizer)
48-
51+
4952
def UpdatePanel(self,event):
5053
#self.Panel.DrawRect()
5154
pass
52-
55+
5356
if __name__ == '__main__':
5457
app = wx.App(0)
5558
frame = MyFrame(None)
5659
frame.Show()
5760
app.MainLoop()
58-
61+

0 commit comments

Comments
 (0)