# Python GUI Multiplication Table

By | March 30, 2020

Topic: Multiplication Table Python GUI Program

## Python GUI Multiplication Table

```# Python GUI program Multiplication Table
# Input a number and show its multiplication table
# from 1 to 10
# www.EasyCodeBook.com

from tkinter import *

def show_table():
num = int(entry.get())
str1=' Table of ' + str(num) + '\n-----------------\n'
for i in range(1,11):
str1 = str1 + " " + str(num) + " x " + str(i) + " = " + str(num*i) + "\n"

output_label.configure(text = str1, justify=LEFT)

main_window = Tk()
main_window.title("Perfect Python tkinter Tutorials : www.EasyCodeBook.com")
message_label = Label(text= ' Enter a number to \ndisplay its Table ' ,
font=( ' Verdana ' , 12))
output_label = Label(font=( ' Verdana ' , 12))
entry = Entry(font=( ' Verdana ' , 12), width=6)
calc_button = Button(text= ' Show Multiplication Table ' , font=( ' Verdana ', 12),
command=show_table)
mainloop()
```

### How this Program works?

• We use Python tkinter module to create GUI of this application
• First of all we create a main window for the program.
• we set the title of the main window.
• create a label widget with message “Enter a number to dislay its table”.
• create a text box / entry widget to get the user input
• create a button and attached a function show_table() using command=show_table.
• Hence when the user will input a number in the entry widget and click on the button, the show_table() function will execute.
• This show_table() function uses a for loop with range() function to display the multiplication table
in a label.

Perfect Programming Tutorials, Python , Java, C Language, C++