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 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
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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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
|
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....
|
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...
|
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...
|
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)
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |