Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<Return>", cb) | ||
output = tk.Label(root, text='') | ||
output.pack() | ||
|
||
tk.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<Return>", cb) | ||
output = tk.Label(root, text='') | ||
output.pack() | ||
|
||
tk.mainloop() |