TKINTER等待多个按钮按下
已经创建了一个带有y^x的计算器,它使用wait命令来等待x值被按下。等待只等待一个按钮按下。希望它至少等待5个按钮按下,例如-25.3。如何做?
# Create a wait function that will wait for another key press
def wait_variable(self):
self.tk.call('tkwait', 'variable', self.equation)
def power(self):
a = self.get_expression()
self.equation.set(f"{a} ^ b (enter b)")
# Call the wait function
self.wait_variable()
b = self.get_expression()[-1]
power_expression = f"math.pow(float({a}), float({b}))"
_expression = self.get_expression()
self._calculate_expression(power_expression)
Have created a calculator with, among others, y^x and it uses wait command to wait for x value to be pressed. Wait only waits for one button press. Would like it to wait for at least 5 button presses, such as -25.3. How to do this?
# Create a wait function that will wait for another key press
def wait_variable(self):
self.tk.call('tkwait', 'variable', self.equation)
def power(self):
a = self.get_expression()
self.equation.set(f"{a} ^ b (enter b)")
# Call the wait function
self.wait_variable()
b = self.get_expression()[-1]
power_expression = f"math.pow(float({a}), float({b}))"
_expression = self.get_expression()
self._calculate_expression(power_expression)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想建议您创建一个全局变量并在每个按钮按下将其递增,然后创建一个用每种按下来调用的函数,并检查变量的值,如果var的值为5,执行件,我希望有帮助。
I would like to suggest that you create a global variable and increment it with every button press, then create a function that gets called with every press and checks the value of the variable, if the var had the value of 5, execute stuff, I hope that helps.