0

I have a customtkinterGUI where I make some labels with the text: namen. Within each label I have an optionmenu. After selecting the option, it uses a callback function with "selection" as input, but in I want to make it in such a way that when I select an option, then it returns the selection, but also the name in which label that selection was made.

This is my piece of code:

def callback(selection):
    if selection != "Kies data vorm":

        print(selection, type(selection))

def make_name_labels(namen, iterator):
    global over_frame, optionmenu1st_level
    over_frame = customtkinter.CTkFrame(master=root)
    over_frame.place(x=80, y=50 + (iterator-1)*45, height=40, relwidth=0.95)
    namen_label = customtkinter.CTkLabel(master=over_frame, text=namen)
    namen_label.place(rely=0.5, x=10, anchor=tkinter.W)
    optionmenu1st_level = customtkinter.CTkOptionMenu(master=over_frame, values=["", "Tekst", "Plaatje","code: code128","code: qrcode","code: datamatrix"], command=callback)
    optionmenu1st_level.place(rely=0.5, relheight=0.9, x=150, anchor=tkinter.W)
    optionmenu1st_level.set("Kies data vorm")

An example, when I select "Tekst" in label with name: this_name, the callback function takes these two as parameters. To make it visible: gui callback

  • so it's basically the function needs as input from wich label the optionmenu is clicked and what is clicked. Now I only have what is clicked. An example, when I click the option as in the image, it must return: Artikelnummer AND code: code128 –  Jul 04 '22 at 10:13
  • Problem solved: look at this problem: https://stackoverflow.com/questions/66899169/tkinter-optionmenu-command-possible-to-specify-parameters –  Jul 04 '22 at 12:34

0 Answers0