From: Alex T. <al...@tw...> - 2004-12-13 01:18:00
|
At 14:49 10/12/2004 +0000, Brian Debuire wrote: >Hi there, > >I wonder the possibility of center my apps on the screen no matter its >resolution. >I think someone else asked for this, and now i please for help. > There may well be an easier way, but this does work ... see code below. The default size and position of the window remain what they are set to when you use the Resource Editor - which of course won't always be centered when using different size screens. So the first task is to find the screen size of the system; there may be a direct PythonCard way to do that, but I don't know it - so I used the wx calls. Once you have that, you can simply set self.position accordingly - note the value you set is the top left of the window - so some quick math and you're done. >from wxPython.wx import * > >class MyBackground(model.Background): > > def on_initialize(self, event): > xScreen = wxSystemSettings_GetMetric(wxSYS_SCREEN_X) > yScreen = wxSystemSettings_GetMetric(wxSYS_SCREEN_Y) > xSize, ySize = self.size > xPos = (xScreen-xSize)/2 > yPos = (yScreen-ySize)/2 > self.position = (xPos,yPos) > print self.size, self.position > pass -- Alex. |