I am just learning MVC and im using Tkinter to do so, but while i am trying to configure a button from a class within a class i keep getting this error
Traceback (most recent call last):
File "Controller.py", line 22, in <module>
controller = Controller(root)
File "Controller.py", line 10, in __init__
self.view.addWidgets.btn.config(command=self.addShow)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1205, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1196, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".35986680.35987112.35991848"
If you cant determine the problem from the error i can post my code, but they are in two separate files, although the files are only 40 lines long.
Details:
Button is in Frame class
Frame class is in View class
View class is in Controller class
function being called by Button command is in Controller class
error happens when i configure button from Controller class
self.view.addWidgets.btn.config(command=self.addShow)
Edit
I striped the code.
Controller.py
from View import *
from Model import *
from Tkinter import *
class Controller:
def __init__(self,root):
self.model = Model()
self.view = View(root)
self.view.addWidgets.btn.config(command=self.addShow)
def addShow(self):
print 'Working'
root=Tk()
root.withdraw()
controller = Controller(root)
root.mainloop()
View.py
from Tkinter import *
from MultiListbox import *
from AddFrame import *
class View(Toplevel):
def __init__(self, master):
Toplevel.__init__(self, master)
self.title('Show Preserver')
self.protocol(self.protocol('WM_DELETE_WINDOW', master.destroy))#When i delete this i dont get the error but it still dosent work
self.addFrame=Frame(self,bg='black')
self.addWidgets=AddFrame(self.addFrame)
self.addFrame.grid(row=0)
self.mainloop()
AddFrame.py
#Add Frame
from Tkinter import *
class AddFrame(Frame):
def __init__(self,master):
self.frame = Frame(master,bg='black')
self.frame.grid(row=0,column=0,sticky=W+E)
self.btn = Button(self.frame,text='Add',bg='black',fg='yellow',activebackground='yellow',activeforeground='black', width=2,command=None)
self.btn.grid(row=0,column=6,sticky=E)