Reputation: 21
How do I run an external application out of my python application AND display the external program on a second screen? Unfortunately, my main GUI and the external GUI do not fit on one single screen.
So far I used the subprocess module and Popen constructor but I feel like desired functionality is not provided.
I considered to incorporate the STARTUPINFO ( https://docs.python.org/2/library/subprocess.html#windows-popen-helpers ) helper in subprocess but I did not find options seeming to fit my problem.
The external application is written in C++ and C#, if that is of any interest.
Thanks everybody!
Edit: I use Windows 7 and a dual monitor setup (to be exact laptop + monitor).
Second Edit: I found a possible answer on my own:
from win32api import GetSystemMetrics
import win32gui
import win32con
window = win32gui.GetForegroundWindow() # retrieves the freshly opened window
win32gui.MoveWindow(window, GetSystemMetrics(0), 0, 0, 0, True) # translates it about the main monitor width
win32gui.ShowWindow(window, win32con.SW_MAXIMIZE) # maximizes the window
I did not answer myself, since this is not exactly what I asked for. For my needs the solution is sufficient, though I'd be happy for further suggestions.
Upvotes: 2
Views: 4309
Reputation: 328624
I don't know a good way in Windows to force the OS to place windows in a certain way. There are external tools which may help: https://superuser.com/questions/250334/utility-to-lock-window-position-size-of-windows-in-windows-7
The next question is how to move the window to the second monitor. That depends on how you set up your desktop. The usual mode is "spanning desktop" where you get a virtual desktop and each monitor displays parts of it. The means one monitor will have a top/left edge at '0, 0' and the other at `1920, 0'. To place a window on the second one, you simply need to set the top left corner of the window to '1920, 0'.
On systems with X11, most programs support the option -geometry
which makes this very simple but on Windows, your application needs special support for this or you need external tools (see the link above).
Upvotes: 1