How correct GetSize from wxglade xrc files ?

newbie question:
I can't get my default sizes to load from a xrc file generated by wxglade. :frowning:

Even if I check the checkbox in the Common Tab of the Properties Dialog of the wxFrame, it shows a minuscule WxFrame that I have to resize in order to see it's contents. I have read several e-mails that talk about the same problem in the mailing list, but I can't figure it out. Even after reading and rereading http://www.wxwidgets.org/wiki/index.php/WxSizer#Window_size_is_very_small .

I am really surprised that the WxFrame does not GetSize() of the value in <size>value</size>

In other words, I simply want to get the size property from a Wxframe to get the default size. In code, I want to get the value from the xrc file "<size>400, 400</size>" from self.main_frame = self.res.LoadFrame(None, "frame_1"), in order to do a self.main_frame.SetSize(), since it does not happen by default.

I attach all the files of a small test case I wrote.
The wxglade file test.wxg
The files test.xrc and test_with_xrc.py that instance a very small frame, be sure to look for it, it's small, but there. I instanced a shell in it so you can see what's around.
The test_with_python.py that was generated from the same glade file as xrc that actually does what I expect: self.SetSize((314, 351))

Sorry for the newbie question ....

test.wxg (665 Bytes)

test.xrc (403 Bytes)

test_with_python.py (1007 Bytes)

test_with_xrc.py (588 Bytes)

Daniel Kornhauser wrote:

newbie question:
I can't get my default sizes to load from a xrc file generated by wxglade. :frowning:

Even if I check the checkbox in the Common Tab of the Properties Dialog of the wxFrame, it shows a minuscule WxFrame that I have to resize in order to see it's contents. I have read several e-mails that talk about the same problem in the mailing list, but I can't figure it out. Even after reading and rereading wxSizer - WxWiki .

I am really surprised that the WxFrame does not GetSize() of the value in <size>value</size>

It does. This code is in the Frame resource handler class:

     if (HasParam(wxT("size")))
         frame->SetClientSize(GetSize(wxT("size"), frame));

The problem you are running in to is that the resource handler for sizers will call Fit with the parent window. So since you have an empty sizer and it is Fitting the frame to that empty size, it gets resized real small.

If you want the frame to have a certain size, there are a couple ways to do it from XRC. First you can just create an empty frame and set it's size property. Second, you can give the frame a panel (that is not in a sizer) and set the size on the panel. Then other content (with sizers if you want) can be children of the panel. Finally, you can just call SetSize yourself with some arbitrary size after loading the frame.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!