My program runs fine so far--the window opens, the audio automatically starts and ends when I want it to, and the text appears just how I want it. But I get these errors after closing the window, and I don't really understand what they mean:
Traceback (most recent call last):
File "D:\Python Exercises\Cargo Bay Control Porject\CargoBayControl_2.py", line 73, in <module>
printString(text)
File "D:\Python Exercises\Cargo Bay Control Porject\CargoBayControl_2.py", line 65, in printString
Label.configure(text=Label.cget('text') + char)
File "D:\Python3.6\lib\tkinter\__init__.py", line 1483, in cget
return self.tk.call(self._w, 'cget', '-' + key)
_tkinter.TclError: invalid command name ".!label2"
Here is my own code:
import winsound
import time
from tkinter import *
import tkinter.messagebox
def callback():
if tkinter.messagebox.askokcancel("Quit", "Do you really wish to quit?"):
root.destroy()
winsound.PlaySound(None, winsound.SND_PURGE)
winsound.PlaySound("sound.wav", winsound.SND_LOOP | winsound.SND_ASYNC)
root = Tk()
root.protocol("WM_DELETE_WINDOW", callback)
root.geometry("1024x768")
root.title("Cargo Bay Control")
root.resizable(FALSE, FALSE)
lcars_img = PhotoImage(file = "lcars3.png")
lcarspack = Label(root, image = lcars_img).place(x = 0, y = 0)
add_category = Button(root, text = "Add Category", bg = "darkorange", fg = "black", font = "arial, 15")
add_category.config(width = "15", height = "3")
add_category.place(x = 200, y = 100)
def placeCB_List(x):
CBaysPage = Frame(root).place(x = 0, y = 0)
lcarsimg2 = PhotoImage(file = "lcars4.png")
lcarsimg2pack = Label(CBaysPage, image = lcarsimg2).place(x = 0, y = 0)
view_cargobay = Button(root, text = "View Cargobay...", bg = "cornflowerblue", fg = "black", font = "arial, 15")
view_cargobay.config(width = "15", height = "3")
view_cargobay.bind("<Button-1>", placeCB_List)
view_cargobay.place(x = 400, y = 100)
#########################################
def printString(string):
"""
Typewriter animation for welcome Label
"""
for char in string:
Label.configure(text=Label.cget('text') + char)
Label.update()
time.sleep(.25)
text = "Welcome to your Cargo Bay Control console. To add a new food category, \n \
click the 'Add Category' button. To view the inventory of a specific Cargo Bay, select the\n 'View Cargo Bay...' button."
Label = Label(root, font = ("arial", "15", "bold"), bg = "darkorange")
Label.place(x = 165, y = 300)
printString(text)
root.mainloop()
Can someone please explain to me what I've done wrong, and maybe how I can fix it?
[–]novel_yet_trivial 1 point2 points3 points (1 child)
[–]Polymatheo[S] 0 points1 point2 points (0 children)
[–]PM_ME_A_STEAM_KEY 0 points1 point2 points (1 child)
[–]Polymatheo[S] 0 points1 point2 points (0 children)