After 40 minutes of experimenting, I finally got it to work. The trick
was to add the following:
sizeMin = sizer.CalcMin()
self.SetSizeHints(sizeMin.width, sizeMin.height)
... before ...
sizer.Fit(self)
It seems to me that this should be easier, if not automatic. If a size
for an "unknown" control is not specified in the XRC file, then it seems
reasonable to me that the container panel would be set to the size of
the containing control when AttachUnknownControl() is called. Does this
sound like a reasonable request for a change to the XRC module?
Attached is my final solution. I'll look into adding it to wxPyWiki.
Matthew
,test.py (1.87 KB)
,test.xrc (2.89 KB)
···
-----Original Message-----
From: Matthew Thornley
Sent: Friday, May 23, 2003 2:04 PM
To: wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Size of controls and XRC
Thanks Robin, I'm a step closer.
The call to sizer.SetItemMinSize() gets the "Unknown" controls to size
correctly. Yay!
However, the dialog still sizes as if the controls are huge. Boo!
Any idea what I need to do to get the dialog box to size correctly?
I've attached my modified code.
BTW, XRCCTRL(self, idText) didn't return the wxPanel container of the
control. It returned the control itself! Instead, I get the container
by calling ctrl.GetParent().
I haven't had time to try a panel or frame.
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Friday, May 23, 2003 9:14 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Size of controls and XRC
Matthew Thornley wrote:
The attached script and XRC file demonstrates something that I can't figure
out how to do. I'm attaching my own control to an "Unknown" control using
AttachUnknownControl(). I want the control have it's own natural default
size... in other words, I don't want to set the size (or more specifically,
the height). I can hard code the size of the control in the XRC file, but
then the size won't be the default size on some operating systems. I can
change the size of the control after calling AttachUnknownControl(), but
AutoLayout doesn't seem to take the new size into consideration.
The thing to know about the "unknown" type is that there is actually a
panel created as a placeholder when the resource is loaded, and then
when you call AttachUnknownControl the new control is made a child of
that panel. So you have to take that extra window into account when
trying to set sizes and such. You might try something like this:
xctrl = XRCCTRL(self, idText)
xctrl.SetSize(ctrl.GetBestSize())
self.GetSizer().SetItemMinSize(xctrl,
xctrl.GetSize().width,
xctrl.GetSize().height)
The sizer will probably need a bit more tweaking though to get it to
work right...
Control 2) Height is too small
Control 3) Height is WAY to big
I'm not sure why #3 is so huge, on wxGTK all the buttons are real close
to the right size. Does it still do this if you use a panel and frame
instead of a dialog?
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org