0
我想創建一個程序,有兩個按鈕「停止」和「去」。 「重複」每5秒打印一次「運行」,直到按下「停止」按鈕。這可能在Python 2.7中使用tkinter?這是到目前爲止我的代碼...按下go按鈕後,如何重複一個功能,直到按下停止按鈕? (tkinter,蟒蛇2.7)
from Tkinter import *
class startGo():
def __init__(self, master=None):
self.master = master
self.displayMain()
self.master.rowconfigure(0, weight=1)
self.master.columnconfigure(0, weight=1)
def fnCreateWidgets(self):
self.frWindow = Frame()
self.frWindow.grid(sticky=N+S+E+W)
self.frWindow.update()
def displayMain(self):
self.cvOne = Canvas(self.master, bd=0, highlightthickness=0)
self.cvOne.grid(row=0, column=0, sticky=N+S+E+W)
self.frmWindowOne = Frame(self.cvOne)
self.master.title("StopGo")
self.master.minsize(100, 100)
self.frmWindowOne.grid()
self.frmWindowOne.btnStop = Button(self.frmWindowOne, text="Stop", font=("MagdaCleanMono", 12), command=self.stop)
self.frmWindowOne.btnStop.grid(row=2, column=1, sticky=EW)
self.frmWindowOne.btnGo = Button(self.frmWindowOne, text="Go", font=("MagdaCleanMono", 12), command=self.go)
self.frmWindowOne.btnGo.grid(row=2, column=1, sticky=EW)
def go(self):
#code
def stop(self):
#code
root = Tk()
app = startGo(root)
root.mainloop()