Solved: call a function with prameters inm tkinter buttion

The main problem is that the function will not be called with the correct number of arguments.


In Python, you can call a function with parameters in a Tkinter button by using the command attribute of the button. For example, if you have a function named my_func that takes two parameters, you can call it like this:

button = tkinter.Button(root, text="Click me", command=lambda: my_func(param1, param2))

In this code, a button is being created that, when clicked, will call the my_func function with the parameters param1 and param2.

Tkinter

Tkinter is a GUI toolkit for Python. It provides a simple and easy to use interface for creating graphical user interfaces. Tkinter can be used to create applications such as interactive menus, dialog boxes, and windows.

Pass arguments to Button with Tkinter

In Python, you can use the pass keyword to call a function without providing any arguments. This is useful when you want to call a function with specific arguments, but you don’t know what they are.

To call a function with specific arguments, you can use the argv keyword.

Related posts:

Leave a Comment