I haven’t seen any discussion about controlling the location of wxPython apps on workstations that have multiple monitors. When invoking the wxPython app, the main frame always seems to appear on the main monitor, which may be different from the monitor you invoked it from; this can be disconcerting and easy to miss (e.g., I have 3 monitors with one off to the side; the app always appears on the one off to the side when I invoke it).
Is there any way to specify, e.g., the “current” monitor as the desired startup location, i.e., the one you invoked the app from?
(We’re in the Ubuntu 14 environment, BTW, though I assume this is an issue in all environments.)
Thanks in advance for any ideas or suggestions.
On closing, do a MyFrame.GetScreenPosition() and MyFrame.GetSize() and save
the values to your app's config file; on startup, do a
MyFrame.SetPosition() and MyFrame.SetSize() before MyFrame.Show().
Check for sanity - if it's the first run, or if the screen layout has
changed, provide default values and use them instead.
···
On Thu, May 24, 2018 at 11:22 AM, Randall X Smith <randallxsmith@gmail.com> wrote:
I haven't seen any discussion about controlling the location of wxPython
apps on workstations that have multiple monitors. When invoking the
wxPython app, the main frame always seems to appear on the main monitor,
which may be different from the monitor you invoked it from; this can be
disconcerting and easy to miss (e.g., I have 3 monitors with one off to the
side; the app always appears on the one off to the side when I invoke it).
Is there any way to specify, e.g., the "current" monitor as the desired
startup location, i.e., the one you invoked the app from?
Hi Randall,
I don’t know of a way to specify Monitor, but you can specify the Position of a Frame with Frame.SetPosition().
I use wxPython apps with multiple monitors all the time. At one workstation controlling my experimental station, I want wxApp # 1 to be on the left, wxApp #2 to be in the middle and wxApp #3 and #4 to be on the right (yes, all three monitors are mostly filled with wxPython apps). As it turns out, the center monitor is the “main” monitor.
Frame.SetPosition((xpos, ypos)) uses absolute coordinates, so to put an App on the left monitor, I have a basic app like this
class SomeApp(wx.App):
def __init__(self, position, maximize=True, **kws):
self.position = position
self.maximize = maximize
wx.App.__init__(self, **kws)
def createApp(self):
frame = MainFrame()
frame.SetPosition(self.position)
if self.maximize:
frame.Maximize()
frame.Show()
self.SetTopWindow(frame)
def OnInit(self):
self.createApp()
return True
if name == ‘main’:
app = SomeApp(position=(-1800, 50), maximize=True) # ← fill the left hand monitor
app.MainLoop()
HTH,
–Matt
···
On Thu, May 24, 2018 at 1:25 PM Randall X Smith randallxsmith@gmail.com wrote:
I haven’t seen any discussion about controlling the location of wxPython apps on workstations that have multiple monitors. When invoking the wxPython app, the main frame always seems to appear on the main monitor, which may be different from the monitor you invoked it from; this can be disconcerting and easy to miss (e.g., I have 3 monitors with one off to the side; the app always appears on the one off to the side when I invoke it).
Is there any way to specify, e.g., the “current” monitor as the desired startup location, i.e., the one you invoked the app from?
(We’re in the Ubuntu 14 environment, BTW, though I assume this is an issue in all environments.)
Thanks in advance for any ideas or suggestions.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Use code like this to find the coordinate ranges per monitor:
for d in range\(wx\.Display\.GetCount\(\)\):
display = wx\.Display\(d\)
client\_area = display\.ClientArea
Unfortunately that does not help the OP to identify where the application was launched from.
It may help to implement a command line argument, though.
Regards,
Dietmar
···
On 5/24/2018 9:21 PM, Matt Newville wrote:
I don't know of a way to specify Monitor, but you can specify the Position of a Frame with Frame.SetPosition().
I have to correct myself: Probably it would be possible to use the posted code to identify the display where the mouse pointer currently is located and then center the new window on that one. This is not a 100% solution, but probably good enough.
Regards,
Dietmar
···
On 5/24/2018 10:12 PM, Dietmar Schwertberger wrote:
Unfortunately that does not help the OP to identify where the application was launched from.
It may help to implement a command line argument, though.