Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5 import QtWidgets, QtGui, QtCore
- import hal, linuxcnc
- class TestWidget(QtWidgets.QWidget):
- def __init__(self, halcomp, parent=None):
- super().__init__(parent)
- self.halcomp = hal.component("mytest")
- self.halcomp.newpin("test-widget-out", hal.HAL_BIT, hal.HAL_OUT)
- self.init_ui()
- self.halcomp.ready()
- def init_ui(self):
- self.setWindowTitle("Test Widget")
- self.setGeometry(300, 300, 250, 150)
- self.layout = QtWidgets.QVBoxLayout()
- self.setLayout(self.layout)
- self.test_direct = QtWidgets.QPushButton("Test Direct")
- self.test_direct.setCheckable(True)
- def set_pin(data):
- self.halcomp["test-widget-out"] = data
- self.test_direct.clicked.connect(set_pin)
- self.layout.addWidget(self.test_direct)
- self.test_hal = QtWidgets.QPushButton("Test HAL")
- self.test_hal.clicked.connect(lambda: hal.set_p("halui.mode.teleop", "true"))
- self.layout.addWidget(self.test_hal)
- self.show()
- def closeEvent(self, event):
- event.accept()
- self.halcomp.exit()
- if __name__ == "__main__":
- app = QtWidgets.QApplication([])
- w = TestWidget(None)
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement