开发者

Button command being called automatically

For some reason, this Button is automatically calling bot_analysis_frame without the button being pressed. I'm guessing it's because the command is a function with arguments.

Is there a way to have the button only call this function and pass the required variables only upon being pressed?

Button(topAnalysisFrame, text='OK', command=bot_analysis_frame(eventConditionL, eventBreakL)).pack(side=LEFT开发者_高级运维)


Read the section here on passing callbacks.

You are storing the result of that function to the command argument and not the function itself.

I believe this:

command = lambda: bot_analysis_frame(eventConditionL,eventBreakL)

might work for you.


I'm pretty sure this has been answered before. Instead of this:

Button(topAnalysisFrame,
       text='OK',
       command=bot_analysis_frame(eventConditionL,eventBreakL)).pack(side=LEFT)

You could use lambda like so:

Button(topAnalysisFrame,
       text="OK",
       command=lambda: bot_analysis_frame(eventConditionL, eventBreakL)).pack(side=LEFT)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜