Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
111 views
in Technique[技术] by (71.8m points)

python - Have multiple commands when button is pressed

I want to run multiple functions when I click a button. For example I want my button to look like

self.testButton = Button(self, text = "test", 
                         command = func1(), command = func2())

when I execute this statement I get an error because I cannot allocate something to an argument twice. How can I make command execute multiple functions.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can simply use lambda like this:

self.testButton = Button(self, text=" test", command=lambda:[funct1(),funct2()])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...