I am trying to make a button to print a line when it is pressed, and print another when it is released. I know about the command and bind attributes, but I would like to know if it can only be executed using attributes or if I need to use methods. With this code snippet:
class motor: def __init__(eleMesmo, eixo , valorZero): eleMesmo.eixo = eixo eleMesmo.zero = valorZero def aumenta(self): print(self.eixo + str(self.zero+5)) def diminui(self): print(self.eixo + str(self.zero-5)) def para(self): print(self.eixo + str(self.zero)) eixox = motor('x',90) eixoy = motor('y',90) class Interface: def __init__(elemesmo, widget): quadro = Frame(widget) quadro.pack() elemesmo.aumentarY = Button(quadro,text="Aumentar Y",height=10,width=20,command=eixoy.aumenta) elemesmo.aumentarY.pack(side=TOP) elemesmo.diminuirY = Button(quadro,text="Diminuir Y",height=10,width=20,command=eixoy.diminui)
I can call the aumenta method on an eixo y object when the aumentarY button is aumentarY . I would like to call the para method on the eixo y object when the aumentarY button is released. How can i do this?
source share