Hi:
I tried to make two buttons that when I click it, the text in the label will increase or decrease. But python told me that "unsupporte d operand type(s) for +: 'instance' and 'int'" on "labeltext1.set (labeltext1 + 1)" and "labeltext1.set (labeltext1 - 1)". Could you help me solve it? Thanks very much!!
I tried to make two buttons that when I click it, the text in the label will increase or decrease. But python told me that "unsupporte d operand type(s) for +: 'instance' and 'int'" on "labeltext1.set (labeltext1 + 1)" and "labeltext1.set (labeltext1 - 1)". Could you help me solve it? Thanks very much!!
Code:
def Increase(labeltext1):
for a in range (0, 100):
labeltext1.set(labeltext1 + 1)
def Decrease(labeltext1):
for a in range (0, 100):
labeltext1.set(labeltext1 - 1)
labeltext1 = IntVar()
labeltext1.set(0)
NumberLabel = Label(root, textvariable = labeltext1)
Button2 = Button(root, text = "Increase")
Button3 = Button(root, text = "Decrease")
NumberLabel.grid(row = 1, column = 0)
Button2.grid(row = 5, column = 0)
Button3.grid(row = 6, column = 0)
Button2.bind("<Button-1>", Increase(labeltext1))
Button3.bind("<Button-1>", Decrease(labeltext1))
Comment