Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def initialize(self):
comp = hal.COMPONENTS['qtpyvcp']
obj_name = str(self.objectName()).replace('_', '-')
# add checkbox.enable HAL pin
self._enable_pin = comp.addPin(obj_name + ".enable", "bit", "in")
self._enable_pin.value = self.isEnabled()
self._enable_pin.valueChanged.connect(self.setEnabled)
# add checkbox.check HAL pin
self._check_pin = comp.addPin(obj_name + ".check", "bit", "in")
self._check_pin.value = self.isChecked()
self._check_pin.valueChanged.connect(self.setChecked)
# add checkbox.checked HAL pin
self._checked_pin = comp.addPin(obj_name + ".checked", "bit", "out")
self._checked_pin.value = self.isChecked()
def __init__(self, *args, **kwargs):
super(MiniVCP, self).__init__(*args, **kwargs)
comp = hal.component('hello')
comp.addPin('testing', 'float', 'in')
comp.addListener('testing', self.onHalTestingChanged)
comp.ready()
def launch_application(opts, config):
qtpyvcp.OPTIONS.update(opts)
qtpyvcp.CONFIG.update(config)
hal_comp = hal.component('qtpyvcp')
LOG.debug('Loading data plugings')
loadPlugins(config['data_plugins'])
log_time('done loading data plugins')
LOG.debug('Initializing app')
app = _initialize_object_from_dict(config['application'])
log_time('done initializing app')
LOG.debug('Loading dialogs')
loadDialogs(config['dialogs'])
log_time('done loading dialogs')
LOG.debug('Loading windows')
loadWindows(config['windows'])
log_time('done loading windows')
except KeyError:
LOG.info("Creating new HAL component: %s", name)
comp = component(name)
return comp
if __name__ == "__main__":
from qtpy.QtWidgets import QApplication
from qtpyvcp import hal
app = QApplication([])
# create a new component and add some pins
comp = hal.getComponent("loop-back")
comp.addPin("in", "float", "in")
comp.addPin("out", "float", "out")
# mark the component as 'ready'
comp.ready()
# define a function to call when the input pin changes
def onInChanged(new_value):
print("loop-back.in pin changed:", new_value)
# loop the out pin to the in pin value
comp.getPin('out').value = new_value
# connect the listener to the input pin
comp.addListener('in', onInChanged)
app.exec_()