I have a function which when called, Doesn't work while other functions in the same indentation work perfectly This is the function I've tried a lot of things but they don't seem to work
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.ttk import Progressbar
from tkinter import messagebox
import tkinter.font as font
import mysql.connector as mys
import time
from time import sleep
def Assign():
# TE Text Entry
# TEfn Text Entry Flight number
# TEp Text Entry Passengers
# TEa Text Entry Airport
# TEd Text Entry Distance
def computing():
master=Tk()
master.title('AMAS')
photo=PhotoImage(file='AMAS.gif') #Image must be GIF
Label(image=photo) # Line required to prevent python's garbage dump function
Label(master,image=photo,fg='black',bg='black').grid(row=0,column=0,sticky=E)
master.resizable(0,0) # Optional line to prevent the user from resizing the window
master.mainloop()
def dwindow():
print('dwindow called')#TEMP
def saveTEd():
global Ed
Ed=TEd.get()
print(Ed)
window.destroy()
# Window Number 5 Called Below
computing()
window=Tk()
window.title("Distance")
window.configure(background='white')
photo1=PhotoImage(file='Distance.gif')
Label(image=photo1)
Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)
Label(window,text='Enter The Distance Travelled',bg='white',fg='black',font='none 12 bold').grid(row=1,column=0,sticky=W)
TEd=Entry(window,width=20,bg='white')
TEd.grid(row=2,column=0,sticky=W)
Button(window,text='Enter',width=6,command=saveTEd).grid(row=3,column=0,sticky=W)
mainloop()
def awindow():
print('awindow called')#TEMP
def saveDDMo(value):
global DDMo
DDMo=aoption.get()
print(DDMo)
window.destroy()
# Window Number 4 Called Below
dwindow()
window=Tk()
window.title("Destination Airport")
window.configure(background='white')
photo1=PhotoImage(file='airport.gif')
Label(image=photo1)
Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)
Label(window,text='Enter The Destination',bg='white',fg='black',font='none 12 bold').grid(row=1,column=0,sticky=W)
OPTIONS = ['Select an option','BNE','MEL','SYD','BAH','BRU','YYZ','PEK','PVG','CAI','MUC','ATH','AMD','BLR','DEL','COK','CCU','CCJ','BOM','TRV','CGK','NBO','KWI','LHR','MAN','ORG','LAX','JFK','DCA']
aoption = StringVar(window)
aoption.set(OPTIONS[0]) # default value
OptionMenu(window, aoption, *OPTIONS,command=saveDDMo).grid(row=2,column=0,sticky=W)
mainloop()
def pwindow():
print('pwindow called')#TEMP
def saveTEp():
global Ep
Ep=TEp.get()
print(Ep)
window.destroy()
# Window Number 3 Called Below
awindow()
window=Tk()
window.title("Passengers")
window.configure(background='white')
photo1=PhotoImage(file='passengers.gif')
Label(image=photo1)
Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)
Label(window,text='Enter The Number Of Passengers',bg='white',fg='black',font='none 12 bold').grid(row=1,column=0,sticky=W)
TEp=Entry(window,width=20,bg='white')
TEp.grid(row=2,column=0,sticky=W)
Button(window,text='Enter',width=6,command=saveTEp).grid(row=3,column=0,sticky=W)
mainloop()
def fnwindow():
def saveTEfn():
global Efn
Efn=TEfn.get()
print(Efn)
window.destroy()
# Window Number 2 Called Below
pwindow()
window=Tk()
window.title("Flight Number")
window.configure(background='white')
photo1=PhotoImage(file='flightnumber.gif')
Label(image=photo1)
Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)
Label(window,text='Enter the Flight Number',background='white',foreground='black',font='none 12 bold').grid(row=1,column=0,sticky=W)
TEfn=Entry(window,width=20,bg='white')
TEfn.grid(row=2,column=0,sticky=W)
Button(window,text='Enter',width=6,command=saveTEfn).grid(row=3,column=0,sticky=W)
Label.pack()
mainloop()
# Window Number 1 Called below
fnwindow()
#The error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\vinayak\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\vinayak\Documents\Programs 12th\Project.py", line 414, in Assign
fnwindow()
File "C:\Users\vinayak\Documents\Programs 12th\Project.py", line 406, in fnwindow
Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)
File "C:\Users\vinayak\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 2766, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Users\vinayak\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: image "pyimage2" doesn't exist
I think it might be because of what I'm importing or garbage dump but I can't seem to resolve the issue.
I think it might be because of what I'm importing or garbage dump but I can't seem to resolve the issue. I think it might be because of what I'm importing or garbage dump but I can't seem to resolve the issue.