views:

79

answers:

1

Hi Guys,

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, 500)
        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.

+1  A: 

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)

iondiode
I tried your example and it worked fine. Then i tried mine again and it didn't. The difference is between using the `Wizard.Show()` method and the `Wizard.RunWizard()` method which I'm using. I went back to reading the documentation again. It seems to have a default a border of 5px or something. I used the following command it the borders went away `Wizard.SetBorder(-5)`. It's got something to do with sizers but I'm not using any. Bad practice, I know. Thanks though.
Mridang Agarwalla