Question: generate the python tkinter code for the following functions: CHECK _ FOR _ EXISTING _ EVENT, ADD _ EVENT, SAVE _ EVENT, VIEW _ EVENT,

generate the python tkinter code for the following functions: CHECK_FOR_EXISTING_EVENT, ADD_EVENT, SAVE_EVENT, VIEW_EVENT, EDIT_EVENT, and DELETE_EVENT, and ensure to incorporate DATA VALIDATION on the functions that need it ( ADD_EVENT & EDIT_EVENt) A listbox is used to contain and highlight the events, entry boxes are used to gather the TITLE, TIME, and DESCRIPTION of the events and they are contained on the second window: the EVENT MANAGEMT WINDOW, and a calendar widget is used to gather the DATE. The following code is what I have generated so far, Please USE IT to develop the functions and other details mentioned. Thank you.
import tkinter as tk
from tkinter import ttk
from tkcalendar import Calendar
from PIL import ImageTk,Image
import datetime
from tkinter import simpledialog
class EventManagementWindow(tk.Toplevel):
def __init__(self, parent):
super().__init__(parent)
self.config(background="dodgerblue1")
self.title('Event Management')
self.geometry('900x800')
self.parent = parent
self.create_widgets()
def add_event(self):
if event_name and event_date:
# Check if the event already exists
if f"{event_date}: {event_name}" in self.event_listbox.get(0, tk.END):
tk.messagebox.showerror("Error", "This event already exists.")
else:
self.event_listbox.insert(tk.END, f"{event_date}: {event_name}")
self.parent.highlight_event(event_date)
def edit_event(self):
selected_index = self.event_listbox.curselection()
if selected_index:
current_text = self.event_listbox.get(selected_index)
new_event_name = tk.simpledialog.askstring("Edit Event", "Enter new event name:", initialvalue=current_text.split(': ')[1])
if new_event_name:
# Check if the new event already exists
if f"{current_text.split(': ')[0]}: {new_event_name}" in self.event_listbox.get(0, tk.END):
tk.messagebox.showerror("Error", "This event already exists.")
else:
self.event_listbox.delete(selected_index)
self.event_listbox.insert(selected_index, f"{current_t
class MainWindow(tk.Tk):
def __init__(self):
super().__init__()
self.config(background="azure3")
self.title("Calendar")
self.geometry("900x600")
self.create_widgets()
self.events ={}
def create_widgets(self):
self.calendar = Calendar(self, selectmode="day",
year=datetime.datetime.now().year,
month=datetime.datetime.now().month,
day=datetime.datetime.now().day,
font=("Arial Black", 16, "bold"),
background="dodgerblue1",
foreground="Black",
headersbackground="firebrick",
headersforeground="Black",
selectforeground="darkslategray4",
selectbackground="yellow",
weekendforeground="Black",
weekendbackground="dodgerblue1",
othermonthforeground="darkslategray4",
othermonthbackground="gainsboro",
disabledforeground="Black",
disabledbackground="dimgray")
self.calendar.pack(pady=20)
self.manage_events_button = tk.Button(self, text='Manage Events', activebackground="yellow", background="dodgerblue1", font=("Arial Black", 10, "bold"), width=12, height=3, command=self.open_event_management)
self.manage_events_button.pack()
# Create the exit program button
self.quit_button = tk.Button(self, text="Exit Program", activebackground="yellow", background="firebrick", font=("Arial Black", 10, "bold"), width=10, height=3, command=self.quit)
self.quit_button.pack(side="bottom", anchor="e", padx=10, pady=10)
def open_event_management(self):
self.event_management_window = EventManagementWindow(self)
def highlight_event(self, event_date):
if event_date not in self.events:
self.events[event_date]= self.calendar.calevent_create(date=event_date, text='Event', tags='highlight')
self.calendar.tag_config('highlight', background='orange', foreground='black')
def unhighlight_event(self, event_date):
if event_date in self.events:
self.calendar.calevent_remove(self.events[event_date])
del self.events[event_date]
if __name__=="__main__":
app = MainWindow()
app.mainloop()
generate the python tkinter code for the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!