PYTHON LAB ASSIGNMENT 8
Tkinter
[Link]. Program
1 Write a Python program to create a basic Tkinter window with the following properties:
The window title should be "Welcome Window".
The window should have a fixed size of 500x400 pixels.
Add a label that says "Hello, Tkinter!" in the center of the window.
Objective: Understand how to create a basic Tkinter window, set window properties, and
add a label widget.
2 Create a Tkinter window with a button labeled "Press Me". When the button is clicked, it
should display a pop-up message box with the text "Button was clicked!".
Objective: Learn how to create buttons and handle events (button clicks) with the
command option and message boxes.
3 Build a simple calculator using Tkinter. The calculator should have buttons for numbers 0-
9, and basic arithmetic operators (+, -, *, /). It should display the result when the user
clicks the "=" button.
Objective: Combine multiple widgets (buttons, labels, and entry boxes) to create a simple
application, and learn about handling input and calculations in Tkinter.
4 Create a login form with two input fields for username and password. Add a "Login"
button that validates the inputs:
If the username is "admin" and the password is "password123", display "Login
successful" in a label below the button.
If the credentials are incorrect, display "Invalid username or password".
Objective: Learn about entry widgets, buttons, and basic form validation using Python
logic within a Tkinter application.
5 Create a Tkinter application to convert temperatures between Celsius and Fahrenheit. It
should have:
Two entry fields: one for Celsius and one for Fahrenheit.
Buttons to convert from Celsius to Fahrenheit and vice versa.
Display the converted temperature in the appropriate entry field.
Objective: Practice handling user input and output, as well as using Tkinter's entry boxes
and buttons to build a useful tool.