I have written two scripts in python. When I run the two scripts as individual programs they run correctly. But when the second script is run as a module within the first by importing it, an image file is not recognised. I have tried calling the full pathwayof the image without any success.

I have shown the error message below.

Can somebody please help?

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "F:\Python26\WebSite_231109_Pg01_01.pyw.py", line 114, in Import
import WebSite_231109_Pg02_01
File "D:\Python26\WebSite_231109_Pg02_01.py", line 184, in <module>
File "C:\Python26\lib\lib-tk\Tkinter.py", line 2156, in create_image
return self._create('image', args, kw)
File "C:\Python26\lib\lib-tk\Tkinter.py", line 2147, in _create
*(args + self._options(cnf, kw))))
TclError: image "pyimage2" doesn't exist

I assume that pyimage2 is an image object in your module.

Without knowing your code, all I can tell you is that Tkinter will garbage collect any image object assigned to a function scope variable. Maybe it will also do that to a module scope variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.