All of the tools needed for a multiscreen application have been provided in this manual already: tools to import multiple screens, tools to run multiple screens, tools to hide and show screens. These have all been compiled together into this section for ease of reference.
The process to design the secondary screen is identical to designing the main screen - except under GUI Properties, the dropdown for 'Window Hierarchy' must be set to 'Child Window'
Import: Just as you imported your first GUI, you can import the second one the same way.
from gui import gui
from secondScreen import secondScreen
Do so for all GUI files
Run: Call the run() method on the main screen only. The run statement must be the final line of the file.
gui.run()
In total, the final parent script would look like this
from gui import gui
from secondScreen import secondScreen
# all other code goes here
gui.run()
Call the hide() and show() methods on each screen to open and close them.
At the moment, both screens would open simultaneously. To create windows that appear and disappear at will - otherwise known as a popup - the hide/show functions must be used. The easiest way to implement this is to use a button. Create a button in GUI Pie that runs an event. For the sake of this example, this will be called "runPopup"
def runPopup(name):
secondScreen.show()
Then create a button on the second screen to close it. For this example, the function attached to that button will be called "close"
def close(name):
secondScreen.hide()
Adding these all together forms
from gui import *
from secondScreen import *
def close(name):
secondScreen.hide()
def runPopup(name):
secondScreen.show()
# add all other code here
secondScreen.hide()
gui.run()
Accessing elements works the same way as it would with a single screen. Use the name of the screen, followed by .<widgetName>. This allows you to access elements from any screen of choice. E.g you could access two elements both named Label1, one with gui.Label1, and one with secondScreen.Label1
To add a second screen, import it with the import statement at the top. There is no need to call the run method on any secondary screen. To manipulate it, use the hide and show functions.