LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-12-2009, 08:13 AM   #1
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Rep: Reputation: 56
Question WxPython: sizers, panels, frames confusion


Hi

I am pretty new to WxPython, have been playing around with sizers and panels and so far could not grasp how they relate to eachother.

You first create a frame, which is the container for the others, but how do panels relate to sizers? Can widgets (like buttons be contained by panels and sizers?)
Unfortunately, there is no simple straight forwards explaination what a panel is, what it is good for and for what not.
Also, where do you define the size of sizer-cells?

From my questions, you might figure that I don't understand "how it all fits together".

Cheers

Markus
 
Old 01-13-2009, 09:58 AM   #2
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Question

It is a shame that nobody seems to know. I dug a little more, but still can't figure out how panels relate to sizers and vice versa.

I guess I should write a comprehensive noob tutorial once I have figured it out, since many newbies must get shipwrecked on the highly complicated widgets of WxPython.

One thing that also baffles me is why a normal window is called a frame. Yet, there are windows, which seems to be everything and nothing at the same time.

Markus
 
Old 01-13-2009, 01:50 PM   #3
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
If you think wxPython is "complicated" you should see other windowing toolkits:

Code:
class UserDiag(wx.Dialog):
    def __init__(self):
        wx.Dialog.__init__(self, None, -1, 'Login',
                           size=(300, 100))
        panel = wx.Panel(self, -1)
        usrLabel = wx.StaticText(panel, -1, "Username:")
        self.usrText = wx.TextCtrl(panel, -1, size=(175, -1))
        pwdLabel = wx.StaticText(panel, -1, "Password:")
        self.pwdText = wx.TextCtrl(panel, -1, size=(175, -1), 
                                   style=wx.TE_PASSWORD)
        okButton = wx.Button(panel, label="OK")
        cancelButton = wx.Button(panel, label="Close")
        sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)
        sizer.AddMany([usrLabel, self.usrText, pwdLabel, self.pwdText, 
                       okButton, cancelButton])
        panel.SetSizer(sizer)
        self.Bind(wx.EVT_BUTTON, self.onOK, okButton)
        self.Bind(wx.EVT_BUTTON, self.onClose, cancelButton)
        self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
    def onOK(self, event):
        self.Close(True)
    def onClose(self, event):
        self.Close(True)
    def onCloseWindow(self, event):
        self.Destroy()
It's not a well-refined example, but it shows how simple sizers are. Frame is analogous with a window frame and the rest of the contents that are contained inside. Generally, Frames contain panels which contain sizers which further contain other widgets. And, yes, these can contain other nested sizers if wished. Most simple GUIs don't require this.
 
Old 01-22-2009, 04:09 AM   #4
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
[solved]

Thanks, that helps me already big deal.

Markus
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wxPython merchtemeagle Linux - Software 3 02-23-2005 10:50 AM
Possible to create a frames effect in an HTML page without using frames? furfurdemon666 General 10 12-12-2004 06:52 AM
wxPython xlord Programming 0 05-23-2004 04:12 PM
wxPython. vexer Slackware 5 09-22-2003 03:11 PM
wxPython Filsta Linux - Software 0 08-20-2002 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration