]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-11/blockwindow.py
don't use strlen() to verify the length of the string as it can contain embedded...
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-11 / blockwindow.py
1 import wx
2
3 class BlockWindow(wx.Panel):
4 def __init__(self, parent, ID=-1, label="",
5 pos=wx.DefaultPosition, size=(100, 25)):
6 wx.Panel.__init__(self, parent, ID, pos, size,
7 wx.RAISED_BORDER, label)
8 self.label = label
9 self.SetBackgroundColour("white")
10 self.SetMinSize(size)
11 self.Bind(wx.EVT_PAINT, self.OnPaint)
12
13 def OnPaint(self, evt):
14 sz = self.GetClientSize()
15 dc = wx.PaintDC(self)
16 w,h = dc.GetTextExtent(self.label)
17 dc.SetFont(self.GetFont())
18 dc.DrawText(self.label, (sz.width-w)/2, (sz.height-h)/2)
19
20