使用addButton时,AppJar已按下所有按钮
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用addButton时,AppJar已按下所有按钮相关的知识,希望对你有一定的参考价值。
所以我想使用appJar,但每当我使用addButton时,它只会执行我所说的如果按下putton应该做的事情。以下是对问题很重要的代码:
app = gui("Leiterspiel")
app.addLabel("l1", "Simple Demo")
app.addButton("1", calculate(1))
app.addButton("2", calculate(2))
app.addButton("3", calculate(3))
app.go()
我可以在控制台中看到计算结果立即执行参数1,2和3。
答案
您对.addButton()
的参数格式不正确。
您实际上正在调用.calculate()
函数,然后将结果传递给每个按钮。
相反,只需将函数的引用传递给每个按钮:
app = gui("Leiterspiel")
app.addLabel("l1", "Simple Demo")
app.addButton("1", calculate)
app.addButton("2", calculate)
app.addButton("3", calculate)
app.go()
以上是关于使用addButton时,AppJar已按下所有按钮的主要内容,如果未能解决你的问题,请参考以下文章