Try posting your entire code, use code blocks, like this
and hopefully we can get to the bottom of your problem.
OK. All I want to do is add SF_RENDERED to the arcmap TOC. ArcMap session is where the script is run from (from personal arcgis tollbox).
# Import system modules
import sys, string, os, arcgisscripting
# get the shapefile
from Tkinter import *
import tkFileDialog
# Create the Geoprocessor object
gp = arcgisscripting.create()
master = Tk()
master.withdraw() #hiding tkinter window
file_path = tkFileDialog.askopenfilename(initialdir="D:\\", title="Open file", filetypes=[("Shapefile",".shp"),("All files",".*")])
if file_path.find('.shp') == -1:
print "Not a shapefile, quiting"
master.quit()
if file_path != "":
print "you chose file with path:", file_path
SF = file_path
else:
print "you didn't open anything!"
sys.exit()
def rchop(thestring, ending):
if thestring.endswith(ending):
return thestring[:-len(ending)]
return thestring
#get the tolerance
toly = 0
from tkMessageBox import askokcancel
class Quitter(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack()
widget = Button(self, text='Done', command=self.quit)
widget.pack(expand=YES, fill=BOTH, side=BOTTOM)
def quit(self):
gp.addmessage('You chose ' + ent.get() + ' for the tolerance...well played!')
toly = ent.get()
gp.addmessage(toly)
gp.addmessage(toly)
#local variables
SF_Copy = rchop(file_path, '.shp') + '_copy.shp'
SF_Copier = SF_Copy + " #"
SF_COUNT = rchop(file_path, '.shp') + '_collectevents.shp'
SF_Integrated = rchop(file_path, '.shp') + '_integrated.shp'
SF_Rendered = rchop(file_path, '.shp') + '_rendered'
# Load required toolboxes...
gp.AddToolbox("D:/ArcGIS/ArcToolbox/Toolboxes/Spatial Statistics Tools.tbx")
gp.AddToolbox("D:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
## Process: Copy Features...
gp.CopyFeatures_management(SF, SF_Copy, "", "0", "0", "0")
gp.addmessage('Backup copy has been made')
## Process: Integrate...
gp.Integrate_management(SF_Copier, toly)
gp.addmessage('Integration completed')
## Process: Collect Events...
gp.CollectEvents_stats(SF_Copy, SF_COUNT)
gp.addmessage('Events have been collected')
SF_COUNT = SF_COUNT.replace("/","\\")
SF_Rendered = SF_Rendered.replace("/","\\")
gp.addmessage('Creating ' + SF_COUNT)
gp.addmessage('Creating ' + SF_Rendered)
# Process: Count Rendering...
gp.CountRenderer_stats(SF_COUNT, "ICOUNT", SF_Rendered, "5", "bright_pink" ,"")
Frame.quit(self)
gp.addmessage('done and dusted')
#this bit was me having a crack at adding it to the TOC
gp.MakeFeatureLayer_management(SF_Rendered, "Untitled")
gp.RefreshActiveView()
root = Tk()
root.title("Enter the tolerance value for integrate tool")
L1 = Label(root, text="Enter the tolerance value for integrate tool (m): ")
L1.pack( side = LEFT)
ent = Entry(root)
ent.insert(0, '20')
#ent.pack(side=TOP, fill=X)
ent.pack(side=LEFT)
ent.focus()
#ent.bind('<Return>', (lambda event: quitter()))
ent.bind(toly, (lambda event: quitter()))
#btn = Button(root, text='Fetch', command=fetch)
#btn.pack(side=LEFT)
Quitter(root).pack(side=RIGHT)
root.mainloop()