python - Listbox returned items not working -


using returned items listbox in command isn't being recognised. message saying "mybuff" not field name. should mybuff returned string? other times message: typeerror: selectbuffer() takes 2 arguments (1 given)

import arcpy,sys,os tkinter import*  class application(frame):     def __init__(self, master=none):         frame.__init__(self, master)         self.grid()         self.createwidgets(master)      def createwidgets(self,master):         #add listbox , populate         self.buflist = listbox(master, height=4, width=17, selectmode=single)         self.buflist.grid(row=0, column=0, rowspan=4, columnspan=2, sticky='w')         self.buflist.insert(end, "select buffer")         item in ["5m", "10m", "15m"]:             self.buflist.insert(end, item)      #add select button     self.selectbutton = button(master, text='1. select',command=self.selectbuffer)         self.selectbutton.grid(row=0, column=2, sticky='nw')         self.selectbutton.bind("<<listboxselect>>", self.selectbuffer)      #add method select button     def selectbuffer(self, event):         global select         select = self.buflist.curselection()         mybuff = self.buflist.get(select[0])  #get value of selected item         #perform geoprocessing analysis         mxd = arcpy.mapping.mapdocument("c:/projects/myproject.mxd)         arcpy.buffer_analysis("c:/projects/road.shp", "c:/projects/roadbuffer100.shp","mybuff")   root = tk() app = application(master=root) app.mainloop() 

you use selectbuffer 2 times.

command=self.selectbuffer  self.selectbutton.bind("<<listboxselect>>", self.selectbuffer) 

one of lines expects def selectbuffer(self, event):,
expect def selectbuffer(self): error.

use none default value event rid of problem.

def selectbuffer(self, event=none): 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -