I've managed to narrow down the circimstances in which the error occurs. The application is a file manager (not terribly original,I know, but my main purpose is to gain experience in using Tkinter). It displays the contents of a directory in a list box, and then applies the function (in this case rename) to the selected items. There is also a secondary list, named tag_list, which can be loaded from disc and used to preselect files. If I call the function filter_taglist once, it behaves itself but after I load a differenct tag list and repeat, then the confirm dialog always returns False and the action fails.
I'm baffled!!!! Code snippets below show 1. Loading the tag file from disc 2. Matching the tag file to the main file list 3. Renaming all selected files (comments starting ## have been added in this post) <code> # Load from file def load_taglist(self,ask_file_name=1): #if ask_file_name get tagfile name if ask_file_name: a=fd.askopenfilename(title='Tag File',initialdir=os.path.split(self.tagfile)[0],filetypes=[('Tagfiles','*.tag'),('All files','*')]) if a=='': return self.tagfile=a ## entTag is an entry bix which shows the name of the current tag file self.entTag.delete(0,tk.END) self.entTag.insert(0,os.path.split(self.tagfile)[1]) # read file self.taglist=[] try: fp=file(self.tagfile,'r') while 1: a=pstring(fp.readline()) if a.text=='': break a.stripcrlf() self.taglist.append(a.text) fp.close() except: mb.showerror(self.tagfile,'Error reading from tag file') self.show_taglist() </code> <code> ## This function reads every file in the list box and checks it against the tag list def filter_taglist(self): for i in range(self.lstFiles.size()): f=self.lstFiles.get(i) if f in self.taglist: self.lstFiles.select_set(i) self.lstFiles.see(i) </code> <code> ## This function applies a user specified function to each selected file def file_control(self,action): ## set up list of files - element 0 is the path and elements 1 up are the files ## get_listbox_contents(1) is a function which returns a list of ## listbox selected contents (instead of just their position number) file_list=[self.file_path,]+widget(self.lstFiles).get_listbox_contents(1) exit_flag=0 file_count=len(file_list)-1 if file_count==0: mb.showwarning(self.title,action+': No files selected') return # Initial conditions. If the user cancels, or the conditions are insufficient, # set an escape flag if action=='Rename': i=mb.askyesno(file_list[0],'Ok to rename %d selected file(s)' % file_count) if i==0: exit_flag=1 ## etc <code> -- http://mail.python.org/mailman/listinfo/python-list