python scripting in arcmap 10

542
2
05-02-2014 03:56 AM
AmalMehdi
New Contributor
Hello
I want to create a python script that do the same as the GO To XY but using a customized user interface. I start to write the interface code and creating the point but I don't know how can I display it in the map. Can you help me please.
Here is the code:
from Tkinter import *
class application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()

        self.site_name= Label(self, text= " Site Name: ")
        self.site_name.grid()
        self.site_coordinate =Label(self, text='Site Coordinates : ')
        self.site_latitude= Label(self, text='Latitude: ')
        self.site_longitude= Label(self, text='Longitude: ')
        self.name=Entry(self, bg='white')
        self.latitude=Entry(self, bg='white')
        self.longitude= Entry(self,bg='white')
        self.site_name.grid(row=0)
        self.name.grid(row=1)
        self.site_coordinate.grid(row=2)
        self.site_longitude.grid(row=3)
        self.site_latitude.grid(row=3, column=2)
        self.longitude.grid (row=4)
        self.latitude.grid(row=4, column=2)
        self.ok_button = Button(self,text='Add', command=self.AddPoint)
        self.ok_button.grid(row=5, pady=30)
        self.cancel_button = Button(self,text='Cancel')
        self.cancel_button.grid(row=5, column=2)
       
    def AddPoint (self):
        latitude_value=self.latitude.get()
        longitude_value=self.longitude.get()
        inPoint = arcpy.Point(longitude_value, latitude_value)
       
    


root=Tk()
root.title ("Create Site")
app= application (root)
root.mainloop()
I there is any other possibilities such as using the ModelBuilder or a possiblity to edit the GO TO XY code and customize it please don't hesitate to tell me
Thank you in advance
Tags (2)
0 Kudos
2 Replies
markdenil
Occasional Contributor III
Tkinter is, it seems, not recomended by esri; it apparently does not play well with ArcMap.

There is a very limited arcpy interface that is available through Arcpy AddIns.
Although limited, it will likely provide what you need.

You will need to download the free addin_assistant.
0 Kudos
AmalMehdi
New Contributor
thank you for your answer!
I download the add-ins assistant wizard and I tried to follow step given in Esri seminar in how to create an add-in but I still enable to reach my target
Actually I have to create an add-in that once clicked on display the following interface (see attached photo) and on clicked to add the I have to display the point in the map and store the other enties in a shp file
0 Kudos