<div>Hi, friends<br> I'm programming with Tkinter/Tix. I want to use Tix.FileEntry, and only find fe_obj['value'] to get the selected file, is there any other way? As I find it may cause some memory problems, while used with tkMessageBox.<br>
Running the following codes, if I click "Work" twice, the program will crash before the 2nd warning sub-window pops up. Even if I comment the 2 lines of adding Label self.sflb, it still dump. </div>
<div> </div>
<div> My pc is WinXP Version 2002 Service Pack 3, CPU is Intel Core2 2-core, with Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32.<br> I find it may be due to conflicts with Tix.FileEntry. How to fix it?</div>
<div><br>import Tkinter, Tix<br>import tkMessageBox, tkFileDialog </div>
<div>class Worker():<br> def __init__(self):<br> self.root = Tix.Tk()</div>
<div> self.sffm = Tkinter.Frame(self.root)<br> self.sflb = Tkinter.Label(self.sffm, text='Select file :')<br> self.sflb.pack(side='left')<br> self.sfft = Tix.FileEntry (self.sffm)<br>
self.sfft.pack(side='left')</div>
<div> self.btfm = Tkinter.Frame(self.root)<br> self.gnbt = Tkinter.Button(self.btfm,text='Work', command=self.work)<br> self.gnbt.pack(side='left')</div>
<div> self.sffm.pack() <br> self.btfm.pack()<br> Tkinter.mainloop()<br> <br> def work(self) :<br> ''' do all work '''<br> print 1<br> value = self.sfft["value"]<br>
# use showwarning/showerror, if click "Work' for 2 times, will dump<br> tkMessageBox.showwarning('Title', '<%s>' % value)<br> <br> print '+%s+' % value<br>
<br>if __name__=='__main__':<br> worker = Worker()<br></div>