2010-05-12 38 views
0

我正在使用wxPizard創建一個使用wxWizard控件的嚮導。我試圖繪製一個彩色的矩形,但是當我運行應用程序時,似乎在矩形的每一邊都有一個大約10px的填充。這也適用於所有其他控件。我必須稍微抵消它們,以便它們恰好出現在我想要的位置。有什麼辦法可以刪除這個填充?這是我的基本嚮導頁面的來源。刪除wxPython的wxWizard中的填充

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 

謝謝你們。

回答

1

我無法驗證這一點(我會發表評論,但我沒有足夠的聲望)。

在我的系統上面的代碼與

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() 

給出的DC無邊框(有邊框是頂層窗口裝飾的一部分。

我驗證了這個在Windows(WX 2.8.10.1 python 2.4.4)和linux(wx 2.8.6.1 gtk)

+0

我試過你的例子,它工作的很好,然後我再次嘗試我的,它沒有,區別在於使用'Wizard.Show ()'方法和我正在使用的'Wizard.RunWizard()'方法,我又回到閱讀文檔。 o有一個默認的5px或其他東西的邊框。我使用下面的命令,它的邊界消失了'Wizard.SetBorder(-5)'。這與sizer有關,但我沒有使用。糟糕的做法,我知道。不過謝謝。 – 2010-05-18 12:43:22