[wxPython] Re: laying out a dialog box

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Re: laying out a dialog box

Bob Klimek-2
Hello Christian,

Thanks for your quick reply. But actually I got that far my self. The
problem is that I'm not able to diplay anything inside that dialog box.
To illustrate the point I've added a few radio buttons to your dialog
box, but if you'll run it you'll see that the dialog box is still blank,
except for the two buttons.

Bob


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)

        # Added radio buttons --- Doesn't show up
        sampleList = ['zero         ', 'one', 'two', 'three']
        self.rb = wxRadioBox(self, 10, "label title", wxPoint(20,20),
wxDefaultSize,
                        sampleList, 1, wxRA_SPECIFY_COLS)



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

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: laying out a dialog box

Robin Dunn


> Hello Christian,
>
> Thanks for your quick reply. But actually I got that far my self. The
> problem is that I'm not able to diplay anything inside that dialog box.
> To illustrate the point I've added a few radio buttons to your dialog
> box, but if you'll run it you'll see that the dialog box is still blank,
> except for the two buttons.
>


Your radiobox is a child of the dialog, but in the same position as the
panel.  Make it a child of the panel instead and see if that fixes it.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] Re: laying out a dialog box

Echeverria Rabi, Cristian  Rodrigo, TRANSELEC S.A.
In reply to this post by Bob Klimek-2
When you work with wxBoxSizer the order
to create an asociate the widget with the sizer
is very important

i.e: create de wxBoxSizer, create  the widget, asociate
the widget to the sizer and the asociate the sizer to
his parent.

Here is the code with your radiobox

 
Cristian Echeverria

-----Original Message-----
From: Bob Klimek [SMTP:[hidden email]]
Sent: Friday, December 17, 1999 1:46 PM
To: wxPython Post
Subject: [wxPython] Re: laying out a dialog box

Hello Christian,

Thanks for your quick reply. But actually I got that far my self. The
problem is that I'm not able to diplay anything inside that dialog box.
To illustrate the point I've added a few radio buttons to your dialog
box, but if you'll run it you'll see that the dialog box is still blank,
except for the two buttons.

Bob

#- <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
        sampleList = ['zero','one','two','three']
        self.rb = wxRadioBox(self,10,"label title",wxPoint(-1,-1),wxDefaultSize,
            sampleList,1,wxRA_SPECIFY_COLS)
        box1.Add(self.rb,1,wxALL,5)
        box.Add(box1,1,wxEXPAND)
       
        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()
Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] Re: laying out a dialog box

Niki Spahiev-3
In reply to this post by Bob Klimek-2
"Cristian Echeverria" <[hidden email]> wrote:
> I think you don´t need another panel, because you
> can do all the layout only with sizers (this way you
> don´t need to hard code any position)

I realy need nested panels for other tasks. This code was just
example for Tab traversal.

Any help?

thanks,
Niki Spahiev

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users