i beginner in tkinter , trying create interface, runs program checks 'correctness' of formal specifications. program checks whether written specification meets criteria - checks whether terms used declared, etc.
anyway, trying add search button, changes color of key words, when found in text - use tags , works ok. problem is, after have used search function (i.e. have added tags , removed them, when clicking on save) program checks 'correctness' of specification doesn't run properly, on files have been checked , shown correct. following error:
file "c:\python27\lib\lib-tk\tkinter.py", line 1193, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) tclerror: invalid command name ".43965456" i have no idea might mean. wondering whether adding tags changes text file in way (apart changing color of key words), might mess program, checks 'correctness'.
here search function:
def searchwindowbutton(self,event): self.top = toplevel() self.top.title("search") label(self.top,text='text find:').pack(side=left) self.edit = entry(self.top) self.edit.pack(side=left, fill=both, expand=1) self.edit.focus_set() button = button(self.top, text="search", command = self.on_button) button.pack(side=left) def find(self): self.txt.tag_remove('found', '1.0', end) s = self.edit.get() if s: idx = '1.0' while 1: idx = self.txt.search(s, idx, nocase=1, stopindex=end) if not idx: break lastidx = '%s+%dc' % (idx, len(s)) self.txt.tag_add('found', idx, lastidx) idx = lastidx self.txt.tag_config('found', background='green', foreground='black') self.edit.focus_set() def on_button(self): self.find() self.top.destroy() and save function:
def savemenu(self): try: self.txt.tag_remove("found", "1.0", 'end') filename=self.fl fl = open(filename, 'w') textoutput = self.txt.get(0.0, end) fl.write(textoutput) except: self.save_asmenu()
i wondering whether adding tags changes text file in way (apart changing color of key words)
no, adding tags has absolutely 0 effect on text file.
tclerror: invalid command name ".43965456" means widget internal id of .43965456 has been destroyed prior calling whatever function triggers error.
Comments
Post a Comment