Running on
- - Linux
- - wxGTK2 2.4.2.4u
- - python 2.3.2.
When I create a frame with no parent, using the default position, that frame
always appears in the center of the display, regardless of where the WM would
have put it.
Child windows on the other hand, do seem to be positioned by the WM.
Quite by chance I discovered that specifying pos=wx.Point(-2,-2) for the
parentless frame, results in the WM controlling it's position (which is what
I want!).
As the subject line says, is this safe, legal, portable? (I don't have a
windoze or mac box to check.) Or is ther a better way to let the WM manage
the initial position of the topwindow?
Thanks,
Nigel
#!/usr/bin/env python
"""Run me with
* no arg, for DefaultPosition (starts in center of display)
* -1 as arg, same as no arg
* a +ve numeric arg, to start at specified pos
* a -ve number, to let WM manage the topwindow's initial position"""
import wx
import sys
somewhere = wx.DefaultPosition
class App(wx.App):
def OnInit(self):
top = wx.Frame(None, -1, "Top", pos=somewhere, size=(400,300))
child = wx.Frame(top, -1, "child", size=(400,300))
child2 = wx.Frame(top, -1, "child2", size=(400,300))
self.SetTopWindow(top)
top.Show()
child.Show()
child2.Show()
return True
if __name__ == '__main__':
if len(sys.argv) > 1:
i = int(sys.argv[1])
somewhere = wx.Point(i,i)
app = App(0)
app.MainLoop()
- --
Nigel Rowe
rho@swiftdsl.com.au