0

I am trying to access tkinter variables from a function, however I am getting the error AttributeError: 'ClassA' object has no attribute 'bet'

I am using a bind for a label to invoke the function here:

self.label.bind("<Button-1>", self.calculator(self.teamAOdds[0], self.teamBOdds[1]))

This is the function:

def calculator(self, a, b, ac=0, bc=0):
     betamt = self.bet.get()
     self.betA.insert(END, a)
     self.betB.insert(END, b)
     self.commA.configure(text=ac)
     self.commB.configure(text=bc)

For each of these labels which I am trying to access in the function, I get an AttributeError.

If I use a button to invoke a function e.g.

self.startButton.configure(command=self.start)

Then I can directly access the tkinter labels/entry forms from that function.

Is there any way I can do this for a label bind?

Thanks.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
user2975192
  • 317
  • 2
  • 6
  • 18

0 Answers0