May-11-2020, 11:41 PM
Hi guys,
I hope you can helpppppp.....
I have a program which is supposed to get the new values of 9 variables.
It initializes [init()] by arranging the numbers similar to a spreadsheet, and putting varaibles in the "textvariable" as var00, var01, var02 etc
Then it give values to each by attempting to use the .get method of the Control variables.
But my program does not work.
Thanks
Marty
I hope you can helpppppp.....
I have a program which is supposed to get the new values of 9 variables.
It initializes [init()] by arranging the numbers similar to a spreadsheet, and putting varaibles in the "textvariable" as var00, var01, var02 etc
Then it give values to each by attempting to use the .get method of the Control variables.
But my program does not work.
Thanks
Marty
import tkinter as tk from tkinter import * root = tk.Tk() def give_values(): # row 0 var00 = StringVar().get() var01 = StringVar().get() var02 = StringVar().get() # row 1 var10 = StringVar().get() var11 = StringVar().get() var12 = StringVar().get() # row 2 var20 = StringVar().get() var21 = StringVar().get() var22 = StringVar().get() v = (var00, var01, var02, var10, var11, var12, var20, var21, var22) print(v) def init(): for i in range(3): for j in range(3): frame = tk.Frame( master=root, relief=tk.RAISED, width=2, borderwidth=1 ) frame.grid(row=i, column=j) entry = tk.Entry(master=frame, text=f"Row {i}\nColumn {j}", textvariable="var" + str(i) + str(j)) entry.pack() give_values() init() give_values() # b1 = Button(root, text="Done", width=10).grid(row=0, column=10, rowspan=10) # command=done) b2 = Button(root, text="Enter", width=10, command=give_values).grid(row=1, column=10, rowspan=10) # command=enter()) root.mainloop()