Remove padding in wxPython's wxWizard
I'm using wxPython to create a wizard using the wxWizard control. I'm trying to a draw a colored rectangle but when I run the app, there seems to be a about a 10px padding on each side of the rectangle. This goes for all other controls too. I have to offset them a bit so that they appear exactly where I want them to. Is there any way I could remove this padding? Here's the source of my base Wizard page.
class SimplePage(wx.wizard.PyWizardPage):
"""
Simple wizard page with unlimited rows of text.
"""
def __init__(self, parent, title):
wx.wizard.PyWizardPage.__init__(self, parent)
self.next = self.prev = None
#self.sizer = wx.BoxSizer(wx.VERTICAL)
title = wx.StaticText(self, -1, title)
title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
#self.sizer.AddWindow(title, 0, wx.ALIGN_LEFT|wx.ALL, padding)
#self.sizer.AddWindow(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, padding)
# self.SetSizer(self.sizer)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, evt):
"""set up the device context (DC) for painting"""
self.dc = wx.PaintDC(self)
self.dc.BeginDrawing()
self.dc.SetPen(wx.Pen("grey",style=wx.TRANSPARENT))
self.dc.SetBrush(wx.Brush("grey", wx.SOLID))
# set x, y, w, h for rectangle
self.dc.DrawRectangle(0,0,500, 开发者_如何学C500)
self.dc.EndDrawing()
del self.dc
def SetNext(self, next):
self.next = next
def SetPrev(self, prev):
self.prev = prev
def GetNext(self):
return self.next
def GetPrev(self):
return self.prev
def Activated(self, evt):
"""
Executed when page is being activated.
"""
return
def Blocked(self, evt):
"""
Executed when page is about to be switched. Switching can be
blocked by returning True.
"""
return False
def Cancel(self, evt):
"""
Executed when wizard is about to be canceled. Canceling can be
blocked by returning False.
"""
return True
Thanks guys.
I can't verify this ( I would post as comment but i don't have enough reputation).
On my system the above code with
if __name__ == "__main__":
app = wx.App(0)
frame_1 = wx.wizard.Wizard(None)
s = SimplePage(frame_1,"")
app.SetTopWindow(frame_1)
s.Show()
frame_1.Show()
app.MainLoop()
Gives no border on the DC (there is a border that is part of the top level window decoration.
I verified this on windows (wx 2.8.10.1 python 2.4.4) and linux (wx 2.8.6.1 gtk)
精彩评论