Спасибо тем, кто нашел время, чтобы оставлять комментарии. После дополнительных исследований я переписал программу. Это работает сейчас.
# Working Example of how to pass parameters to sequential windows
import tkinter as tk
class Win1(tk.Frame):
def __init__(self, master):
tk.Frame.__init__(self, master)
self.grid()
rownum = 0
colnum = 0
#-----collect some information needed for the application--------------------------
self.lbl_a = tk.Label(self, text="Number of Categories", font=("Arial Bold", 10),
justify="left",anchor='w')
self.lbl_a.grid(column=colnum, row=rownum,columnspan=1,sticky='w')
self.numcat_ent =tk.Entry(self, width=12,background='white',
fg='blue',state='normal',font=("Arial Bold", 10), justify='center')
self.numcat_ent.insert('end', '4')
self.numcat_ent.grid(column=colnum+1, row=rownum)
numcat=int(self.numcat_ent.get())
rownum += 1
self.lbl_b = tk.Label(self, text="Items Per Category", font=("Arial Bold", 10),
justify="left",anchor='w')
self.lbl_b.grid(column=colnum, row=rownum,columnspan=1,sticky='w')
items=6
self.numitems_ent=tk.Entry(self, width=12,background='white',
fg='blue',state='normal',font=("Arial Bold", 10), justify='center')
self.numitems_ent.insert('end', '4')
self.numitems_ent.grid(column=colnum+1, row=rownum)
numitems=int(self.numitems_ent.get())
rownum += 1
#---on click, open Win2 and close Win1
btn1=tk.Button(self,text='Show Win 2',
command=lambda: self.open_win2(master,numcat ,numitems))
btn1.grid(row=rownum,column=colnum,sticky='nsew')
def open_win2(self, master, numcat ,numitems):
self.hide(master)
self.root2 = tk.Toplevel()
self.root2.geometry('300x600')
print(numcat,numitems)
app2 = Win2(self.root2,root, numcat, numitems)
def hide(self,master):
root.withdraw()
#---to bring root window back
#root.deiconify()
class Win2(tk.Frame):
def __init__(self, master, root2, parm1, parm2):
tk.Frame.__init__(self, master)
print(parm1, parm2)
root.withdraw()
self.grid()
#---on click, open Win3 form and close Win2
self.btn1=tk.Button(self,text='Open Win3', command=lambda: self.open_win3(master))
self.btn1.grid(row=0,column=0)
rownum = 0
colnum = 0
fontSize = 12
for i in range(parm1):
rownum += 1
self.catEntry=tk.Entry(self, width=12,background='white',
fg='blue',state='normal',font=("Arial Bold", fontSize), justify='center')
self.catEntry.grid(column=colnum, row=rownum)
for j in range(parm2):
rownum += 1
self.subcatEntry=tk.Entry(self, width=12,background='white',
fg='black',state='normal',font=("Arial Bold", fontSize), justify='center')
self.subcatEntry.grid(column=colnum+1, row=rownum)
def open_win3(self,master):
self.hide(master)
root3 = tk.Toplevel()
root3.geometry('800x800')
app3 = Win3(root3)
def hide(self,master):
root.withdraw()
master.withdraw()
class Win3(tk.Frame):
def __init__(self,master):
root.withdraw()
tk.Frame.__init__(self, master)
self.grid()
self.btn=tk.Button(self,text='Return to Start Page',command=lambda:self.return_to_start(master))
self.btn.grid(row=0,column=0)
def return_to_start(self, master):
master.withdraw()
root.deiconify()
root = tk.Tk()
root.geometry("225x100")
app = Win1(root)
#----Mainloop keeps forms updated and listens for user input--
root.mainloop()