-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.py
71 lines (65 loc) · 2.21 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# caesarplus Demo
# Owner: awesomelewis2007
# Co-Owner: WolfieBoy
import sys
def demo():
import PySimpleGUI as sg
import sys
sg.theme('black') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text('Enter a piece of data to corrupt')],
[sg.Text('Data:'), sg.InputText()],
[sg.Button('Ok'), sg.Button('Quit')] ]
# Create the Window
window = sg.Window('caesarplus Demo', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Quit': # if user closes window or clicks cancel
window.close()
sys.exit()
if event == 'Ok':
window.close()
break
return values[0]
def output_message(values):
import caesarplus
import PySimpleGUI as sg
import sys
key,output = caesarplus.encode(values)
sg.theme('Green') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text("Command completed successfully.")],
[sg.Text("Key:"+str(key))],
[sg.Text("Output:"+output)],
[sg.Button('Ok'), sg.Button('Quit')] ]
# Create the Window
window = sg.Window('caesarplus Demo', layout)
# Event Loop to process "events" and get the "values" of the inputs
print(key)
print(output)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Quit' or event == 'Ok': # if user closes window or clicks cancel
break
window.close()
def error(value):
import PySimpleGUI as sg
import sys
sg.theme('black') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text("Error in demo module")],
[sg.Text(value)],
]
# Create the Window
window = sg.Window('Error', layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Quit' or event == 'Ok': # if user closes window or clicks cancel
break
window.close()
value = demo()
if value == "":
error("Please enter data to encrypt!")
sys.exit()
output_message(value)