Thanks for your input vegaseat. I have posted the code that is giving me the problem in the two scripts and I hope you can comment further.
Thanks in advance - Elvedon.

#The script displayed below is only part of the larger original script.#

#filename = 'firstScript.py'

#!/usr/bin/python

from Tkinter import *
import pickle
import tkFont
import os, sys
from ImageTk import PhotoImage 
from PIL import Image

def Import():
        import secondScript
        
root = Tk()
root.geometry("600x400")
root.title("FirstScript")

w = Canvas(root, width=300, height=400, bg= "white")
w.place(x=300,y=0,anchor=NW)

photo = PhotoImage(file="fotoimage01.bmp")
item = w.create_image(152,200,image=photo)

import_button = Button(root, text="Imprt", command = Import)
import_button.place(x=150, y=150, anchor=N)

root.mainloop()


#Second Script#

#Although the script displayed below is only a part of the larger original script.#
#The two scripts display the same error message.#
#
#When this script is run alone as a script, it works perfectly.#
#When this script is imported into the First Script as a module,#
#it will not run and the following error message is displayed: #
#    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:\DaniWeb\firstScript.py", line 12, in Import
#    import secondScript
#  File "F:\DaniWeb\secondScript.py", line 32, in <module>
#    item = wb.create_image(397,281,image=photo)
#  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


#filename = 'secondScript.py'

#!/usr/bin/python

from Tkinter import *
import pickle
import tkFont
import os, sys
from ImageTk import PhotoImage 
from PIL import Image


root = Tk()
root.geometry("600x400")
root.title("SecondScript")

wb = Canvas(root, bg="yellow")
wb.config(width= 794, height= 562)                

wb.place(x=0,y=0,anchor=NW)

photo = PhotoImage(file= 'fotoimage02.bmp')

item = wb.create_image(397,281,image=photo)

root.mainloop()

Something like this works ...

# main program firstscript.py
# display an image using Tkinter and PIL
# PIL allows Tkinter to read more than just .gif image files

import Tkinter as tk
from PIL import ImageTk

def next_image():
    import secondscript


root = tk.Tk()
# size the window so the image will fit
root.geometry("%dx%d+0+0" % (360, 240))

# create all image objects in __main__ to be persistent
# pick an image file you have in your working directory
# or specify full path
image_file = "people1.bmp"
photo = ImageTk.PhotoImage(file=image_file)
root.title(image_file)

# put the image on a canvas
cv = tk.Canvas()
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(0, 0, image=photo, anchor='nw')

# now add a button on top of the canvas
btn1 = tk.Button(cv, text="Click", command=next_image)
btn1.pack(side='left', padx=10, pady=5, anchor='sw')

root.mainloop()

... and here is the second script ...

# save as module secondscript.py
# display an image using Tkinter and PIL
# PIL allows Tkinter to read more than just .gif image files

import Tkinter as tk
from PIL import ImageTk

root = tk.Tk()
root.withdraw()
win = tk.Toplevel()
# size the window so the image will fit
win.geometry("%dx%d+200+100" % (360, 240))

# create all image objects in __main__ to be persistent
# pick an image file you have in your working directory
# or specify full path
image_file = "people2.bmp"
photo = ImageTk.PhotoImage(file=image_file)
win.title(image_file) 

# put the image on a canvas
cv = tk.Canvas(win)
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(0, 0, image=photo, anchor='nw')


if __name__ == '__main__':
    win.mainloop()
commented: Thanks vegaseat - your post solved my problem +0
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.