以下是我为当前工作构建的应用程序中使用的部分代码。运行以下代码时,我收到本文标题中所述的错误。tkinter 向导的代码来自http://mail.python.org/pipermail/tutor/2005-May/038686.html。我已经在自己的窗口中运行了代码并且它可以工作,但是当我将代码放在我的应用程序中时,它会遇到上述错误。
所以,这是我的问题:发生了什么事,我该如何解决?
from tkinter import *
#Start Code for the Introduction Wizard
def wizIntro():
wizIntro = tkinter.Tk()
#Title:
wizIntro.title('Welcome to Training')
#Content:
page1 = Frame(wizIntro)
Label(page1, text='', width=110).pack()
Label(page1, text='--Welcome to Training--', width=85).pack()
Label(page1, text='', width=85).pack()
Label(page1, text='This tutorial will help you familiarize yourself with the program. Following it is key to understanding', width=85).pack()
Label(page1, text='the proper operation of the Laser Cutter.', width=85).pack()
Label(page1, text='', width=90).pack()
Label(page1, text='It is also important to follow every insrtuction exactly as stated, to avoid or minimize damage to the Laser', width=85).pack()
Label(page1, text='Cutter and reduce the risk of injury to the operator and those around him.', width=85).pack()
Label(page1, text='Therefore, all safety notices must be followed with extreme care.', width=110).pack()
Label(page1, text='--Failure to follow all safety notices poses a severe risk of damage to the equipment and to the operator, which can be fatal--', width=110, fg='red').pack()
Label(page1, text='', width=110).pack()
Label(page1, text='Click Next to Continue...', width=110).pack()
page1.pack()
page2 = Frame(wizIntro)
Label(page2, text='', width=110).pack()
#Commands:
pages = [page1, page2]
current = page1
def move(dirn):
global current
idx = pages.index(current) + dirn
if not 0 <= idx < len(pages):
return
current = pages[idx]
current.pack_forget()
current.pack(side = TOP)
def nex():
move(+1)
def prev():
move(-1)
Button(wizIntro, text='Previous', command=prev).pack(side = LEFT)
Button(wizIntro, text='Next', command=nex).pack(side = RIGHT)
#End Code for the Introduction Wizard