Initial Position of wxFrame

How do I get my wvFrame (the main window on my program) to open in the center of the screen? When I use either “Self.SetCenter(wx.Both)” or “self.CenterOnScreen(),” the window open in the lower right corner of the screen and the bottom third is off the screen. If I don’t add either “Self.SetCenter(wx.Both)” or “self.CenterOnScreen(),” to my code, the window opens to the left of the screen with the bottom 10% off screen. IN either case the user needs to move the window to see the entire frame?

Code is attached.

Thank you

Regards,

Russ

math_flash4_boa.py (17.5 KB)

Hi,
you may try to add:

    mathframe.CenterOnScreen()

after the line:
    mathframe = MathFrame(None, -1, "")

or doesn't it work for you?

hth,
vbr

···

2010/3/17 R. P. Hintze <rphintze@earthlink.net>:

How do I get my wvFrame (the main window on my program) to open in the
center of the screen? When I use either "Self.SetCenter(wx.Both)" or
"self.CenterOnScreen()," the window open in the lower right corner of the
screen and the bottom third is off the screen. If I don't add either
"Self.SetCenter(wx.Both)" or "self.CenterOnScreen()," to my code,
the window opens to the left of the screen with the bottom 10% off screen.
IN either case the user needs to move the window to see the entire frame?

Code is attached.

Thank you

Regards,

Russ

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

At the time you call CenterOnScreen the frame has a small default size and so wx is centering based on that size. Later you add items to sizers and call Fit and it becomes much larger and the edges of the frame go off the screen while keeping the same position. Move your call to CenterOnScreen to *after* the size has been set and you'll see results more like what you are expecting.

···

On 3/17/10 2:52 AM, R. P. Hintze wrote:

How do I get my wvFrame (the main window on my program) to open in the
center of the screen? When I use either "Self.SetCenter(wx.Both)" or
"self.CenterOnScreen()," the window open in the lower right corner of
the screen and the bottom third is off the screen. If I don't add either
"Self.SetCenter(wx.Both)" or "self.CenterOnScreen()," to my code, the
window opens to the left of the screen with the bottom 10% off screen.
IN either case the user needs to move the window to see the entire frame?
Code is attached.

--
Robin Dunn
Software Craftsman

Thank you, Vlastimil and Robin. Both suggestions worked.