-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicgui.py
More file actions
48 lines (39 loc) · 1.64 KB
/
basicgui.py
File metadata and controls
48 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# ***************************************************************
# Name : ProgramNameTong
# Author: Than Tong
# Created : * Course: CIS189
# Version: 1.0
# OS: Windows 11
# IDE: Python
# Copyright : This is my own original work
# based onspecifications issued by our instructor
# Description :
# Input: ADD HERE XXX
# Ouput: ADD HERE XXX
# Academic Honesty: I attest that this is my original work.
# I have not used unauthorized source code, either modified or
# unmodified. I have not given other fellow student(s) access
# to my program.
import tkinter as tk
# Function to update the "Waiting" label when a Checkbutton is checked
def checkbutton_checked():
selected_meals = [meal for meal, var in zip(meals, meal_vars) if var.get() == 1]
waiting_label.config(text=f"Waiting for: {', '.join(selected_meals)}")
# Create the main application window
app = tk.Tk()
app.title("Favorite Meal")
# List of meal options and their associated IntVar
meals = ["Breakfast", "Second Breakfast", "Lunch", "Dinner"]
meal_vars = [tk.IntVar() for _ in range(len(meals))]
# Create Checkbuttons for each meal
for i, meal in enumerate(meals):
checkbutton = tk.Checkbutton(app, text=meal, variable=meal_vars[i], command=checkbutton_checked)
checkbutton.grid(row=i, column=0, sticky=tk.W)
# Create the "Waiting" label
waiting_label = tk.Label(app, text="Waiting for:")
waiting_label.grid(row=4, column=0, sticky=tk.W)
# Create the "Exit" button
exit_button = tk.Button(app, text="Exit", command=app.quit)
exit_button.grid(row=5, column=0)
# Start the Tkinter main loop to run the application
app.mainloop()