473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

[wxpython] StaticBoxSizer problems

Hi!

I'd like to place several StaticBoxes in a frame, but I can't get it
right.

Consider the following code:

import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
box.Add(item=upper_box, flag=wx.GROW)
upper_sizer = wx.StaticBoxSizer(upper_box)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
frame.Show()
app.MainLoop()

This should show a frame containing a StaticBox which contains a
button, but: The button is not placed within the StaticBox. Hmm.

Additionally: wx.StaticBoxSizer.__init__.__doc__ says that a
StaticBoxSizer is created by __init__(self, StaticBox box, int
orient=HORIZONTAL). But if I change the line

upper_sizer = wx.StaticBoxSizer(upper_box)

to

upper_sizer = wx.StaticBoxSizer(StaticBox=upper_box)

I get the error: TypeError: new_StaticBoxSizer() takes at least 1
argument (0 given).

What am I missing?

Regards,
Matthias

Mar 8 '06 #1
6 2660
Matthias Kluwe wrote:
Hi!

I'd like to place several StaticBoxes in a frame, but I can't get it
right.

Consider the following code:

import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
box.Add(item=upper_box, flag=wx.GROW) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You should remiove this line.
upper_sizer = wx.StaticBoxSizer(upper_box)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
frame.Show()
app.MainLoop()

This should show a frame containing a StaticBox which contains a
button, but: The button is not placed within the StaticBox. Hmm.

Additionally: wx.StaticBoxSizer.__init__.__doc__ says that a
StaticBoxSizer is created by __init__(self, StaticBox box, int
orient=HORIZONTAL). But if I change the line

upper_sizer = wx.StaticBoxSizer(upper_box)

to

upper_sizer = wx.StaticBoxSizer(StaticBox=upper_box)

I get the error: TypeError: new_StaticBoxSizer() takes at least 1
argument (0 given).

What am I missing?

Generally speaking what you appear to be missing is a methodical
approach to GUI consruction. This reminds me of a lot of my early
experiments with wxPython code :-)

Less is more, but it *does* take a while to get the hang of sizers and
the like.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

Mar 9 '06 #2
Hi!
Matthias Kluwe wrote:
I'd like to place several StaticBoxes in a frame, but I can't get it
right. Consider the following code:
import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
box.Add(item=upper_box, flag=wx.GROW)


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You should remiove this line.


Hmm. As I see it, this means constructing the StaticBox and not placing
it in the frame. Obviously, this does not help.
[...]
What am I missing?


Generally speaking what you appear to be missing is a methodical
approach to GUI consruction. This reminds me of a lot of my early
experiments with wxPython code :-)


"a methodical approach to GUI construction"? Please be more specific --
any hints are welcome. Clearly, the above is an experiment with
wxPython, not anything methodical. This may follow when I understand
how StaticBoxSizer works.

Regards,
Matthias

Mar 9 '06 #3
Hi!

If anybody's interested, I've got an solution now.
I'd like to place several StaticBoxes in a frame, but I can't get it
right. import wx app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
box.Add(item=upper_box, flag=wx.GROW)
upper_sizer = wx.StaticBoxSizer(upper_box)
Oops. That's a thinko. upper_box is no sizer. The right line must be

box.Add(item=upper_sizer, flag=wx.GROW)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
frame.Show()
app.MainLoop() [...] Additionally: wx.StaticBoxSizer.__init__.__doc__ says that a
StaticBoxSizer is created by __init__(self, StaticBox box, int
orient=HORIZONTAL). But if I change the line upper_sizer = wx.StaticBoxSizer(upper_box) to upper_sizer = wx.StaticBoxSizer(StaticBox=upper_box) I get the error: TypeError: new_StaticBoxSizer() takes at least 1
argument (0 given).


This is still to be solved.

Regards,
Matthias

Mar 9 '06 #4
Matthias Kluwe wrote:
Hi!

Matthias Kluwe wrote:
I'd like to place several StaticBoxes in a frame, but I can't get it
right.
Consider the following code:
import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
box.Add(item=upper_box, flag=wx.GROW)


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You should remiove this line.

Hmm. As I see it, this means constructing the StaticBox and not placing
it in the frame. Obviously, this does not help.

Did you actually try removing the line and running the program? Guess
what: the button appears inside the static box sizer. And your problem
with that would be ... ?
[...]

What am I missing?


Generally speaking what you appear to be missing is a methodical
approach to GUI consruction. This reminds me of a lot of my early
experiments with wxPython code :-)

"a methodical approach to GUI construction"? Please be more specific --
any hints are welcome. Clearly, the above is an experiment with
wxPython, not anything methodical. This may follow when I understand
how StaticBoxSizer works.

Well, "methodical" would seem to include testing the suggestions of
well-meaning fellow netizens, for a start, rather than using your
psychic powers to predict results.

regards
Steve

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

Mar 9 '06 #5
Hi!

Steve Holden wrote:
Did you actually try removing the line and running the program?
I tried, of course :-) Removing the line

box.Add(item=upper_box, flag=wx.GROW)

yields the remaining program

import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
upper_sizer = wx.StaticBoxSizer(upper_box)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
frame.Show()
app.MainLoop()
Hmm. As I see it, this means constructing the StaticBox and not placing
it in the frame. Obviously, this does not help. Guess what: the button appears inside the static box sizer. And your problem
with that would be ... ?
.... the StaticBox not being displayed.
"a methodical approach to GUI construction"? Please be more specific --
any hints are welcome. Clearly, the above is an experiment with
wxPython, not anything methodical. This may follow when I understand
how StaticBoxSizer works.

Well, "methodical" would seem to include testing the suggestions of
well-meaning fellow netizens, for a start, rather than using your
psychic powers to predict results.


No prediction needed :-) I can't see how I have suggested you're not
well-meaning.

Regards,
Matthias

Mar 10 '06 #6
Matthias Kluwe wrote:
Hi!

Steve Holden wrote:
Did you actually try removing the line and running the program?

I tried, of course :-) Removing the line

box.Add(item=upper_box, flag=wx.GROW)

yields the remaining program

import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
upper_sizer = wx.StaticBoxSizer(upper_box)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
frame.Show()
app.MainLoop()

Hmm. As I see it, this means constructing the StaticBox and not placing
it in the frame. Obviously, this does not help.
Guess what: the button appears inside the static box sizer. And your problem
with that would be ... ?

... the StaticBox not being displayed.

But the StaticBox *is* displayed when I run the program under Windows,
at least. What platform are you running on?"a methodical approach to GUI construction"? Please be more specific --
any hints are welcome. Clearly, the above is an experiment with
wxPython, not anything methodical. This may follow when I understand
how StaticBoxSizer works.


Well, "methodical" would seem to include testing the suggestions of
well-meaning fellow netizens, for a start, rather than using your
psychic powers to predict results.

No prediction needed :-) I can't see how I have suggested you're not
well-meaning.

I didn't take any such inference from your response. I am slightly
confused that the program doesn't run for you, however. Here's the exact
source I ran:

import wx

app = wx.PySimpleApp()
frame = wx.Frame(parent=None, title="Test")
box = wx.BoxSizer(wx.VERTICAL)
frame.SetSizer(box)
upper_box = wx.StaticBox(parent=frame, label="Upper Box")
#box.Add(item=upper_box, flag=wx.GROW)
upper_sizer = wx.StaticBoxSizer(upper_box)
upper_sizer.Add(wx.Button(parent=frame, label="Button"))
box.Add(upper_sizer, flag=wx.GROW)
frame.Show()
print "running"
app.MainLoop()

The upper_box is displayed because it's presented as an argument to the
StaticBoxSizer's creator.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

Mar 10 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
1
by: ncookson | last post by:
I am trying to add a caption or title to the box drawn around a checklistbox and having no luck. Is there a way to do this? I am using python 2.3.4 and wxPython 2.5 on a windows platform. Noel
1
by: James Stroud | last post by:
Hello All, I will soon have an excuse to install a new operating system on my computer. I would like to know exactly what operating system I should have so that I can get wxPython going....
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
3
by: writeson | last post by:
Hi all, I'm trying to use wxPython from a fairly new installation of Fedora Core 5. I installed wxPython using yum -y install wxPython and that all seemed to work fine. However, when I run...
10
by: abcd | last post by:
I have a TextCtrl which is set to be multi-line. I have a function say, updateText(msg), which takes some string and appends it to the text control... txtControl.AppendText(msg) ...
1
by: kath | last post by:
Hello, sorry about the lengthy message. I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn...
10
by: markwalker84 | last post by:
Hello everyone! Got a bit of a problem... Two of the panels on my program contain a number of check boxes. The exact number of which is determined by a pair of variables. I have recently...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.