wxPython - PLEASE Help

Anton Vredegoor anton at vredegoor.doge.nl
Tue Dec 24 08:08:41 EST 2002


On 24 Dec 2002 01:17:16 -0800, pennedinil at excite.com (DP) wrote:

>I can't seem to get the panel to display in the frame (see code
>below). What am I doing wrong? I've been at this too long now...

The wxBoxSizer code was hiding it. Some other elements were drawn on
the same coordinates, so they were hiding each other :-)

I have taken the liberty of removing the offending lines and changing
some coordinates and some text in the code you posted in order to get
the elements to display. I am evading the problem with the wxBoxSizer
code for now. Generally speaking it's best to build GUI's by starting
from something that works and to add/change things one by one.

Regards,
	Anton.

from wxPython.wx import *

def ruSure(parent):
    ru = wxMessageDialog(parent, "Are you sure you want to quit?",
           "Leaving Application", \
           wxOK | wxCANCEL | wxICON_QUESTION)
    return ru.ShowModal()

class baseCopyPane(wxPanel):
    
    def __init__(self, parent, id, Info, sourceDir,
                 pos = wxDefaultPosition,
                 size = wxDefaultSize,
                 style = wxTAB_TRAVERSAL,
                 cbTT = "Select Individually",
                 loadTT = "Copy files",
                 backTT = "Backup files",
                 ):
        wxPanel.__init__(self, parent, id)
        self.cbID = NewId()
        self.cb = wxCheckBox(self, self.cbID, "x", wxPoint(20,90), \
            wxSize(-1, -1), style = wxSUNKEN_BORDER)
        self.loadID = NewId()
        self.load = wxButton(self, self.loadID, "Load",
            wxPoint(150,90), wxSize(50,20))
        self.backID = NewId()
        self.back = wxButton(self, self.backID, "Back-up",
            wxPoint(200,90),wxSize(50,20))
        self.textID = NewId()
        self.text = wxStaticText(self, self.textID, Info)

class testframe(wxFrame):
    
    def __init__(self, parent, id, title):
        # initialize frame geometry & position
        wxFrame.__init__(self, parent, id, title, 
            size = (600, 200),
            style = wxSYSTEM_MENU | wxMINIMIZE_BOX | 
            wxRESIZE_BORDER |wxCAPTION)
        # Add a panel to place things in
        self.panel = baseCopyPane(self, -1, "the info", "b")
        EVT_CLOSE(self, self.OnCloseWindow)

    def OnCloseWindow(self, event):
        if ruSure(self) == wxID_OK:
            self.Destroy()

    def exitApp(self, event):
        if ruSure(self) == wxID_OK:
            self.Close()

class TestApp(wxApp):

    def OnInit(self):
        frame = testframe(NULL, -1, "Test Frame")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

if __name__ == "__main__":
    app = TestApp(0)
    app.MainLoop()




More information about the Python-list mailing list