Sub Window


A way to add additional windows, which can be hidden and shown.

SubWindow

from appJar import gui 

def launch(win):
    app.showSubWindow(win)

app=gui()

# these go in the main window
app.addButtons(["one", "two"], launch)

# this is a pop-up
app.startSubWindow("one", modal=True)
app.addLabel("l1", "SubWindow One")
app.stopSubWindow()

# this is another pop-up
app.startSubWindow("two")
app.addLabel("l2", "SubWindow Two")
app.stopSubWindow()

app.go()

Definition of SubWindows happens in the same part of the code as the rest of the GUI, but they default to being hidden.
Both SubWindows and the main window can be shown and hidden - this is usually done through button presses.

Start/Stop Sub Windows


Show/Hide Sub Windows


def login(btn):
    app.hideSubWindow("Login")
    app.show()

app.startSubWindow("Login")
app.addLabel("l2", "Login Window")
app.addButton("SUBMIT", login)
app.stopSubWindow()

app.go(startWindow="Login")

It's useful to be able to create a button that stops a SubWindow:
If you define a button, that calls .hideSubWindow() or .destroySubWindow(), and give it the same name as the SubWindow, then it will hide/destroy the SubWindow, and call any associated .stopFunction().

app.startSubWindow("Demo")
app.addLabel("l1", "Press the button to close this window")
# set the button's name to match the SubWindow's name
app.addNamedButton("CLOSE", "Demo", app.hideSubWindow)
app.stopSubWindow()

Set Sub Windows


Note, all functions available on the main window are also available on SubWindows.
Simply call those functions after starting a SubWindow.

app.startSubWindow("one", modal=True)
app.setBg("orange")
app.setSize(400, 400)
app.setTransparency(25)
app.setStopFunction(checkDone)
app.addLabel("l1", "In sub window")
app.stopSubWindow()