473,385 Members | 1,958 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,385 software developers and data experts.

wxPython: Fit() works on wxPanel, but not on surrounding wxFrame

Hello,
I am still struggling with a dynamic dialog box.
I have created a dialog box that will show a variable number of
controls depending on a selection made in a ComboBox also present in
the frame. The dialog box is not derived from wxDialog, but from a
wxFrame.
The dialog is initialized as follows:

class myDialog(wxFrame):
def __init__(self,parent,title):
wxFrame.__init__(self,parent,-1, title,
style=wxDEFAULT_FRAME_STYLE)
self.panel = wxPanel(self,-1)
The position of the controls on the wxPanel inside the frame is
controlled by sizers, which are initialized as follows:
self.MasterSizer=wxBoxSizer(wxVERTICAL)
self.panel.SetSizer(self.MasterSizer)
self.panel.SetAutoLayout(True)
self.MasterSizer.Fit(self.panel)
self.panel.Fit()
self.Fit()

To ensure that the size of the window and its layout always take into
account the number of the controls, every function that will change
the number of controls ends with the following threelines:
self.MasterSizer.RecalcSizes()
self.panel.Fit()
self.Fit()

For some reason, only the wxPanel changes its size as expected and
fits nicely around the controls placed on it. The surrounding wxFrame
is always (except at initialization time) slightly larger than the
panel, resulting in an ugly, dark grey border on the right and at the
bottom of the frame. How is that possible?
Thanks in advance for your help
Piet
Jul 18 '05 #1
1 5972
pi********@gmx.de (Piet) wrote:

[snip]
class myDialog(wxFrame):
def __init__(self,parent,title):
wxFrame.__init__(self,parent,-1, title, style=wxDEFAULT_FRAME_STYLE)
self.panel = wxPanel(self,-1)

The position of the controls on the wxPanel inside the frame is
controlled by sizers, which are initialized as follows:

self.MasterSizer=wxBoxSizer(wxVERTICAL)
self.panel.SetSizer(self.MasterSizer)
self.panel.SetAutoLayout(True)
self.MasterSizer.Fit(self.panel)
self.panel.Fit()
self.Fit()

To ensure that the size of the window and its layout always take into
account the number of the controls, every function that will change
the number of controls ends with the following threelines:

self.MasterSizer.RecalcSizes()
self.panel.Fit()
self.Fit()


I don't think Fit() is needed, it's implied by:

self.MasterSizer.SetSizeHints(self)

But you've not used that. You've also not added the panel to the
sizer:

self.MasterSizer.Add(self.panel, 1, wx.ALL|wx.EXPAND, 0)

Also, I think you need a self.Layout() at the end of those three
lines.

Finally, beware of scrollbars, they're not at all well handled by wx's
sizers.

To get past the initial layout differing from the resized layout, I
usually would call your EVT_SIZE handler to do the initial layout too,
then you can just fix one function....

It's a bit hard to debug with only a snippet of code.
Jul 18 '05 #2

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

Similar topics

2
by: Tom Plunket | last post by:
(Is this an appropriate place to ask wxPython questions?) Here's some code (line breaks put in without testing them, I'm kinda a newbie hope they're ok): <busted.py> from wxPython.wx import...
5
by: Daniel Ehrenberg | last post by:
I'm trying to learn wxPython, but I can't seem to find much documentation. The wxPython website says that all advanced (and even some basic) documentation for wxPython is only available in C++...
1
by: Curzio Basso | last post by:
Hi all, I have a problem for which I wasn't able to find an answer anywhere else, maybe someone can give me a hint... I designed with XRCed a small GUI (the code is at the bottom of the...
3
by: Piet | last post by:
Hi there. I am trying to display tabular data in a wxListCtrl. What I get from the script below are only the headers, not the items themselves. The documentation didnīt help me much; instead I was...
0
by: Piet | last post by:
Hello wxPythoneers. I have a problem with a dialog box derived from wxFrame which has a wxComboBox as main element. Depending on the entry selected from the ComboBox, the dialog box will be...
2
by: Emiliano Molina | last post by:
This has been driving me crazy for a couple of days and I have finally narrowed it down to the following code. If the commented section is uncommented the drag and drop handler is never called. I...
1
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm...
1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
2
by: CYBER | last post by:
Is this possible to create 1 wxFrame and register more than 1 wxPanel in it. And select the one you want to show at the moment ? I'm trying to implement a multistep wizard under wxPython. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.