How to pass arguments to a Button command in Tkinter?

前端 未结 18 2807
夕颜
夕颜 2020-11-21 07:42

Suppose I have the following Button made with Tkinter in Python:

import Tkinter as Tk
win = Tk.Toplevel()
frame = Tk.Frame(master=win).grid(row=         


        
18条回答
  •  梦如初夏
    2020-11-21 08:16

    One simple way would be to configure button with lambda like the following syntax:

    button['command'] = lambda arg1 = local_var1, arg2 = local_var2 : function(arg1, arg2)
    

提交回复
热议问题