0% found this document useful (0 votes)
8 views11 pages

I-53 Assignment 3 - GUI

The document outlines an assignment for a Python Programming course at Vidyavardhini’s College of Engineering & Technology, detailing various GUI applications to be created by the student Chaitanya Santosh Shelar. It includes performance indicators for evaluation, a list of practice problems with corresponding code examples, and expected outputs for each task. The tasks range from creating basic windows to more complex applications like a simple calculator and a stopwatch timer.

Uploaded by

ankita.223073201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

I-53 Assignment 3 - GUI

The document outlines an assignment for a Python Programming course at Vidyavardhini’s College of Engineering & Technology, detailing various GUI applications to be created by the student Chaitanya Santosh Shelar. It includes performance indicators for evaluation, a list of practice problems with corresponding code examples, and expected outputs for each task. The tasks range from creating basic windows to more complex applications like a simple calculator and a stopwatch timer.

Uploaded by

ankita.223073201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Vidyavardhini’s College of Engineering & Technology

First Year Engineering

Academic Year 2024-25

Class: FE Semester: II
Course Code: VSEC202 Course Name: PYTHON PROGRAMMING

Name of Student: CHAITANYA SANTOSH SHELAR


Roll No.: 53
Assignment No.: 03
Title of Assignment: GUI
Date of Submission: 09/04/25
Date of Correction:

Evaluation
Performance Indicator Max. Marks Marks Obtained
Legibility 4
Demonstrated Knowledge 4
Timely submission 2
Total 10

Performance Indicator Exceed Expectations Meet Expectations Below Expectations


(EE) (ME) (BE)
Legibility 4 2-3 1-2
Demonstrated Knowledge 4 2-3 1-2
Timely submission 2 1 1

Checked by

Name of Faculty: MS. SHRADDHA GOSAVI


Signature:
Date:

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25

Practice Problems/GUI

NOTE: YOUR NAME /DIV/ROLL NO SHOULD APPEAR ON EACH OUTPUT WINDOW


AS TITTLE/LABEL OR MESSAGE
1 Create a Basic Window
●​ Display a window with a title and fixed size (300x200 pixels).
Code:
import tkinter as tk
from tkinter import Label
root = tk.Tk()
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
root.resizable(False, False)
label = Label(root, text="Python")
label.pack()
root.mainloop()

Output:

2 Display a Label with User Input


●​ Create a GUI that asks for the user’s name in an Entry box.
●​ Display "Hello, [Name]!" when a button is clicked.
Code:
from tkinter import *
def greeting():
name = uname.get()
label2.config(text=f"Hello, {name}")
print("Try")
root = Tk()
root.title("Chaitanya Shelar / I / 53")
label = Label(root, text = "Enter Name: ").grid(row=0, column=0)
label2 = Label(root , text="")
label2.grid(row = 2, column=0, columnspan=2, sticky=EW)
uname = Entry(root)

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


uname.grid(row=0, column=1)
button = Button(root, text="Click Me", command=greeting)
button.grid(row = 1, column= 0, columnspan=2, sticky=EW)
root.mainloop()

Output:

3 Counter Application
●​ Create a window with a label showing a number (starting from 0).
●​ Add "Increase" and "Decrease" buttons to update the number.
Code:
from tkinter import *
root = Tk()
def increaser():
num1 = int(label1['text'])
num1 = num1+1
label1.config(text=num1)
def decreaser():
num1 = label1['text']
num1 = num1-1
label1.config(text=num1)
root.geometry("300x200")
root.title("Chaitanya Shelar / I / 53")
label1 = Label(root, text=0)
label1.grid(row = 0, column=0, columnspan=2, sticky = EW)
button1 = Button(root, text="Decrease", command=decreaser)
button1.grid(row=1, column = 0, sticky=EW)
button2 = Button(root, text="Increase", command=increaser)
button2.grid(row = 1, column = 1)
root.mainloop()

Output:

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25

4 Change Label Text on Button Click


●​ Create a label with "Click the button" text.
●​ When a button is clicked, update the label to say "Button Clicked!"
Code:
from tkinter import *
def clicked():
label1.config(text="Button Clicked")
root = Tk()
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
label1 = Label(root, text = "Click the Button")
label1.grid(row = 0, column = 0)
button1 = Button(root, text = "Click Me", command=clicked)
button1.grid(row = 1, column = 0)
root.mainloop()
Output:

5 Background Color Changer

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


●​ Add buttons labeled "Red", "Blue", "Green".
●​ When clicked, they change the window's background color.
Code:
from tkinter import *
root = Tk()
def red():
root.config(bg='Red')
def blue():
root.config(bg='Blue')
def green():
root.config(bg='Green')
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
button1 = Button(root ,text = "Red", command=red, bg='Red', fg='White')
button1.grid(row = 0, column =0)
button2 = Button(root ,text = "Blue", command= blue, bg='Blue',
fg='White')
button2.grid(row = 0, column =1)
button3 = Button(root ,text = "Green", command= green, bg='Green',
fg='White')
button3.grid(row = 0, column =2)
root.mainloop()

Output:

6 Simple Login Form

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


●​ Create a Username and Password entry field.
●​ Add a Login button.
●​ Display "Login Successful" when the button is clicked.
Code:
from tkinter import *
from tkinter import messagebox
def login():
username = uname.get()
password = passwrd.get()
if username and password:
messagebox.showinfo("Login", "Login Successful")
else:
messagebox.showinfo("Invalid Details", "Please input Valid
Credentials")
root = Tk()
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
label1 = Label(root, text="Username: ")
label1.grid(row = 0, column = 0)
uname = Entry(root)
uname.grid(row = 0, column = 1)
label2 = Label(root, text="Password: ")
label2.grid(row = 1, column = 0)
passwrd = Entry(root, show = "*")
passwrd.grid(row = 1, column = 1)
button = Button(root, text = "Login", command=login)
button.grid(row = 2, column = 0, columnspan=2,)
label3 = Label(root, text="")
label3.grid(row = 3, column = 0, columnspan=2)
root.mainloop()
Output:

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


7 Simple Calculator
●​ Create an entry box for numbers.
●​ Add "Add", "Subtract", "Multiply", "Divide" buttons.
●​ Show the result when an operation is clicked.
Code:
from tkinter import *
root = Tk()
def add():
n1 = int(num1.get())
n2 = int(num2.get())
res = n1+n2
label3.config(text=f"Result: {res}")
def subs():
n1 = int(num1.get())
n2 = int(num2.get())
res = n1-n2
label3.config(text=f"Result: {res}")
def multi():
n1 = int(num1.get())
n2 = int(num2.get())
res = n1*n2
label3.config(text=f"Result: {res}")
def divi():
n1 = int(num1.get())
n2 = int(num2.get())
if n2==0:
label3.config(text=f"Result: Second number cant be Zero")
else:
res = n1 / n2
label3.config(text=f"Result: {res}")
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
label1 = Label(root, text="Number 1: ")
label1.grid(row = 0, column = 0)
num1 = Entry(root)
num1.grid(row = 0, column = 1)
label2 = Label(root, text="Number 2: ")
label2.grid(row = 1, column = 0)
num2 = Entry(root)
num2.grid(row = 1, column = 1)
button1 = Button(root, text = "Add", command= add)
button1.grid(row = 0, column= 2, sticky=EW)
button2 = Button(root, text = "Substract", command= subs)
button2.grid(row = 1, column= 2, sticky=EW)
button3 = Button(root, text = "Multiply", command= multi)
button3.grid(row = 2, column= 2, sticky=EW)
button4 = Button(root, text = "Divide", command= divi)

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


button4.grid(row = 3, column= 2, sticky=EW)
label3 = Label(root, text="")
label3.grid(row=2, column = 0, columnspan=2, sticky= EW)
root.mainloop()

Output:

8 To-Do List
●​ Create an Entry box for adding tasks.
●​ Add a "Add Task" button to store tasks in a Listbox.
●​ Add a "Delete Task" button to remove selected tasks.
Code:
from tkinter import *
def addTask():
task = taskentry.get()
if task:
dispList.insert(END, task)
def delTask():
indexnum = dispList.curselection()
if indexnum:
dispList.delete(indexnum[0])
root = Tk()
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
label1 = Label(root, text="Enter Task: ")
label1.grid(row = 0, column = 0)
taskentry = Entry(root)
taskentry.grid(row = 0, column = 1)
addT = Button(root, text = "Add Task", command = addTask)
addT.grid(row = 0, column = 2, sticky=EW)
delT= Button(root, text = "Delete Task", command=delTask)

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


delT.grid(row = 1, column = 2, sticky=EW, )
dummyLabel1 = Label (root, text = "")
dummyLabel1.grid(row = 2, column= 2)
dispList = Listbox(root, selectmode=SINGLE)
dispList.grid(row = 1, column = 0, columnspan= 2, rowspan= 4, sticky=EW)
root.mainloop()

Output:

9 Password Strength Checker


●​ Ask the user to enter a password.
●​ Display "Weak", "Medium", or "Strong" based on the password length.
Code:
from tkinter import *
def strength():
password = passEntry.get()
ostrength = ""
if len(password) < 8:
ostrength = "Weak"
elif len(password) < 12:
ostrength = "Medium"
else:
ostrength = "Strong"
result.config(text=f"Password Strength: {ostrength}")
root = Tk()
root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
label1 = Label(root, text = "Enter Password")
label1.grid(row = 0, column = 0)
passEntry = Entry(root)
passEntry.grid(row = 0, column = 1)
btn1 = Button(root, text = "Check Strength", command=strength)
btn1.grid(row = 1, column = 0, columnspan=2, sticky=EW)

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


result = Label(root, text = "")
result.grid(row = 2, column = 0, columnspan=2, sticky=EW)
root.mainloop()
Output:

10 StopWatch Timer
●​ Create a timer with Start, Stop, and Reset buttons.
●​ Display the elapsed time in seconds.
Code:
from tkinter import *
global eTime
eTime = 0
def start():
global running
running = True
update_timer()
def stop():
global running
running = False
def reset():
global running, eTime
running = False
eTime = 0
timeholder.config(text=f"{eTime:.2f}")
def update_timer():
global eTime
if running:
eTime = eTime + 0.01
timeholder.config(text=f"{eTime:.2f}")
root.after(10, update_timer)
root = Tk()

Python Programming 2024-25


Vidyavardhini’s College of Engineering & Technology
First Year Engineering

Academic Year 2024-25


root.title("Chaitanya Shelar / I / 53")
root.geometry("300x200")
timeholder = Label(root, text = "0.00")
timeholder.grid(row = 0, column = 0 )
btn1 = Button(root, text = "Start", command=start)
btn1.grid(row = 1, column = 0)
btn2 = Button(root, text = "Stop", command=stop)
btn2.grid(row = 1, column = 1)
btn3 = Button(root, text = "Reset", command= reset)
btn3.grid(row = 1, column = 2)
root.mainloop()

Output:

Python Programming 2024-25

You might also like