#๐Ÿ”’ Ctk Option menu help

11 messages ยท Page 1 of 1 (latest)

white terrace
#

global location
location = 3.1

    def optionmenu_callback(event):
        choice = combobox.get()
        if choice == "Head":
            location = 3
        if choice == "Chest":
            location = 37
        if choice == 'Legs':
            location = 67
        if choice == 'Feet':
            location = 97

    combobox = CTkComboBox(master=self.mainFrame,
                           values=["Head", "Chest", "Legs", "Feet"])
    combobox.set("Head") #Startup Value
    combobox.grid(row=6, column=0, padx=20, pady=10)
    combobox.bind("<<ComboboxSelected>>", optionmenu_callback)
dim sandBOT
#

@white terrace

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

white terrace
#

i have no idea how to use Ctk, i just want a option menu with those options, head chest legs and feet, and then when you choose either of those options it will make location = the corresponding numbers 3, 37, 67, 97

queen quail
#

moving your global location declaration to inside the function would be the correct way to make it global

#

i.e. py def optionmenu_callback(event): global location location = 3 ...

white terrace
#

then i want the location in def something to be changing acording to the class gui optionmenu

#

if that makes any sense

dim sandBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.