From f486be96eaec4a721feb65f9fd826d5a082c2392 Mon Sep 17 00:00:00 2001 From: "Richard Horton (hortonr6)" Date: Wed, 1 Nov 2017 12:18:19 +0000 Subject: [PATCH] Created GUITest1 Experimenting with different GUI elements, can be ignored by anyone not working on the GUI --- GUITesting/GUITest1 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 GUITesting/GUITest1 diff --git a/GUITesting/GUITest1 b/GUITesting/GUITest1 new file mode 100644 index 0000000..b66d6b0 --- /dev/null +++ b/GUITesting/GUITest1 @@ -0,0 +1,28 @@ +import random +import tkinter as tk + +root = tk.Tk() +userInput = tk.Entry(root) +userInput.pack() + +greetings = ['hola', 'hello', 'hi', 'hey!', 'hey'] +question = ['how are you?', 'how are you doing?', 'how are you', 'how are you doing'] +responses = ['Okay', "I'm fine"] +huh = "I did not understand what you said" + +def cb(event): + userText = userInput.get() + userText = userText.lower() + if userText in greetings: + botText = random.choice(greetings) + elif userText in question: + botText = random.choice(responses) + else: + botText = huh + output.config(text=botText) + +userInput.bind("", cb) +output = tk.Label(root, text='') +output.pack() + +tk.mainloop()