From f9869cfb108f28f408afd87c588a3603eb28989b Mon Sep 17 00:00:00 2001 From: William Date: Tue, 2 Jun 2026 09:22:52 -0700 Subject: [PATCH] Improve game scheduling interface and validation Refactor game scheduling UI and add validation for team selection. --- Droplistmenu/GamesCalender.py | 85 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/Droplistmenu/GamesCalender.py b/Droplistmenu/GamesCalender.py index 48ff7c9d5a6..bfc1282adaf 100644 --- a/Droplistmenu/GamesCalender.py +++ b/Droplistmenu/GamesCalender.py @@ -1,62 +1,49 @@ -from tkinter import * -from tkcalendar import Calendar import tkinter as tk +from tkinter import messagebox +from tkcalendar import Calendar - -window = tk.Tk() - -# Adjust size -window.geometry("600x500") - -gameList = ["Game List:"] - - -# Change the label text def show(): - game = selected1.get() + " vs " + selected2.get() + " on " + cal.get_date() - gameList.append(game) - # print(gameList) - gameListshow = "\n".join(gameList) - # print(gameList) - label.config(text=gameListshow) + visitor = selected1.get() + home = selected2.get() + + # Validation: Check if teams are the same + if visitor == home: + messagebox.showwarning("Input Error", "Visitor and Home teams cannot be the same!") + return + + game = f"{visitor} vs {home} on {cal.get_date()}" + + # Update the Text widget + display_area.config(state=tk.NORMAL) # Enable editing + display_area.insert(tk.END, game + "\n") + display_area.config(state=tk.DISABLED) # Make read-only + + # Optional: Clear dropdowns or reset + selected1.set("Team 1") + selected2.set("Team 2") +window = tk.Tk() +window.title("Game Scheduler") +window.geometry("600x550") -# Dropdown menu options options = ["Team 1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6"] +selected1 = tk.StringVar(value="Team 1") +selected2 = tk.StringVar(value="Team 2") -# datatype of menu text -selected1 = StringVar() -selected2 = StringVar() - -# initial menu text -selected1.set("Team 1") -selected2.set("Team 2") - -# Create Dropdown menu -L1 = Label(window, text="Visitor") -L1.place(x=40, y=35) -drop1 = OptionMenu(window, selected1, *options) -drop1.place(x=100, y=30) - -L2 = Label(window, text="VS") -L2.place(x=100, y=80) - -L3 = Label(window, text="Home") -L3.place(x=40, y=115) -drop2 = OptionMenu(window, selected2, *options) -drop2.place(x=100, y=110) - -# Add Calendar -cal = Calendar(window, selectmode="day", year=2022, month=12, day=1) +# UI Layout using Grid for better alignment +tk.Label(window, text="Visitor:").grid(row=0, column=0, padx=10, pady=10) +tk.OptionMenu(window, selected1, *options).grid(row=0, column=1) -cal.place(x=300, y=20) +tk.Label(window, text="Home:").grid(row=1, column=0, padx=10, pady=10) +tk.OptionMenu(window, selected2, *options).grid(row=1, column=1) +cal = Calendar(window, selectmode="day", year=2026, month=6, day=2) +cal.grid(row=0, column=2, rowspan=2, padx=20) -# Create button, it will change label text -button = Button(window, text="Add to calendar", command=show).place(x=100, y=200) +tk.Button(window, text="Add to Schedule", command=show).grid(row=2, column=0, columnspan=2, pady=20) -# Create Label -label = Label(window, text=" ") -label.place(x=150, y=250) +# Scrollable display area +display_area = tk.Text(window, height=10, width=50, state=tk.DISABLED) +display_area.grid(row=3, column=0, columnspan=3, padx=10) window.mainloop()