Rick Muller wrote:
I sat down this weekend and started using wxPython in earnest, and I have to say that I'm very impressed.
I'm glad you like it.
And the documentation from wxWidgets is very complete, and translates directly to the Python wrappings. Very well done.
It's so nice to here someone new NOT complain that the docs are written for C++
That being said, I'm doing something *boneheaded* in sizing widgets.
Almost everywhere, you've used defaults for all the parameters when you Sizer.Add() something. As you've seen the results aren't very nice. Once you get used to them (whioch can take a while), you'll find that they are very powerful, and you can do almost anything you might want with them.
The problem is that the OK and Cancel buttons overlap the other widgets on the panel. I was wondering whether I'm doing something wrong.
Actually, this looks a like a little bug. On my system (GTK) they don't overlap, but the OK button gets the "I'm the default" box surronding it, and that does overlap.
>Is there a command to put extra spacing around the widgets when packing them?
There sure is. Put a wx.ALL , wx.TOP, etc. flag as one of the third arguments to Add, and the width of the space you want as the fourth argument.
You probably want to make at least one of the windows in a sizer stretchable as well (a integer > 0 as the second argument), so that it can fill space.
Another sizing related problem has to do with setting default sizes. In my main checkbook register widget, I have a large display area (currently 585x450 pixels) that holds a ListBox that displays the checks. When I pack this into the frame, I would like to simply not give any size arguments, and have the frame figure out the additional size that it needs depending on whether there is a toolbar, menubar, and/or a statusbar. If there is a way to do this, I haven't figured it out yet,
Put everything on the frame in a sizer, and call self.SetSizerAndFit(sizer) at the end of the Frame's __init__. That makes it fit around whatever is inside it.
Finally, I've noticed strange behavior on the Macintosh port of wxPython with regards to menu bars. My menubars show up fine on linux/wxGtk and on Macintosh running fink and wxGTK. But the native Macintosh widgets don't offer any room for the menu bar.
The Mac menubar is put at the top of the screen, like on other Mac apps. Or did you mean something else?
Enclosed is a mini app with your sizer stuff, fixed up a bit to make it look better. I'd look into using a FlexGridSizer for this, however, so that you can get stuff on the different rows to line up. Make sure you read everything in the Wiki about Sizers. Somewhere there is a nice diagram that describes what all the flags mean.
You also might want to consider using wxGlade or wxDesigner, and letting it figure out the sizers for you.
-Chris
SimpleSizer4.py (1.75 KB)
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov