I'm working on a GUI-App with tkinter and customtkinter. When an option of an OptionMenu is selected, i want to trigger a function located in another class with keyword arguments. As far as i know, commands dont accept functions with arguments, so i want to use a functool.partial wrapper.
The relevant parts of code are the following:
class OptionsFrame(ctk.CTkFrame):
def __init__(self, master,main):
#creating optionmenu
self.opt_window_func=ctk.CTkOptionMenu(self,values=self.values_window_func)
#defining wrapped command call
command_opt_windows_func=partial(self.main.command_opt
,opt_name="select_window_func"
,opt_value=self.opt_window_func.get())
#setting command call
self.opt_window_func.configure(command=command_opt_windows_func)
self.opt_window_func.grid(row=1,column=1, padx=5, pady=5, sticky='new')
class MainClass():
def __init__(self):
self.app=App(main=self)
self.app.mainloop()
def command_opt(self,opt_value,opt_name):
self.set_param(opt_name,opt_value)
self.update_opt()
Compiling and App start is working fine. When I trigger the command (by clicking on the OptionsMenu) I'll receive a TypeError:
tkinter\windows\widgets\ctk_optionmenu.py", line 381, in _dropdown_callback self._command(self._current_value) TypeError: command_opt() got multiple values for argument 'opt_value'
How should i call the function correctly with all given arguments?