I'm trying to add items to the combobox in GUIzero getting the value from a textbox when a button is pressed, but when the button is pressed I get the following error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Alfonso\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2068, in __call__
return self.func(*args)
~~~~~~~~~^^^^^^^
File "C:\Users\Alfonso\AppData\Local\Programs\Python\Python313\Lib\site-packages\guizero\PushButton.py", line 206, in _command_callback
self._command()
~~~~~~~~~~~~~^^
TypeError: 'str' object is not callable
this is the part of my code that it is giving my issues:
from guizero import App, Box, Text, PushButton, ListBox, Window, TextBox, Combo
def add_team():
n = t_names.value
l_team.append(n)
def edit_menu():
edit_win.show(wait=True)
app = App(title = "Timer", layout = "grid", bg="Gray")
bot = PushButton(app, text="edit", grid=[0,0], command="edit_menu")
edit_win = Window(app, title="Edit", layout="grid", bg="Gray") #edit window
team_name = Text(edit_win, grid=[0,0], text="Teams:", size=30)
l_team = Combo(edit_win, options=[" "], grid=[1,0])
l_team.text_size=30
t_names = TextBox(edit_win, grid=[2,0], width=40)
mas_team = PushButton(edit_win, grid=[3,0], text="Add", command="add_team")
menos_team = PushButton(edit_win, grid=[4,0], text="Del", command="del_team")
edit_win.tk.state("zoomed")
edit_win.hide()
I think that I have a problem with my Tkinter library.
commandargs of your buttons instead of passing the function you want to call. That will lead to the error as strings are not callable.command=edit_menuwithout" "- and this how you send functions in GUIs and in many other situations.