I have created several individuall windows with tkinter and now I want to connect them. So implementing several "Forward" and "Back" Buttons. This should be simple but it turns out to screw with me alot.
This can be seen as a practical application issue of this question: Go back and forth between tkinter windows
I implemented the explained logic the best I can but still fail.
My specific Issues are:
When I klick the "Reports"-button the new window opens but: the original window(cockpit) doesnt disapear and a second window opens which is just the Original Cockpit window but without any widgets in it (just the frame?)
Also when I hit the "Back" Button this error Message Appears: self.ReportSelection_Win.withdraw() AttributeError: 'Event' object has no attribute 'ReportSelection_Win'
I stripped the following code of most of its functions since they arent neccessary for the issue I think. So most button dont have any function.
from tkinter import *
from tkinter import ttk
#Funktionen für Fenster
def Func_Show_Rep(self):
# Open new Window
ReportSelection_Win = Tk()
self.ReportSelection_Win = Toplevel()
ReportSelection_Win.title("Report auswählen")
#Dropdown Auswahlliste
Reports = [
"Alle Mitarbeiter",
"Alle Projekte",
"Alle Skills"
]
#Widgets
#Labels & Dropdown
Lbl_Headline = Label(ReportSelection_Win, text = "Bitte wählen Sie einen Report")#Create Label
Lbl_Headline.grid(column=0, row=0, padx=10, pady=10) #Show Label
Drop_Reports = ttk.Combobox(ReportSelection_Win)
Drop_Reports.grid(column=0, row=1, padx=10, pady=10)
Drop_Reports['values'] = Reports
#Buttons
Btt_Confirm_RepSelect = Button(ReportSelection_Win, text="Auswählen")
Btt_Confirm_RepSelect.bind("<Button-1>", Select_Report)
Btt_Confirm_RepSelect.grid(column=0, row=2, padx=10, pady=10, sticky=W)
Btt_Back_RepSelect = Button(ReportSelection_Win, text="Zurück")
Btt_Back_RepSelect.bind("<Button-1>", Func_ReportSelection_Back)#Back to Cockpit
Btt_Back_RepSelect.grid(column=0, row=2, padx=10, pady=10, sticky=E)
self.Cockpit_Win.withdraw() #.deiconify() to show again
#Funktionen für Report Fenster
def Func_ReportSelection_Back(self):
self.ReportSelection_Win.withdraw()
self.Cockpit_Win.deiconify()
#Modify the Window [◙Not essential for Issue]
Cockpit_Win.title("Ressourcen Verwaltung")
Cockpit_Win.columnconfigure(1, weight=1)
Lbl_Descr_MA = Label(Cockpit_Win, text = "Mitarbeiter verwalten und anlegen")#Create Label
Lbl_Descr_MA.grid(column=0, row=0, padx=10) #Show Label
Btt_Show_MA = Button(Cockpit_Win, text="Mitarbeiter", width=35)
Btt_Show_MA.bind("<Button-1>",Func_Show_MA)#Button click starts function
Btt_Show_MA.grid(column=1, row=0, padx=10, pady=7, sticky=E)
Lbl_Descr_Pro = Label(Cockpit_Win, text = "Projekte Verwalten und anlegen.")#Create Label
Lbl_Descr_Pro.grid(column=0, row=1, padx=10) #Show Label
Btt_Show_Pro = Button(Cockpit_Win, text="Projekte", width=35)
Btt_Show_Pro.bind("<Button-1>",Func_Show_Pro)#Button click starts function
Btt_Show_Pro.grid(column=1, row=1, padx=10, pady=7, sticky=E)
Lbl_Descr_Rep = Label(Cockpit_Win, text = "Report auswählen und ausgeben")#Create Label
Lbl_Descr_Rep.grid(column=0, row=2, padx=10) #Show Label
Btt_Show_Rep = Button(Cockpit_Win, text="Reports", width=35)
Btt_Show_Rep.bind("<Button-1>",Func_Show_Rep)#Button click starts function
Btt_Show_Rep.grid(column=1, row=2, padx=10, pady=7, sticky=E)
Btt_Cock_Abort = Button(Cockpit_Win, text="Abbrechen", width=35)
Btt_Cock_Abort.bind("<Button-1>",Func_Cock_Abort)#Button click starts function
Btt_Cock_Abort.grid(column=1, row=3, padx=10, pady=7, sticky=E)
Cockpit_Win.geometry('350x170') #Window size
#Make the windows stay (loop)
Cockpit_Win.mainloop()