I'm building an image processing appilcation..the problem is I'm not able to import separate scripts in my main script..I want to use them for various functions..but it shows an error..
can anyone tell me the correct procedure to import script defined for various functions..
`

from Tkinter import *
from PIL import Image, ImageTk, ImageEnhance
import sys
import os
import ttk
import img_func
import en2
import center



root = Tk()
root.wm_title("PhotoGram")
center.center_window(root,1100,700)
#root.tk.call('wm', 'iconbitmap', root, '-default', 'iconfile.ico')

global filename
filename = "ip_img.jpg"

img_func.img_show(root,filename)
img_func.logo_show(root)

Label(root, text="Specify the parameters below and click OK",bg="red",font=("Helvetica", 12)).grid(row=0,columnspan=4)

#Input file
#Label(root, text="Input File:",bg="white").grid(row=1,column=0,sticky=W)

labelIp = StringVar()
labelIp.set("Browse to select an IMAGE                  ")
l1=Label(root, textvariable=labelIp,bg = "white",wraplength=220).grid(row=1, column=1,columnspan=4,sticky=E+W+S+N)

#Function for Browse Ip File  Button
def sel_ip():
 import tkFileDialog


 toplevel = Tk()
 toplevel.withdraw()
 global filename
 filename = tkFileDialog.askopenfilename()
 print filename
 name,ext = os.path.splitext(filename)
 print ext
 name = os.path.basename(name)
 print name

 if ext == ".bmp" or ext == ".xpm" or ext == ".eps" or ext == ".gif" or ext == ".im" or ext == ".jpg" or ext == ".pcd" or ext == ".pcx" or ext == ".xbm" or ext == ".png" or ext == ".ppm" or ext == ".psd" or ext == ".tif" :
  labelIp.set(filename)

  en2.image = Image.open(filename)

  en2.image = en2.image.resize((700,500),Image.ANTIALIAS)


  #im=en2.image.thumbnail((200, 200))
  #img_func.img_show(root,filename)

  en2.tkim = ImageTk.PhotoImage(en2.image.mode,en2.image.size)

  Label(root, image=en2.tkim).grid(row=0, column=10, columnspan=12, rowspan=12,padx=10, sticky=W+E+N+S)

  en2.Enhance(root, "Color", ImageEnhance.Color, 0.0, 4.0).grid(row=3,column=0)
  en2.Enhance(root, "Sharpness", ImageEnhance.Sharpness, -2.0, 2.0).grid(row=3,column=1)
  en2.Enhance(root, "Brightness", ImageEnhance.Brightness, -1.0, 3.0).grid(row=4,column=0)
  en2.Enhance(root, "Contrast", ImageEnhance.Contrast, -1.0, 3.0).grid(row=4,column=1)


  #Label(root, image=tkim).grid(row=5,column=0)


 else:
  labelIp.set("ERROR!! NOT AN IMAGE FILE!!")
  filename = "not_img.jpg"
  img_func.img_show(root,filename)

#Browse IpFile button
b1 = Button(root, text="Click to Browse Input File ...",bg='white',anchor='center',command=sel_ip)
b1.grid(row=1,column=0)

#Enhancement Widgets
en2.image = Image.open(filename)
en2.tkim = ImageTk.PhotoImage(en2.image.mode,en2.image.size)


en2.Enhance(root, "Color", ImageEnhance.Color, 0.0, 4.0).grid(row=3,column=0)
en2.Enhance(root, "Sharpness", ImageEnhance.Sharpness, -2.0, 2.0).grid(row=3,column=1)
en2.Enhance(root, "Brightness", ImageEnhance.Brightness, -1.0, 3.0).grid(row=4,column=0)
en2.Enhance(root, "Contrast", ImageEnhance.Contrast, -1.0, 3.0).grid(row=4,column=1)


#ZOOM IN WIDGET
def zoomin():
 if filename != "ip_img.jpg" and filename != "not_img.jpg":

  print "yes in loop"

  top = Toplevel(root)
  ####zoom in photoimage instance of en2.image code here 

  Label(top, image=en2.tkim).grid(row=0, column=10, columnspan=20, rowspan=20,padx=10, sticky=W+E+N+S)




im = Image.open("zoomin.jpg")
image = im.resize((80,30),Image.ANTIALIAS)
photo = ImageTk.PhotoImage(image)
b=Button(root, image=photo,command=zoomin)
b.grid(row=5,column=0)




root.mainloop()

`

I do not see any error message in your post.

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.