Skip to content Skip to sidebar Skip to footer

Functions In Tkinter

So I am practicing using Tkinter with python, and I am just trying to learn the basics. My code right now is import Tkinter as tk class Example(tk.Frame): def __init__(self, p

Solution 1:

The problem is that the command attribute expects a reference to a function. When you do command=self.button(...), you are immediately calling the function and then using the result of the function as the value for the command attribute.

If you want to pass arguments, you need to use lambda or functools.partial. This question has been asked many times on this site. See, for example, Calling functions with arguments on "command" and "bind" and python Tkinter: passing an argument to a function

Post a Comment for "Functions In Tkinter"