def main(): iutils.initApp() network.getConnection('https://localhost:3880', 'admin', 'admin') srv = network.manager.remote qb = QtGui.QWidget() lay = QtGui.QFormLayout() wgs = [] for d in srv.morla.devices: for m in d.devices: wg = widgets.build(srv, m, m.gete('end')) wgs.append(wg) lay.addRow(m['fullpath'] + m['name'], wg) do = False def up(): logging.debug('up') global do if do: return do = True for wg in wgs: wg.async_get() do = False clock = QtCore.QTimer() clock.connect(clock, QtCore.SIGNAL('timeout()'), up) clock.start(250) qb.setLayout(lay) qb.show() sys.exit(QtGui.qApp.exec_())
def test_human(self): self.root.sete('delay', option.ao({}, 'delay', 'Time')['delay']) self.root.sete( 'delayStart', option.ao({}, 'delayStart', 'Boolean')['delayStart']) w = self.wgGen('delay') w1 = widgets.build(self.root, self.root, self.root.gete('delayStart')) w.lay.addWidget(w1) iutils_testing.show(w, __name__)
def test_human(self): self.root.sete('delay', option.ao({}, 'delay', 'Time')['delay']) self.root.sete('delayStart', option.ao({}, 'delayStart', 'Boolean')['delayStart']) w = self.wgGen('delay') w1 = widgets.build(self.root, self.root, self.root.gete('delayStart')) w.lay.addWidget(w1) iutils_testing.show(w, __name__)
def test_role(self): w = widgets.build(self.root, self.root, self.root.gete('role')) self.assertEqual(w.current, ['/dev/', 'default']) e = widgets.RoleEditor(w) self.assertEqual(e.tree.current_fullpath(), '/dev/') self.assertEqual(e.config.itemData(e.config.currentIndex()), 'default') self.assertFalse(hasattr(e, 'io')) iutils_testing.show(w, __name__)
def test_io(self): w = widgets.build(self.root, self.root, self.root.gete('roleio')) self.assertEqual(w.prop['options'], ['/dev/', 'default', 'value']) e = widgets.RoleEditor(w) self.assertEqual(e.tree.current_fullpath(), '/dev/') ci = e.config.currentIndex() self.assertEqual(e.config.itemData(ci), 'default') ei = e.io.currentIndex() self.assertEqual(e.io.itemData(ei), 'value') e.io.setCurrentIndex(ei - 1) nval = e.io.itemData(e.io.currentIndex()) e.apply() iutils_testing.show(w, __name__)
def update(self): """ Draw the referred widget""" self.prop = self.remObj.gete(self.handle) if not self.prop: logging.warning('Cannot get option ', self.handle) return opt = self.prop['options'] if opt[0] == '.': path = '.' obj = self.remObj else: path = self.server.searchPath(opt[0]) obj = self.server.toPath(opt[0]) logging.debug('RoleIO search', opt[0], path, obj) fu = False # Is update needed? if self.value: if hasattr(self.value, 'prop'): kid = opt[0] + opt[-1] if kid == self.value.prop['kid']: logging.debug('RoleIO: no update', kid) return fu = self.value.force_update # Remove old widget self.lay.removeWidget(self.value) self.value.hide() self.value.close() # Recreate widget if path and obj and opt[2] not in ('None', None): from misura.client.widgets import build refopt = obj.gete(opt[2]) if 'Hidden' in [refopt['type']]+refopt['attr']: self.label_widget.hide() self.hide() raise RuntimeError('RoleIO points towards an hidden option.') self.value = build(self.server, obj, refopt) if self.io_menu: self.emenu.removeAction(self.io_menu) self.io_menu = self.emenu.addMenu(self.value.emenu) self.io_menu.setText(_('Referred option')) self.value.label_widget.hide() self.value.force_update = fu # TODO: manage units and menu, which is bounded to label_widget else: logging.debug('Pointless RoleIO', path, obj, opt[2]) self.value = QtGui.QLabel('None') self.lay.addWidget(self.value) self.ioact.setText('{}: {} : {}'.format(*opt))
def update(self): """ Draw the referred widget""" self.prop = self.remObj.gete(self.handle) if not self.prop: logging.warning('Cannot get option ', self.handle) return opt = self.prop['options'] if opt[0] == '.': path = '.' obj = self.remObj else: path = self.server.searchPath(opt[0]) obj = self.server.toPath(opt[0]) logging.debug('RoleIO search', opt[0], path, obj) fu = False # Is update needed? if self.value: if hasattr(self.value, 'prop'): kid = opt[0] + opt[-1] if kid == self.value.prop['kid']: logging.debug('RoleIO: no update', kid) return fu = self.value.force_update # Remove old widget self.lay.removeWidget(self.value) self.value.hide() self.value.close() # Recreate widget if path and obj and opt[2] not in ('None', None): from misura.client.widgets import build refopt = obj.gete(opt[2]) if 'Hidden' in [refopt['type']] + refopt['attr']: self.label_widget.hide() self.hide() raise RuntimeError('RoleIO points towards an hidden option.') self.value = build(self.server, obj, refopt) if self.io_menu: self.emenu.removeAction(self.io_menu) self.io_menu = self.emenu.addMenu(self.value.emenu) self.io_menu.setText(_('Referred option')) self.value.label_widget.hide() self.value.force_update = fu # TODO: manage units and menu, which is bounded to label_widget else: logging.debug('Pointless RoleIO', path, obj, opt[2]) self.value = QtGui.QLabel('None') self.lay.addWidget(self.value) self.ioact.setText('{}: {} : {}'.format(*opt))
def wgGen(self): self.assertTrue(self.root.has_key('test')) widget = widgets.build(self.root, self.root, self.root.gete('test')) # The current value is not initialized (gete() returns {current:None} ) self.assertTrue(widget is not False) return widget
def wgGen(self): self.assertTrue(self.root.has_key('test')) widget = widgets.build(self.root, self.root, self.root.gete('test')) self.assertTrue(widget is not False) return widget
def wgGen(self, name): self.assertTrue(self.root.has_key(name)) widget = widgets.build(self.root, self.root, self.root.gete(name)) self.assertTrue(widget is not False) return widget
def wgGen(self): self.assertTrue(self.root.has_key('Test')) w = widgets.build(self.root, self.root, self.root.gete('Test')) # The current value is not initialized (gete() returns {current:None} ) self.assertTrue(w is not False) return w
def wgGen(self, k='val'): self.assertTrue(self.root.has_key(k)) w = widgets.build(self.root, self.root, self.root.gete(k)) # The current value is not initialized (gete() returns {current:None} ) self.assertTrue(w is not False) return w