我正在构建一个包含一个计数器和一个图像的脚本。两者都在单个窗口的不同画布上。我试图在计时器停止后更新画布图像。以下是我的代码。我没有弄到这个
的错误from Tkinter import *
import Tkinter as tk
import stopwatch
import stone_image
class App():
def __init__(self, root):
self.root = root
self.root.configure(background="yellow")
global stoneImagePanel
stopwatchPanel = tk.Canvas(self.root, background="yellow")
stoneImagePanel = tk.Canvas(self.root, background="yellow")
stopwatchPanel.grid(row=0, column=0, columnspan=4, sticky="e")
stoneImagePanel.grid(row=1, column=0, rowspan=2, columnspan=4, sticky="news")
self.stoneImage_canvas(stoneImagePanel)
self.stopWatch_canvas(stopwatchPanel)
def stopWatch_canvas(self, parent):
stopwatch.timerStart(parent, 500)
stoneImagePanel.after(500, self.update(stoneImagePanel))
def stoneImage_canvas (self, parent):
displayImage = stone_image.DisplayImage(parent)
displayImage.stoneImg('images/stone.jpg')
def update(self, parent):
displayImage = stone_image.DisplayImage(parent)
displayImage.stoneImg('images/UP.png')
if __name__ == "__main__":
root = Tk()
app = App(root)
root.mainloop()
秒表工作不顺畅,图像也没有更新。请帮忙。