0

I have a tkinter GUI that I structured based on Bryan Oakley's post here. I have a container class and some other classes. I have a button in my navigation class that is trying to call a function in the container class. For some reason I cant get self.parent... to work and have to type in Container... to get the function to work. The first line of code below works but the second line gets the error you see below.

    self.Clear.bind("<Button-1>", lambda event: self.parent.combine_funcs(self.parent.ChangeRange(F_Clear), Container.UpdateToolBar(self, F_Clear)))
    self.Clear.bind("<Button-3>", lambda event: self.parent.combine_funcs(self.parent.ChangeRange(F_Clear), self.parent.UpdateToolBar(self, F_Clear)))

TypeError: UpdateToolBar() takes 2 positional arguments but 3 were given

It only has a problem with the UpdateToolBar def...

    def UpdateToolBar(self, file):
    self.parent.ToolBar1.itemconfigure('toolbar', text=('CalcTime: '+str(self.parent.total)[:5]))

If I change the code to:

self.parent.UpdateToolBar(F_Clear)))

I get:

AttributeError: 'Container' object has no attribute 'parent'

I'm hoping the answer to this will give me more insight into interacting with code in different classes.

Community
  • 1
  • 1
lessharm
  • 65
  • 13
  • 2
    Can you provide an [MCVE](http://stackoverflow.com/help/mcve) so we can see what each object refers to? – TigerhawkT3 Apr 04 '16 at 01:46
  • my advice: don't use lamba. It adds complexity without providing any real value here. Just create a custom function. Lambda should only be used when – Bryan Oakley Apr 04 '16 at 02:51
  • I actually figured it out when making a MCVE... The variable 'total' was something I was using to keep track of the time it would take a different function to calculate something, but that variable was in the function and that's why my prog couldn't access it. I added the UpdateToolBar code to the end of that function instead of trying to call it from another one which makes a lot more sense anyway. – lessharm Apr 04 '16 at 02:54

0 Answers0