Jog Pushbuttons Like Bind in Tkinter
-
I'm to create robot jog pushbuttons that once a PB is pressed will start a function (jog X+) and once the PB is released, will cause a stopjog function. I've tried using .pressed and .released (ref below) but those calls do not work. Any ideas on how to bind the function like in tkinter?
# Check for Coords Jog pushbuttons if self.pushButton_Xplus.pressed:self.move_jog(text="X+") if self.pushButton_Xplus.released: self.move_stop -
I'm to create robot jog pushbuttons that once a PB is pressed will start a function (jog X+) and once the PB is released, will cause a stopjog function. I've tried using .pressed and .released (ref below) but those calls do not work. Any ideas on how to bind the function like in tkinter?
# Check for Coords Jog pushbuttons if self.pushButton_Xplus.pressed:self.move_jog(text="X+") if self.pushButton_Xplus.released: self.move_stop@Pinks32 Please read https://wiki.qt.io/Qt_for_Python_Signals_and_Slots
There is an example how to connect a function to a signal:import sys from PySide2.QtWidgets import QApplication, QPushButton def func(): print("func has been called!") app = QApplication(sys.argv) button = QPushButton("Call func") button.clicked.connect(func) button.show() sys.exit(app.exec_()) -
Thanks! I've done that on other PB's where only clicked is required. Here I want to run func: move_jog() when the PB is held down continuously and then run stop_jog() when that same PB is released after being pushed. The two lines of code above don't work, i.e. the .pressed does not start the move_jog() func.
-
Thanks! I've done that on other PB's where only clicked is required. Here I want to run func: move_jog() when the PB is held down continuously and then run stop_jog() when that same PB is released after being pushed. The two lines of code above don't work, i.e. the .pressed does not start the move_jog() func.
-
Thanks. I changed code to reflect a connect:
self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
self.pushButton_J1plus.released.connect(self.move_stop)Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?
-
Thanks. I changed code to reflect a connect:
self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
self.pushButton_J1plus.released.connect(self.move_stop)Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?
@Pinks32 said in Jog Pushbuttons Like Bind in Tkinter:
but the .released function doesn't work as expected
You mean self.move_stop is never called?
-
Thanks. I changed code to reflect a connect:
self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
self.pushButton_J1plus.released.connect(self.move_stop)Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?
-
Thanks for the advice. Placed print() statements in both move_jog & move_stop and sure enough move_stop was not getting called. There was a tkinter remanent left over in the move_stop module. Once removed, Now my jog PB's work as expected! Thanks again! Onto the next issue...
-
Thanks. I changed code to reflect a connect:
self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
self.pushButton_J1plus.released.connect(self.move_stop)Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?
@Pinks32 said in Jog Pushbuttons Like Bind in Tkinter:
The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?
There was a tkinter remanent left over in the move_stop module. Once removed, Now my jog PB's work as expected!
:)
Don't make assumptions. Put in debug messages.