From 610783a632f621e05f6bd205f724c1f354e21a0b Mon Sep 17 00:00:00 2001 From: Richard Horton Date: Thu, 2 Nov 2017 15:16:23 +0000 Subject: [PATCH] Renamed some GUI files to include .py extension --- GUITesting/GUITest1.py | 28 ++++++++++++++++++++++++++++ GUITesting/GUITest2.py | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 GUITesting/GUITest1.py create mode 100644 GUITesting/GUITest2.py diff --git a/GUITesting/GUITest1.py b/GUITesting/GUITest1.py new file mode 100644 index 0000000..b66d6b0 --- /dev/null +++ b/GUITesting/GUITest1.py @@ -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() diff --git a/GUITesting/GUITest2.py b/GUITesting/GUITest2.py new file mode 100644 index 0000000..57361eb --- /dev/null +++ b/GUITesting/GUITest2.py @@ -0,0 +1,25 @@ +import random +import tkinter as tk +import Get_Functions as GF + +root = tk.Tk() +root.geometry("150x150") + +lblNameAsk = tk.Label(root, text="What is your name?") +lblNameAsk.pack() + +userInput = tk.Entry(root) +userInput.pack() + +def cb(event): + userText = userInput.get() + userName = GF.getName(userText) + userName = userName.title() + botText = "Hello " + userName + ", it's nice to meet you" + output.config(text=botText) + +userInput.bind("", cb) +output = tk.Label(root, text='') +output.pack() + +tk.mainloop()