I have a window that contains up to twelve lines of data from a matrix. Because I use a loop, I have to use a "variable label." One of these variable labels There are eight of them) uses an Option Menu to allow the user to pick from a list, the example here is "0", "1", "2", "3".
I use the i=my_num
before the colon because out of the twelve lines, the user might be changing line three.
The problem is, no matter what I do, the "print(f'{i}, {gn.get()}, {final_roster}')"
statement will "overwrite" the "i" value with the "gn" value.
Changing this variable for the first line to a value of "3" should look like this: 1, 3, {1: 'B@Griffin@GRF-3M@1521@1@1521@A@A@N@5@4'}
But actually returns this: 3, 3, {1: 'B@Griffin@GRF-3M@1521@1@1521@A@A@N@5@4'}
from tkinter import *
from tkinter import Label
from tkinter import messagebox
from tkinter import LEFT
from tkinter.ttk import Label, Entry
from tkinter.filedialog import askopenfilename
from tkinter import Tk, Canvas, Frame, BOTH
import win32api
root = Tk()
def NewList(root):
rndwin = Toplevel(root)
rndwin.geometry("775x360+10+10")
rndwin.title("Define Selection Parameters")
pick3 = [
"0",
"1",
"2",
"3"
]
# This line is actually in a loop and draws up to twelve of them.
globals()['roster_gun%s' % my_num] = OptionMenu(rndwin, gunnry, *pick3, command=lambda i=my_num: gunneryv(root, rndwin, i, gunnry, final_roster, bv_array, roster_sz, base_files))
globals()['roster_gun%s' % my_num].place(x=10, y=10)
def gunneryv(root, rndwin, i, gn, final_roster, bv_array, roster_sz, base_files):
print(f'{i}, {gn.get()}, {final_roster}')