jmf wrote:
I apologize for this mail. I can't post to the wxPython list.
That's odd. It seems to be working fine for me an many others. I've forwarded it to the list for you.
I am cleaning the code of some large applications I have. The plan is to
use sizers in every frame, panel, dialog window (Good idea, isn't it?).
Yes. I agree.
1. In the declaration of the controls, should I use wx.DefaultPosition
and wx.DefaultSize or should I drop them (seems logical)?w1 = wx.Window(self, wx.NewId(), wx.DefaultPosition, wx.DefaultSize)
or
w1 = wx.Window(self, wx.NewId())
I'd drop them. That's the beauty of python's default values. The only reason to use them is because you need to specify later arguments (such as style), but if you use keywords you don't need to do that either.
Also, for most window constructors, you can leave the ID off too, leaving you with:
w1 = wx.Window(self)
Very simple and clean.
2. StaticLine. The default thickness of the line is 2. It seems, this
value has changed in the different wxPython releases. Am I wrong ?
I have no idea. I suppose it's best to specify the thickness you want, so as to be insulated against future changes.
3. Sometimes one wishes a size value for an item/control, that is
different from the default value. Where is the best place to define it;
at the level of the control declaration or in the sizer manager with an
SetItemMinSize().
I'd put it in the control declaration, unless it will change later, or be based on a value unknown at creation time.
4. Just a final side note. The GridBagSizer does not seem to be very
healthy. Coding mistakes have crashed Python (win2k, Py242, wxPy2621).
Any reports about this ?
I haven't seen any, but I haven't used it much myself.
Some code...
A few changed I'd suggest:
> w1 = wx.Window(self, wx.NewId())
w1 = wx.Window(self)
staline1 = wx.StaticLine(self, wx.NewId(), style=wx.LI_HORIZONTAL)
staline1 = wx.StaticLine(self, style=wx.LI_HORIZONTAL)
b1 = wx.Button(self, wx.NewId(), '&OK')
b2 = wx.Button(self, wx.NewId(), '&Cancel')
Use standard IDs for these:
b1 = wx.Button(self, wx.ID_OK, '&OK')
b2 = wx.Button(self, wx.ID_CANCEL, '&Cancel')
(you can find these under "Stock Items" in the reference manual)
hsizer1.Add(w1, 1, wx.EXPAND | wx.ALL, b)
The consensus seems to be to leave out space around the "|":
hsizer1.Add(w1, 1, wx.EXPAND|wx.ALL, b)
-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