Rick Pasotto wrote:
I've gotten to understanding Tkinter fairly well and now I *trying* to
understand wxWindows and having a terrible time.
wxWindows and TK use different vocabulary, and different layout
mechanisms, so the transition takes some brain re-wiring.
Why is a window not a window but a frame?
Why is a frame not a frame but a panel?
Or do I have that wrong?
I've kind of forgotten my TK definitions, and the answer to "why" is
jsut arbitrary choice of vocabulary, but here are some quick wxPython
definitions:
A wxWindow is the base class for all controls, etc. It is a rectangular
thing that can be drawn on the screen, and subclasses to create
virtually all the GUI elements you need (most of that subclassing has
been done for you)
a wxFrame is is a "top level" window: it is managed by the system, in
the sense that the system ddrawas a border around it, and provides a way
to move, re-size it, etc. It is what most computer users, rather than
progarmmers, would call a "Window".
A wxPanel is a type of wxWindow that is used to place other windows,
(controls, etc) on. It adds a little bit of functionality to the baseic
wxWindows, including tabbing between controls, etc. It is usually used
to group a set of widgets that all work together as a unit in some way.
You will often find yourself placing your widgets on a panel, and then
the panel in some kind of container, like a wxNotebook, or wxSashWindow,
etc.
How do I get a window (or is it a frame) to figure out for itself
what size it ought to be based on its contents?
It could be either a window or a frame, though most likely it will be a
class you define, that is subclassed from a wxFrame (for a top level
window) or a wxPanel(for a piece of what be on a frame)
wxWhatever.Fit()
How can I adjust the internal padding on a button?
I'm not sure what "internal" padding is, but to put space around a
button, you use the spacer flags and sizes when you add the button to a
sizer. For example:
MySizer.Add(myButton,0,wxALL|OtherFlags, 4)
wxALL is a flag that indicates that you want space on all sides, and the
4 is the number of pixels to make that space.
How can I make all buttons in a group the same size?
This depends on whether you want them a fixed size, or all the same size
to fit something else. Fixed size is easy. For all the same size, put
them in a wxBoxSizer, either horizontal or vertical, and give them all
the saem flagg wxEXPAND if you want them to expand to fit the dimension
perpindicular to the main one, and give them all the option value,
usually 1, so they will all stretch the same amount. Example:
ButtonSizer = wxBoxSizer(wxVERTICAL)
for (button) in ButtonList:
ID = wxNewId()
ButtonSizer.Add(button,0,wxEXPAND|wxALL,2)
This will put all the buttons in ButtonsList in a vertical row, making
them all the same size, with a border of two pixels around them.
(example cut and pasted from a small app of mine)
Can a cell in a wxGridSizer span multiple rows or columns?
No, but take a look at wxFlexGridSizer(). It doesn't appear to be in my
copy of the demo, but it is in the wxWindows reference docs.
Make sure you read the wxSizer overview in teh docs, ans well as the
sizer stuff in the Wiki.
-Chris
···
--
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