Program Works
This commit is contained in:
parent
dcc55d8aee
commit
21b4c6bae4
@ -66,26 +66,11 @@ def build_layout():
|
||||
sg.Column(layout3, visible=False, key='-COL3-')
|
||||
],
|
||||
[sg.VPush()],
|
||||
[sg.Push(), sg.Button('No'), sg.Button('Yes'), sg.Button('Exit', visible=False)]
|
||||
[sg.Push(), sg.Button('No'), sg.Button('Yes', focus=True), sg.Button('Exit', visible=False)]
|
||||
|
||||
]
|
||||
return layout
|
||||
|
||||
|
||||
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)
|
||||
|
||||
def tab_no(window):
|
||||
""" handle displaying the no tab/column """
|
||||
window['-COL1-'].update(visible=False)
|
||||
@ -94,14 +79,14 @@ def tab_no(window):
|
||||
window['Yes'].update(visible=False)
|
||||
window['Exit'].update(visible=True)
|
||||
|
||||
def tab_yes(window):
|
||||
def tab_yes(window, tvn_mode, tvn_state):
|
||||
""" handle displaying the yes tab/column"""
|
||||
window['-COL1-'].update(visible=False)
|
||||
window['-COL2-'].update(visible=True)
|
||||
window['No'].update(visible=False)
|
||||
window['Yes'].update(visible=False)
|
||||
window['Exit'].update(visible=True)
|
||||
# window.perform_long_operation(vncdisconnect, '-VNCCONNECT-')
|
||||
window.perform_long_operation(lambda : vncconnect(tvn_mode, tvn_state), '-VNCCONNECT-')
|
||||
|
||||
def tvn_get_state():
|
||||
""" get current state of tvnserver - retrun stopped if does not exist """
|
||||
@ -118,18 +103,34 @@ def get_tvnserver_info():
|
||||
application running - can use as is
|
||||
application stopped - need to start application
|
||||
"""
|
||||
mode = "application"
|
||||
mode = "-controlapp"
|
||||
state = tvn_get_state()
|
||||
if state == "running":
|
||||
mode = "service"
|
||||
mode = "-controlservice"
|
||||
elif "tvnserver.exe" in (p.name() for p in psutil.process_iter()):
|
||||
state = "running"
|
||||
return mode, state
|
||||
|
||||
def vncconnect(tvn_mode, tvn_state):
|
||||
""" start tvnserver if needed, kill any connection and attempt to connect """
|
||||
app = resource_path("tvnserver.exe")
|
||||
# print(tvn_mode, tvn_state, app)
|
||||
if tvn_state == "stopped":
|
||||
print("Starting Service")
|
||||
# subprocess.call([app, "-run"], shell=True)
|
||||
sg.execute_command_subprocess(app, *["-run"], wait=False)
|
||||
time.sleep(3)
|
||||
# print("Disconnectiong")
|
||||
sg.execute_command_subprocess(app, *[tvn_mode, "-disconnectall"], wait=False)
|
||||
time.sleep(3)
|
||||
# print("Connecting")
|
||||
sg.execute_command_subprocess(app, *[tvn_mode, "-connect 192.168.0.94"], wait=False)
|
||||
|
||||
def main():
|
||||
tvn_mode, tvn_state = get_tvnserver_info()
|
||||
icon_file=resource_path('remotedesktop.ico')
|
||||
layout = build_layout()
|
||||
window = sg.Window('Pismotek', layout, size=(380, 350))
|
||||
window = sg.Window('Pismotek', layout, size=(380, 350), icon=icon_file)
|
||||
while True:
|
||||
event, values = window.read()
|
||||
if event in (sg.WIN_CLOSED, 'Exit'):
|
||||
@ -137,8 +138,8 @@ def main():
|
||||
elif event == 'No':
|
||||
tab_no(window)
|
||||
elif event == 'Yes':
|
||||
tab_yes(window)
|
||||
window.close()
|
||||
tab_yes(window, tvn_mode, tvn_state)
|
||||
# window.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user