FW: [wxPython] laying out a dialog box

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FW: [wxPython] laying out a dialog box

Echeverria Rabi, Cristian  Rodrigo, TRANSELEC S.A.

SORRY , SORRY
I SEND THE WRONG  FILE.
THIS IS THE RIGHT ONE

 


-----Original Message-----
From: Echeverría, Cristian
Sent: Friday, December 17, 1999 1:39 PM
To: 'Bob Klimek'; wxPython Post
Subject: RE: [wxPython] laying out a dialog box
Importance: High

You can use wxBoxSizer.
I send you an example file

Cristian Echeverría



#- <00> -----------------------------------------------------------------------
# Archivo           : demo.py -- 17/12/1999

from wxPython.wx import *

#- <00> -----------------------------------------------------------------------

class MyDialog(wxDialog):
    def __init__(self,parent,title):
        wxDialog.__init__(self,parent,-1,title)

        box = wxBoxSizer(wxVERTICAL)

        box1 = wxBoxSizer(wxHORIZONTAL)
        # You can put your widgets here
        widget = wxPanel(self,-1,size=(200,200))
        box1.Add(widget,0,wxALL,5)
        box.Add(box1,0,wxALL,2)
       
        boxX = wxBoxSizer(wxHORIZONTAL)
        okbut = wxButton(self,wxID_OK,"Aceptar")
        okbut.SetDefault()
        boxX.Add(okbut,0,wxALL,5)
        boxX.Add(wxButton(self,wxID_CANCEL,"Cancelar"),0,wxALL,5)
        box.Add(boxX,0,wxCENTER)

        self.SetAutoLayout(true)
        self.SetSizer(box)
        box.Fit(self)
        box.SetSizeHints(self)

#- <00> -----------------------------------------------------------------------

class MainFrame(wxFrame):
    def __init__(self, parent,title):
        wxFrame.__init__(self, parent, -1, title,
                         wxDefaultPosition, wxSize(400,300))
       
        mainmenu = wxMenuBar()
        menu = wxMenu()
        menu.Append(100,"Dialog...","Display Dialog")
        mainmenu.Append(menu, "&Archivo")
        self.SetMenuBar(mainmenu)
        EVT_MENU(self,100,self.OnDisplayDialog)
       
        self.Center(wxBOTH)

    def OnDisplayDialog(self,event):
        dlg = MyDialog(self,"Dialog Sample")
        dlg.Center(wxBOTH)
        opcion = dlg.ShowModal()
        dlg.Destroy()

    def OnCloseWindow(self,event):
        self.Destroy()

#- <00> -----------------------------------------------------------------------

class MainApp(wxApp):
    def OnInit(self):
        frame = MainFrame(NULL,"Wx-Template")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

#- <00> -----------------------------------------------------------------------

def main():
    app = MainApp(0)
    app.MainLoop()

#- <99> -----------------------------------------------------------------------

if __name__ == '__main__':
    main()