Using wxPython in the presence of multiple monitors.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using wxPython in the presence of multiple monitors.

Randall Smith-2
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wxPython in the presence of multiple monitors.

Marc Tompkins
On Thu, May 24, 2018 at 11:22 AM, Randall X Smith <[hidden email]> 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?


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.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wxPython in the presence of multiple monitors.

Matt Newville
In reply to this post by Randall Smith-2
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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wxPython in the presence of multiple monitors.

Dietmar Schwertberger-2
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().

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

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wxPython in the presence of multiple monitors.

Matt Newville
Hi Dietmar,

On Thu, May 24, 2018 at 3:13 PM Dietmar Schwertberger <[hidden email]> wrote:
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().

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.


​Oh, that's very helpful. Thanks very much!

--Matt

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using wxPython in the presence of multiple monitors.

Dietmar Schwertberger-2
In reply to this post by Dietmar Schwertberger-2
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.

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


--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.