【发布时间】:2017-12-21 09:39:40
【问题描述】:
我正在使用 Python 2.7.13 和 Tkinter。
这是我的程序的一部分:
PAButton = Tkinter.ButtonPress(PAFrame, text='PA', fg='white', bg='blue')
PAButton.pack()
self.PAButton.bind("<ButtonPress>", self.playPA)
这是我正在尝试做的事情的要点:
当 PAButton 被按下(未释放)时,运行脚本前面定义的函数 playPA()。
但是,我得到了这个错误:
AttributeError: 'module' object has no attribute 'ButtonPress'
我将如何正确地实现我的目标?
【问题讨论】:
-
...拜托,做研究。
-
你确定
Tkinter有ButtonPress方法,但是我没找到。 -
@S.G.Harmonia 我做到了。我找到了 [this] (stackoverflow.com/questions/34522095/gui-button-hold-down) 和 [this] (stackoverflow.com/questions/16548757/…),并以此为基础编写了代码。请不要贸然评论。
标签: python python-2.7 user-interface tkinter