I am new to Python programming, and am a bit stumped on a problem.
I am trying to build a sequence of forms and pass parameters from one form to the next. Although I have found examples showing how to switch between forms, I have not found an example that shows passing parameters between forms in different classes.
The code below is bad and has errors--sorry about that. I assume this is a relatively easy for an experienced Python programmer to answer. I appreciate your help and consideration in in this matter.
# Problem 1: All forms open at once instead of 1 at a time
# 2: The buttons are not attached to the forms
# 3: Not sure if parameters are being passed from Form1 to Form2
# 4: Now i am getting errors
# Notes: All forms will be different sizes
import tkinter as tk
class Form1(tk.Tk):
def __init__(self, master):
two=tk.Tk() # <--define object for Form2
value1 = 'Some Text'
value2 = 8
value3 = 'More Text'
#--attempting to pass 3 parameters to Form2
#---on click, open Form2 and close Form1
self.btn=tk.Button(self,text='button 1',
command=Form2.__init__(two, value1, value2, value3))
self.btn.grid(row=0,column=0)
class Form2(tk.Tk):
def __init__(self, parm1, parm2, parm3):
print(parm1, parm2, parm3)
three=tk.Tk() # <--define object for Form3
#---on click, open Form3 form and close Form2
self.btn=tk.Button(self,text='button 2', command=Form3.__init__(three))
self.btn.grid(row=0,column=0)
class Form3(tk.Tk):
def __init__(self):
three = tk.Tk()
self.btn=tk.Button(self,text='button3 ',command=None) # action to be added later
self.btn.grid(row=0,column=0)
a=tk.Tk()
Form1 = Form1(a)