I'm trying to make a custom popup to act as an about screen for a program i'm making, however when i try to have another window existing before i call the popup i get a tcl message saying the image doesnt exist. for the record i'm using python 3.3.4
complete extract of my code is:
#!python3
from tkinter import *
import PIL.ImageTk
import os
__version__ = "part number"
class Screen():
def __init__(self):
aboutscreen = Tk()
aboutscreen.title("About")
aboutscreen.photoimg = PIL.ImageTk.PhotoImage(file="Logo.bmp")
Label(aboutscreen, image=aboutscreen.photoimg).pack()
Label(aboutscreen, text = "company name", width = 25, font = ("ariel",16)).pack()
Label(aboutscreen, text = "program name", width = 30, font = ("ariel",12)).pack()
Label(aboutscreen, text = "Part Number: " + __version__, width = 30, font = ("ariel",12)).pack()
Label(aboutscreen, text = "Copyright company name", width = 30, font = ("ariel",12)).pack()
while 1:
try: aboutscreen.update() #keep update window updated until destroyed
except: break #break loop when destroyed
if __name__ == "__main__":
root = Tk()
app = Screen()
this code is what gives me the error message:
line 15, in __init__
Label(aboutscreen, image=aboutscreen.photoimg).pack()
File "C:\Python33\lib\tkinter\__init__.py", line 2607, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Python33\lib\tkinter\__init__.py", line 2086, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: image "pyimage1" doesn't exist
but if i comment out the root = Tk() line it works.
can anyone explain where i'm going wrong?
Thanks
James