-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserDialogs.py
33 lines (25 loc) · 1.05 KB
/
UserDialogs.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
from tkinter import Tk # from tkinter import Tk for Python 3.x
from tkinter.messagebox import showerror
from tkinter.filedialog import askopenfilename
from tkinter import simpledialog
from numpy.core.defchararray import strip
def loadDescriptionFile():
Tk().withdraw()
filename = askopenfilename(title="Select Automaton Configuration Document", filetypes=(('text files', 'txt'),))
return filename
def receiveUserInput():
Tk().withdraw()
return strip(str(simpledialog.askstring(title="Input Dialog",
prompt="Insert a character:\n Empty character = #")))
def getInput():
while True:
userInput = receiveUserInput()
print('user input: ' + str(userInput))
if userInput == 'None' or userInput is None:
return None
if not userInput == '':
break
showErrorDialog('You need to add a character or a word. To exit, press "X" or "Cancel"')
return userInput
def showErrorDialog(errorMessage):
showerror(title="Error", message=errorMessage)