2024-05-26 14:47:45 -06:00
|
|
|
#!/bin/env python
|
|
|
|
|
2024-05-26 16:58:18 -06:00
|
|
|
import os
|
2024-05-26 14:47:45 -06:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
|
|
|
"""
|
|
|
|
Pismotek-Remote - Remote Desktop Application
|
|
|
|
|
|
|
|
To "swap out" a portion of a window, use a Column element for that portion. Add multiple Columns
|
|
|
|
on the same row and make only 1 of them active at a time
|
|
|
|
"""
|
|
|
|
|
2024-05-26 16:58:18 -06:00
|
|
|
def resource_path(relative_path):
|
|
|
|
""" Get absolute path to resource, works for dev and for PyInstaller """
|
|
|
|
try:
|
|
|
|
base_path = sys._MEIPASS
|
|
|
|
except Exception:
|
|
|
|
base_path = os.path.abspath(".")
|
|
|
|
return os.path.join(base_path, relative_path)
|
|
|
|
|
|
|
|
|
2024-05-26 17:01:07 -06:00
|
|
|
logo = resource_path("logo.png")
|
2024-05-26 16:58:18 -06:00
|
|
|
|
2024-05-26 14:47:45 -06:00
|
|
|
# ----------- Create the 3 layouts this Window will display -----------
|
|
|
|
layout1 = [
|
2024-05-26 16:58:18 -06:00
|
|
|
[
|
|
|
|
sg.Image(logo),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
sg.Text('This is layout 1'),
|
|
|
|
],
|
2024-05-26 14:47:45 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
layout2 = [
|
|
|
|
[sg.Text('This is layout 2')],
|
|
|
|
]
|
|
|
|
|
|
|
|
layout3 = [
|
|
|
|
[sg.Text('This is layout 3')],
|
|
|
|
]
|
|
|
|
|
|
|
|
# ----------- Create actual layout using Columns and a row of Buttons
|
|
|
|
layout = [
|
|
|
|
[
|
|
|
|
sg.Column(layout1, key='-COL1-'),
|
|
|
|
sg.Column(layout2, visible=False, key='-COL2-'),
|
|
|
|
sg.Column(layout3, visible=False, key='-COL3-')
|
|
|
|
],
|
|
|
|
[
|
|
|
|
sg.Button('1'),
|
|
|
|
sg.Button('2'),
|
|
|
|
sg.Button('3'),
|
|
|
|
sg.Button('Exit')
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
window = sg.Window('Swapping the contents of a window', layout)
|
|
|
|
|
2024-05-26 16:58:18 -06:00
|
|
|
|
2024-05-26 14:47:45 -06:00
|
|
|
layout = 1 # The currently visible layout
|
|
|
|
while True:
|
|
|
|
event, values = window.read()
|
|
|
|
print(event, values)
|
|
|
|
if event in (sg.WIN_CLOSED, 'Exit'):
|
|
|
|
break
|
|
|
|
elif event in '123':
|
|
|
|
window[f'-COL{layout}-'].update(visible=False)
|
|
|
|
layout = int(event)
|
|
|
|
window[f'-COL{layout}-'].update(visible=True)
|
|
|
|
window.close()
|
|
|
|
|