I have 2 monitors and I have a popup that I would like to be able to drag to a different screen and keep the main project on the other display. However, the popup dragging is constrained to the display that the project is displayed on.
Is there a way to allow the popup to be moved to the second monitor?
Ok, so not using a popup anymore, but I have a full-screen view of the window I want on another page, but I have no menu bar on the top to close it. I assume that the menu bar follows project properties, and that's why it's hidden?
So, circling back to this again. I have one main client that will have multiple screens, but not all clients will have the same number of displays. The easy solution would be to allow popups to be dragged out of the vision client application and then they can be moved to whatever monitors are available.
If that's not an option, I might have to figure out how to script it to find how many monitors are available and provide a way to specify which monitor to open it on.
Well, not sure that it really matters in this case. The main window will be locked to fullscreen and I think I'll just use a button to open a maximized window that can be moved wherever the user wants.
#base desktop handle
dHandle = 'Desktop '
#get handles
handles = system.gui.getDesktopHandles()
#no desktops open yet
if len(handles) == 0:
nextIndex = 0
#other desktops open
else:
#get list of the desktop indicies from the handle
openDesktopIndicies = [int(handle.replace(dHandle,'')) for handle in handles]
#get max index and increment for next index
nextIndex = max(openDesktopIndicies)+1
#get the current window
window = system.nav.getCurrentWindow()
#open new desktop with current window
system.gui.openDesktop(handle=dHandle+str(nextIndex),windows = [window]).setAlwaysOnTop(False)
What I'm running into now is that with the project open in fullscreen mode, opening a new desktop is in fullscreen mode. How can I make it windowed mode for the new desktops?
Thinking I could do something with this script after opening the new desktop?
from javax.swing import JFrame
window = system.gui.getParentWindow(event)
while not isinstance(window, JFrame):
window = window.getParent()
if window.isUndecorated():
# Switch to windowed mode.
window.dispose()
window.setUndecorated(False)
window.setExtendedState(JFrame.NORMAL)
# Restore previous window size and location, if available.
try:
normalW = event.source.getClientProperty('normalW')
normalH = event.source.getClientProperty('normalH')
normalX = event.source.getClientProperty('normalX')
normalY = event.source.getClientProperty('normalY')
window.setSize(normalW, normalH)
window.setLocation(normalX, normalY)
except:
pass
window.setVisible(True)
else:
# Store window size and location for restore.
event.source.putClientProperty('normalW', window.size.width)
event.source.putClientProperty('normalH', window.size.height)
event.source.putClientProperty('normalX', window.x)
event.source.putClientProperty('normalY', window.y)
# Switch to full screen mode.
window.dispose()
window.setUndecorated(True)
window.setExtendedState(JFrame.MAXIMIZED_BOTH)
window.setVisible(True)
Just not sure how to use this with the new desktop and window
Since I already have the JFrame from system.gui.openDesktop(), I should be able to pass that directly to the function that I've placed in the project script library.
#base desktop handle
dHandle = 'Desktop '
#get handles
handles = system.gui.getDesktopHandles()
#no desktops open yet
if len(handles) == 0:
nextIndex = 0
#other desktops open
else:
#get list of the desktop indicies from the handle
openDesktopIndicies = [int(handle.replace(dHandle,'')) for handle in handles]
#get max index and increment for next index
nextIndex = max(openDesktopIndicies)+1
#get the current window
window = system.nav.getCurrentWindow()
#open new desktop with current window
desktop = system.gui.openDesktop(handle=dHandle+str(nextIndex),windows = [window]).setAlwaysOnTop(False)
Navigation.desktopSwapToWindowedMode(desktop)
#pass desktop JFrame directly
def desktopSwapToWindowedMode(desktop):
from javax.swing import JFrame
window = desktop
#skip this because we already have the JFrame
# window = system.gui.getParentWindow(event)
# while not isinstance(window, JFrame):
# window = window.getParent()
if window.isUndecorated():
# Switch to windowed mode.
window.dispose()
window.setUndecorated(False)
window.setExtendedState(JFrame.NORMAL)
# Restore previous window size and location, if available.
try:
normalW = event.source.getClientProperty('normalW')
normalH = event.source.getClientProperty('normalH')
normalX = event.source.getClientProperty('normalX')
normalY = event.source.getClientProperty('normalY')
window.setSize(normalW, normalH)
window.setLocation(normalX, normalY)
except:
pass
window.setVisible(True)
else:
# Store window size and location for restore.
event.source.putClientProperty('normalW', window.size.width)
event.source.putClientProperty('normalH', window.size.height)
event.source.putClientProperty('normalX', window.x)
event.source.putClientProperty('normalY', window.y)
# Switch to full screen mode.
window.dispose()
window.setUndecorated(True)
window.setExtendedState(JFrame.MAXIMIZED_BOTH)
window.setVisible(True)
but I get an error at the first if statement
File "<module:Navigation>", line 146, in desktopSwapToWindowedMode
AttributeError: 'NoneType' object has no attribute 'isUndecorated'
I'm getting an error now when I try to swap the window back to fullscreen mode. It says event doesn't exist.
Button script:
desktop = Nav.getParentDesktop(system.gui.getParentWindow(event))
if Nav.desktopIsWindowedMode(desktop):
Nav.desktopSwapDisplayMode(desktop)
else:
Nav.desktopSwapDisplayMode(Nav.openNewDesktop())
Nav scripts:
def getParentDesktop(window):
'''
Get the parent desktop JFrame for supplied window.
Args:
window (obj) : window on the desktop
Returns:
desktop (JFrame) : window's parent desktop JFrame
'''
while not isinstance(window, JFrame):
window = window.getParent()
desktop = window
return desktop
def desktopIsWindowedMode(window):
'''
Determine if a desktop is in windowed mode or not.
Args:
window (ovj) : Window to determine if the parent desktop is in fullscreen or windowed mode
Returns:
isWindowMode (BOOL) : True if desktop is in window mode
'''
#undecorated = fullscreen
return not Nav.getParentDesktop(window).isUndecorated()
def openNewDesktop():
'''
Open a new desktop window
Args:
n/a
Returns:
desktop (JFrame) : newly opened desktop
'''
#base desktop handle
dHandle = 'Desktop '
#get handles
handles = system.gui.getDesktopHandles()
#no desktops open yet
if len(handles) == 0:
nextIndex = 0
#other desktops open
else:
#get list of the desktop indicies from the handle
openDesktopIndicies = [int(handle.replace(dHandle,'')) for handle in handles]
#get max index and increment for next index
nextIndex = max(openDesktopIndicies)+1
#get the current window
window = system.nav.getCurrentWindow()
#open new desktop with current window
desktop = system.gui.openDesktop(handle=dHandle+str(nextIndex),windows = [window, 'Nav'])
desktop.setAlwaysOnTop(False)
return desktop
def desktopSwapDisplayMode(desktop):
'''
Swap the selected "desktop" to windowed/fullscreen mode from fullscreen/windowed mode.
Args:
desktop (JFrame) : JFrame of desktop to be swapped to windowed mode.
Returns:
n/a
'''
window = desktop
if window.isUndecorated():
# Switch to windowed mode.
window.dispose()
window.setUndecorated(False)
window.setExtendedState(JFrame.NORMAL)
# Restore previous window size and location, if available.
try:
normalW = event.source.getClientProperty('normalW')
normalH = event.source.getClientProperty('normalH')
normalX = event.source.getClientProperty('normalX')
normalY = event.source.getClientProperty('normalY')
window.setSize(normalW, normalH)
window.setLocation(normalX, normalY)
except:
pass
window.setVisible(True)
else:
# Store window size and location for restore.
event.source.putClientProperty('normalW', window.size.width)
event.source.putClientProperty('normalH', window.size.height)
event.source.putClientProperty('normalX', window.x)
event.source.putClientProperty('normalY', window.y)
# Switch to full screen mode.
window.dispose()
window.setUndecorated(True)
window.setExtendedState(JFrame.MAXIMIZED_BOTH)
window.setVisible(True)