Lambda表达式传参给GUI

2021-01-13  本文已影响0人  Chaweys

#coding=utf-8
from tkinter import *

root=Tk()
root.title("lambda表达式传参应用")
root.geometry("300x50")

def command1():
    print("command1,这种方式简单情况:不涉及获取event对象,可以使用")

def command2(a,b):
    print("{0}-{1}".format(a,b))

Button(root,text="command1",command=command1).pack(side="left")

Button(root,text="command2",command=lambda :command2("Vince","Jenny")).pack(side="left")


root.mainloop()
lambda表达式传参给GUI.png
上一篇 下一篇

猜你喜欢

热点阅读