pismotek-remote/pismotek-remote.py

102 lines
2.9 KiB
Python
Raw Normal View History

2024-05-26 14:47:45 -06:00
#!/bin/env python
2024-05-26 16:58:18 -06:00
import os
2024-05-26 20:49:53 -06:00
import psutil
2024-05-26 14:47:45 -06:00
import PySimpleGUI as sg
2024-05-26 20:49:53 -06:00
import subprocess
import time
2024-05-26 14:47:45 -06:00
"""
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 17:45:50 -06:00
[sg.Push(), sg.Image(logo), sg.Push()],
[sg.Text('This program allows Will B. to remotely control your')],
[sg.Text('computer through the internet')],
[sg.Text('Is Will waiting for you - *right now* - to run this program?')],
2024-05-26 14:47:45 -06:00
]
layout2 = [
2024-05-26 17:45:50 -06:00
[sg.Text('Remote connection started')],
2024-05-26 20:49:53 -06:00
[sg.Text('Allow connection through firewall if asked.')],
[sg.Text('')],
2024-05-26 17:45:50 -06:00
[sg.Text('Click Exit when finished')],
2024-05-26 14:47:45 -06:00
]
layout3 = [
2024-05-26 17:45:50 -06:00
[sg.Text('Please run this program ONLY when Will is waiting for you')],
[sg.Text('Click Exit to continue')],
2024-05-26 14:47:45 -06:00
]
# ----------- 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-')
],
2024-05-26 17:45:50 -06:00
[sg.VPush()],
[sg.Push(), sg.Button('No'), sg.Button('Yes'), sg.Button('Exit', visible=False)]
2024-05-26 14:47:45 -06:00
]
2024-05-26 20:49:53 -06:00
def vncdisconnect():
print("Starting TightVNC")
subprocess.call("tvnserver.exe -run", shell=True)
time.sleep(3)
print("Starting Disconnecting TightVNC")
subprocess.call("tvnserver.exe -controlservice -disconnectall", shell=True)
print("Did we get an error")
time.sleep(15)
# def vncconnect():
# print("This one as well")
# subprocess.call("tvnserver.exe -controlservice -connect remotesupport.pismotek.com", shell=True)
# time.sleep(3)
2024-05-26 17:45:50 -06:00
window = sg.Window('Pismotek', layout, size=(380, 350))
2024-05-26 14:47:45 -06:00
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()
if event in (sg.WIN_CLOSED, 'Exit'):
break
2024-05-26 20:49:53 -06:00
elif event == 'No':
2024-05-26 17:45:50 -06:00
window['-COL1-'].update(visible=False)
2024-05-26 20:49:53 -06:00
layout = int(3)
window['-COL3-'].update(visible=True)
2024-05-26 17:45:50 -06:00
window['No'].update(visible=False)
window['Yes'].update(visible=False)
window['Exit'].update(visible=True)
2024-05-26 20:49:53 -06:00
elif event == 'Yes':
2024-05-26 17:45:50 -06:00
window['-COL1-'].update(visible=False)
2024-05-26 20:49:53 -06:00
layout = int(2)
window['-COL2-'].update(visible=True)
2024-05-26 17:45:50 -06:00
window['No'].update(visible=False)
window['Yes'].update(visible=False)
window['Exit'].update(visible=True)
2024-05-26 20:49:53 -06:00
# window.perform_long_operation(vncdisconnect, '-VNCCONNECT-')
# elif event == '-VNCCONNECT-':
# print("Woot")
2024-05-26 14:47:45 -06:00
window.close()