As a new guy, I was trying to write a simple unit conversion program in Tk. I got this error message:TclError: unknown option "-command"
>>> Traceback (most recent call last): File "D:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\Python24\Convert it\Tk Grid demo2py.py", line 70, in ? main() File "D:\Python24\Convert it\Tk Grid demo2py.py", line 67, in main Application().mainloop() File "D:\Python24\Convert it\Tk Grid demo2py.py", line 22, in __init__ , relief=SUNKEN) File "D:\Python24\lib\lib-tk\Tkinter.py", line 2409, in __init__ Widget.__init__(self, master, 'listbox', cnf, kw) File "D:\Python24\lib\lib-tk\Tkinter.py", line 1862, in __init__ self.tk.call( TclError: unknown option "-command" Any Ideas? Joe Cox 513-293-4830
from Tkinter import * class Application( Frame ): def __init__(self): Frame.__init__(self) self.master.title( "Conver Units" ) self.master.rowconfigure( 0, weight = 1 ) self.master.columnconfigure( 0, weight = 1 ) self.grid( sticky = W+E+N+S ) """Create the Text""" self.lbRSSSiteText = Label(self, text="Convert Length Units From:") self.lbRSSSiteText.grid(row=0, column=0, sticky=W) self.lbRSSItemText = Label(self, text="Convert Length Units To:") self.lbRSSItemText.grid(row=0, column=2, sticky=W) """Create the First ListBox""" scrollbarV = Scrollbar(self, orient=VERTICAL) self.lbSites = Listbox(self,command=self.reveal, exportselection=0 , relief=SUNKEN) self.lbSites.grid(row=1, column=0, columnspan=1, sticky=N+W+S+E) for line in ['Miles','Yards','Feet','Inches']: self.lbSites.insert(END, line) """Create the Second ListBox""" self.lbRSSItems = Listbox(self, exportselection=0 ,command=self.reveal , relief=SUNKEN) self.lbRSSItems.grid(row=1, column=2, sticky=N+W+S+E) for line in ['Miles','Yards','Feet','Inches']: self.lbRSSItems.insert(END, line) self.button1 = Button( self, text = "Convert", width = 25 ) self.button1.grid( row = 7, column = 1, columnspan = 2, sticky = W+E+N+S ) """Create the Text""" self.entry = Label(self, text="Input:") self.entry.grid(row=8, column=0, sticky=W) self.text2 = Label(self, text="Output:") self.text2.grid(row=8, column=2, sticky=W) self.entry = Entry( self ) self.entry.grid( row = 11, columnspan = 2, sticky = W+E+N+S ) self.text2 = Text( self, width = 2, height = 2 ) self.text2.grid( row = 11, column = 2, sticky = W+E+N+S ) def reveal(self): a = self.entry.get() b = self.text2.get() c = self.lbSites.get(exportselection) d = self.lbRSSItems.get(exportselection) if c == Miles and d == Feet: message ="Equals"+ a*5280 self.text2.insert(0.0,message) def main(): Application().mainloop() if __name__ == "__main__": main()
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor