Multiplication Table Display GUI using tkinter – Screen for Logged-in Users

Posted by

Multiplication Table Displayer GUI using tkinter | Screen after Login

PART 2: Multiplication Table Displayer GUI using tkinter

Screen after Login

In the previous article, we created a simple login interface using the tkinter library in Python. Now, let’s continue building our Multiplication Table Displayer GUI.

Code Update

After the user successfully logs in, we want to display a new window with the multiplication table options. We can achieve this by creating a new class for the main application window and defining the layout and functionality of the table displayer.

Sample code:

		
class MultiplicationTableApp(tk.Tk):
    def __init__(self, username):
        tk.Tk.__init__(self)
        self.title("Multiplication Table Displayer")
        self.geometry("400x300")

        self.username = username

        self.label = tk.Label(self, text=f"Welcome, {self.username}!")
        self.label.pack()

        self.num_label = tk.Label(self, text="Enter a number:")
        self.num_label.pack()

        self.num_entry = tk.Entry(self)
        self.num_entry.pack()

        self.show_button = tk.Button(self, text="Show Table", command=self.show_table)
        self.show_button.pack()

    def show_table(self):
        number = int(self.num_entry.get())
        table = ""
        for i in range(1, 11):
            table += f"{number} x {i} = {number * i}n"
        messagebox.showinfo("Multiplication Table", table)

if __name__ == "__main__":
    app = MultiplicationTableApp("John")
    app.mainloop()
		
	

Explanation:

We created a new class called MultiplicationTableApp which inherits from the tk.Tk class. In the constructor, we initialize the window with a title, dimensions, and the username of the logged-in user. We also added a label, entry field, and a button for the user to input a number and display the multiplication table. When the button is clicked, we retrieve the input, calculate the multiplication table, and display it using a message box.

Conclusion

With this update, we have successfully implemented the screen after the login interface for our Multiplication Table Displayer GUI. In the next article, we will further enhance the functionality and design of the application.

0 0 votes
Article Rating
6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@PoonamSingh-hr3id
5 months ago

Really helpful

@Xavier-vy8eh
5 months ago

What if …..
If mam asks questions to me ?
I'm dead☠️

@pragatichauhan2398
5 months ago

thanks for helping, really good

@madrench4067
5 months ago

very good

@unnatichauhan6725
5 months ago

Really helpful!👏

@chemicalcad9006
5 months ago

Great….. good 👍