我想在tkinter中找到一个方法,按钮星星保持按下,直到我按下strop按钮。在tkinter中的Python方法,按钮保持按下,直到不同的命令
from Tkinter import *
import tkMessageBox
class MainWindow(Frame):
def __init__(self):
Frame.__init__(self)
self.master.title("input")
self.master.minsize(250, 150)
self.grid(sticky=E+W+N+S)
top=self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
for i in range(2):self.rowconfigure(i, weight=1)
self.columnconfigure(1, weight=1)
self.button0 = Button(self, text="Start", command=self.save, activeforeground="red")
self.button0.grid(row=0, column=0, columnspan=2, pady=2, padx=2, sticky=E+W+N+S)
self.button1 = Button(self, text="Stop", command=self.stop, activeforeground="red")
self.button1.grid(row=1, column=0, columnspan=2, pady=2, padx=2, sticky=E+W+N+S)
def save(self):
pass
def stop(self):
pass
if __name__=="__main__":
d=MainWindow()
d.mainloop()
这么想的工作,对不起 –
哪一部分不工作?我认为这里可能存在平台依赖性,因为这可以在我的Linux机器上运行,但不适用于Mac OSx。 – ebarr
“dosen't work”是不是很丰富。怎么了?你有没有看到任何错误?这是一个[完整的代码示例来尝试](https://gist.github.com/11390111) – jfs