Create Your Own Python Chat Bot GUI
In this article I will show you how to build a graphical user interface (GUI) using the Python programming language that you can use for a chat bot. So no, this won’t be an actual chat bot, I will be focusing on just the graphical user interface components. This is a good exercise to get familiar with creating GUI’s using Python. The graphical user interface (GUI) is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicators such as primary notation, instead of text-based user interfaces, typed command labels or text navigation. -wikipedia
If you are interested in creating a chat bot please check out my other two articles Build Your Own Chat Bot Using Python and Build Your Own Smart AI Chat Bot Using Python & Machine Learning. Also, if you find this article to be useful or helpful, please leave a few claps!
If you prefer not to read this article and would like a video representation of it, you can check out the YouTube Video . It goes through everything in this article with a little more detail and will help make it easy for you to start programming even if you don’t have the programming language Python installed on your computer. Or you can use both as supplementary materials for learning!
Let’s start programming !
The first thing that I like to do before writing a single line of code is to put in a description in comments of what the code does. This way I can look back on my code and know exactly what it does.
#Description: This is a chat bot GUI
Next I will load the library that I will need to create this GUI.
#Import the library
from tkinter import *
Next I will create the tkinter object. This represents the parent window.
root = Tk()
Now, I will give the Window a title, a shape, and make it such that it can’t be resized.
Let’s create the main menu.
main_menu = Menu(root)
Add some sub menus to the main menu.
# Create the submenu
file_menu = Menu(root)
# Add commands to submenu
#Add the rest of the menu options to the main menu
Create a window for the conversation and place it on the parent window.
chatWindow = Text(root, bd=1, bg="black", width="50", height="8", font=("Arial", 23), foreground="#00ffff")chatWindow.place(x=6,y=6, height=385, width=370)
Create the text area where the messages will be entered and place it on the parent window.
messageWindow = Text(root, bd=0, bg="black",width="30", height="4", font=("Arial", 23), foreground="#00ffff")
messageWindow.place(x=128, y=400, height=88, width=260)
Create a scroll bar and place it on the parent window.
scrollbar = Scrollbar(root, command=chatWindow.yview, cursor="star")
Create a button to send the message and place it on the parent window.
Button= Button(root, text="Send", width="12", height=5,
bd=0, bg="#0080ff", activebackground="#00bfff",foreground='#ffffff',font=("Arial", 12))
Button.place(x=6, y=400, height=88)
Run the main loop.
That’s it, we are done creating this program !
If you are also interested in reading more on Python one of the fastest growing programming languages that many companies and computer science departments use then I recommend you check out the book Learning Python written by Mark Lutz’s. Also you can see the full code in this article here.
Thanks for reading this article I hope it’s helpful to you all! If you enjoyed this article and found it helpful please leave some claps to show your appreciation. Keep up the learning, and if you like Python, machine learning, mathematics, computer science, programming or algorithm analysis, please visit and subscribe to my YouTube channels (randerson112358 & compsci112358 ).