wxPython - PLEASE Help
Donnal Walter
donnalcwalter at yahoo.com
Tue Dec 24 06:59:30 EST 2002
"DP" <pennedinil at excite.com> wrote in message
news:6af8e801.0212240117.d9ffd87 at posting.google.com...
> In advance, many thanks for any help on this. I'm stumped, mainly
> because I just don't know enough.
>
See corrected code below. You may also want to check out the
wxPython-users mailing list at: http://wxpython.org/maillist.php
Corrected code:
#-----------------------------------------------------------------
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)
hbox = wxBoxSizer(wxHORIZONTAL)
self.cbID = NewId()
self.cb = wxCheckBox(self, self.cbID, "x", wxPoint(-1, -1),
wxSize(-1, -1), style = wxSUNKEN_BORDER)
self.loadID = NewId()
self.load = wxButton(self, self.loadID, "Load")
self.backID = NewId()
self.back = wxButton(self, self.backID, "Back-up")
self.textID = NewId()
self.text = wxStaticText(self, self.textID, Info)
hbox.Add(0, 0, 1, wxEXPAND)
hbox.Add(self.load, 0, wxALIGN_CENTER)
hbox.Add(self.back, 0, wxALIGN_CENTER)
hbox.Add(self.cb, 0, wxALIGN_CENTER)
hbox.Add(self.text, 0, wxALIGN_CENTER)
self.SetAutoLayout(true)
self.SetSizer(hbox)
self.SetAutoLayout(true)
self.Centre(direction = wxBOTH)
# -----------------------------------------------------
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, "a", "b")
EVT_CLOSE(self, self.OnCloseWindow)
box = wxBoxSizer(wxVERTICAL)
box.Add(self.panel, 1, wxEXPAND)
###################################################################
self.SetSizer(box) # this is the statement you are missing
###################################################################
self.SetAutoLayout(true)
self.Centre(direction = wxBOTH)
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