Tkinter错误:窗口路径名称错误

时间:2015-11-19 07:42:35

标签: python tkinter

我想为我的游戏添加统计菜单(见此处):

def statsexpand():
    toplevel = Toplevel()
    toplevel.destroy()
    if "normal" != toplevel.state():
        toplevel = Toplevel()
        totalclicksvar = StringVar()
        totalclicksvar.set("Total Clicks: " + str(totalclicks))
        totalclickslabel = Label(toplevel, textvariable=totalclicksvar)
        totalclickslabel.pack()

...遗憾的是,这不起作用,并提出了这个问题。

Traceback (most recent call last):
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1536, in __call__
    return self.func(*args)
  File "C:/Users/hyli/Desktop/New folder (2)/Ways to NOT earn money V0.4.0.py", line 14, in statsexpand
    if "normal" != toplevel.state():
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1772, in wm_state
    return self.tk.call('wm', 'state', self._w, newstate)
  TclError: bad window path name ".28950040"

我已在本网站上检查了其他问题,以获取答案,例如thisthis,但他们并不真正适用于此问题。

对于其余代码(如果需要),请参阅https://github.com/DerpfacePython/Ways-to-NOT-make-money/blob/master/game.py

请帮忙!

0 个答案:

没有答案