Get QIcon from wrapper
966428
def icon(self):
        """"""
        if self._icon is None:
            self._icon = QIcon(self.pm())
        return self._icon
336968
def _get_function_wrapper(
        self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]
    ) -> typing.Callable[..., typing.Any]:
        
        raise NotImplementedError()
638046
def get_icon(name, as_qicon=False):
    """"""
    filename = name + ".png"
    icon = icons.get(filename)
    if not icon:
        path = os.path.dirname(__file__)
        path = os.path.join(path, "icons")
        filepath = os.path.join(path, filename)
        if not os.path.exists(filepath):
            filepath = os.path.join(path, "pink.png")

        icon = QtGui.QPixmap(filepath)
        icons[filename] = icon

    return QtGui.QIcon(icon) if as_qicon else icon
720088
def wrap(ptr, base=None):
    
    if ptr is None:
        return None
    ptr = long(ptr) # Ensure type
    if base is None:
        qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
        metaObj = qObj.metaObject()
        cls = metaObj.className()
        superCls = metaObj.superClass().className()
        if hasattr(QtGui, cls):
            base = getattr(QtGui, cls)
        elif hasattr(QtGui, superCls):
            base = getattr(QtGui, superCls)
        else:
            base = QtGui.QWidget
    return shiboken.wrapInstance(long(ptr), base)
361271
def load_from_conf(self):
        """"""
        for checkbox, (option, default) in list(self.checkboxes.items()):
            checkbox.setChecked(self.get_option(option, default))
            # QAbstractButton works differently for PySide and PyQt
            if not API == 'pyside':
                checkbox.clicked.connect(lambda _foo, opt=option:
                                         self.has_been_modified(opt))
            else:
                checkbox.clicked.connect(lambda opt=option:
                                         self.has_been_modified(opt))
        for radiobutton, (option, default) in list(self.radiobuttons.items()):
            radiobutton.setChecked(self.get_option(option, default))
            radiobutton.toggled.connect(lambda _foo, opt=option:
                                        self.has_been_modified(opt))
            if radiobutton.restart_required:
                self.restart_options[option] = radiobutton.label_text
        for lineedit, (option, default) in list(self.lineedits.items()):
            lineedit.setText(self.get_option(option, default))
            lineedit.textChanged.connect(lambda _foo, opt=option:
                                         self.has_been_modified(opt))
            if lineedit.restart_required:
                self.restart_options[option] = lineedit.label_text
        for textedit, (option, default) in list(self.textedits.items()):
            textedit.setPlainText(self.get_option(option, default))
            textedit.textChanged.connect(lambda opt=option:
                                         self.has_been_modified(opt))
            if textedit.restart_required:
                self.restart_options[option] = textedit.label_text
        for spinbox, (option, default) in list(self.spinboxes.items()):
            spinbox.setValue(self.get_option(option, default))
            spinbox.valueChanged.connect(lambda _foo, opt=option:
                                         self.has_been_modified(opt))
        for combobox, (option, default) in list(self.comboboxes.items()):
            value = self.get_option(option, default)
            for index in range(combobox.count()):
                data = from_qvariant(combobox.itemData(index), to_text_string)
                # For PyQt API v2, it is necessary to convert `data` to
                # unicode in case the original type was not a string, like an
                # integer for example (see qtpy.compat.from_qvariant):
                if to_text_string(data) == to_text_string(value):
                    break
            else:
                if combobox.count() == 0:
                    index = None
            if index:
                combobox.setCurrentIndex(index)
            combobox.currentIndexChanged.connect(lambda _foo, opt=option:
                                                 self.has_been_modified(opt))
            if combobox.restart_required:
                self.restart_options[option] = combobox.label_text

        for (fontbox, sizebox), option in list(self.fontboxes.items()):
            font = self.get_font(option)
            fontbox.setCurrentFont(font)
            sizebox.setValue(font.pointSize())
            if option is None:
                property = 'plugin_font'
            else:
                property = option
            fontbox.currentIndexChanged.connect(lambda _foo, opt=property:
                                                self.has_been_modified(opt))
            sizebox.valueChanged.connect(lambda _foo, opt=property:
                                         self.has_been_modified(opt))
        for clayout, (option, default) in list(self.coloredits.items()):
            property = to_qvariant(option)
            edit = clayout.lineedit
            btn = clayout.colorbtn
            edit.setText(self.get_option(option, default))
            # QAbstractButton works differently for PySide and PyQt
            if not API == 'pyside':
                btn.clicked.connect(lambda _foo, opt=option:
                                    self.has_been_modified(opt))
            else:
                btn.clicked.connect(lambda opt=option:
                                    self.has_been_modified(opt))
            edit.textChanged.connect(lambda _foo, opt=option:
                                     self.has_been_modified(opt))
        for (clayout, cb_bold, cb_italic
             ), (option, default) in list(self.scedits.items()):
            edit = clayout.lineedit
            btn = clayout.colorbtn
            color, bold, italic = self.get_option(option, default)
            edit.setText(color)
            cb_bold.setChecked(bold)
            cb_italic.setChecked(italic)
            edit.textChanged.connect(lambda _foo, opt=option:
                                     self.has_been_modified(opt))
            # QAbstractButton works differently for PySide and PyQt
            if not API == 'pyside':
                btn.clicked.connect(lambda _foo, opt=option:
                                    self.has_been_modified(opt))
                cb_bold.clicked.connect(lambda _foo, opt=option:
                                        self.has_been_modified(opt))
                cb_italic.clicked.connect(lambda _foo, opt=option:
                                          self.has_been_modified(opt))
            else:
                btn.clicked.connect(lambda opt=option:
                                    self.has_been_modified(opt))
                cb_bold.clicked.connect(lambda opt=option:
                                        self.has_been_modified(opt))
                cb_italic.clicked.connect(lambda opt=option:
                                          self.has_been_modified(opt))
843836
def _pyside2():
    

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken2
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide2 import shiboken2

        Qt.QtCompat.wrapInstance = (
            lambda ptr, base=None: _wrapinstance(
                shiboken2.wrapInstance, ptr, base)
        )
        Qt.QtCompat.getCppPointer = lambda object: \
            shiboken2.getCppPointer(object)[0]

    except ImportError:
        pass  # Optional

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.qInstallMessageHandler = _qInstallMessageHandler
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PySide2")
    _build_compatibility_members("PySide2")
432376
def getfnc_qual_ev(self):
        """"""
        fnc_key = (
            self.nd_not2desc[(self._keep_nd, self._keep_not)],
            self.incexc2num[(
                self.include_evcodes is not None,
                self.exclude_evcodes is not None)],
        )
        return self.param2fnc[fnc_key]
412934
def show_qparams(qtype, stream=sys.stdout):
    """"""
    for cls in all_subclasses(QueueAdapter):
        if cls.QTYPE == qtype: return stream.write(cls.QTEMPLATE)

    raise ValueError("Cannot find class associated to qtype %s" % qtype)
655197
def _widget_from_p(self, pname, ptype):
        """"""

        widget_name = self.type2widget[ptype].__name__.lower()
        widget_name = "_".join([widget_name, pname])
        return getattr(self, widget_name)
436178
def config(_config=None, **kwargs):
    
    if _config is None:
        _config = {}
    _config.update(kwargs)

    def wrapper(func):
        func._config = _config
        return func
    return wrapper
171557
def get_context(self, name, value, attrs):
        """"""
        context = {}
        context['widget'] = {
            'name': name,
            'type': 'text',
            'is_hidden': self.is_hidden,
            'required': self.is_required,
            'value': self.format_value(value),
            'attrs': {**self.attrs, **(attrs or {})},
            'template_name': self.template_name,
        }
        return context
74855
def data(self, index, role=Qt.DisplayRole):
        

        if not index.isValid():
            return QVariant()

        node = self.get_node(index)
        if index.column() == 0:
            if hasattr(node, "roles"):
                if role == Qt.DecorationRole:
                    return QIcon(node.roles.get(role, ""))
                else:
                    return node.roles.get(role, QVariant())
        else:
            attribute = self.get_attribute(node, index.column())
            if attribute:
                if hasattr(attribute, "roles"):
                    if role == Qt.DecorationRole:
                        return QIcon(attribute.roles.get(role, ""))
                    else:
                        return attribute.roles.get(role, QVariant())
        return QVariant()
900000
def init(scope):
    
    # update globals
    scope['py2q'] = py2q
    scope['q2py'] = q2py
    
    # define wrapper compatibility symbols
    QtCore.THREADSAFE_NONE = None
    
    # define the importable symbols
    scope['QtCore'] = QtCore
    scope['QtGui'] = lazy_import('PyQt4.QtGui')
    scope['QtWebKit'] = lazy_import('PyQt4.QtWebKit')
    scope['QtNetwork'] = lazy_import('PyQt4.QtNetwork')
    scope['QtXml'] = lazy_import('PyQt4.QtXml')
    
    # PyQt4 specific modules
    scope['QtDesigner'] = lazy_import('PyQt4.QtDesigner')
    scope['Qsci'] = lazy_import('PyQt4.Qsci')
    
    scope['uic'] = lazy_import('PyQt4.uic')
    scope['rcc_exe'] = 'pyrcc4'
    
    # map shared core properties
    QtCore.QDate.toPython = lambda x: x.toPyDate()
    QtCore.QDateTime.toPython = lambda x: x.toPyDateTime()
    QtCore.QTime.toPython = lambda x: x.toPyTime()
    
    QtCore.Signal = Signal
    QtCore.Slot = Slot
    QtCore.Property = QtCore.pyqtProperty
    QtCore.SIGNAL = SIGNAL
    QtCore.__version__ = QtCore.QT_VERSION_STR

    if SIP_VERSION == '2':
        QtCore.QStringList = list
        QtCore.QString = unicode
287146
def getConf(self, conftype):
        '''
        
        '''
        if conftype not in [ZooConst.CLIENT, ZooConst.WORKER, ZooConst.BROKER]:
            raise Exception('Zooborg.getConf: invalid type')

        zooconf={}

        #TODO: specialconf entries for the mock

        if conftype == ZooConst.CLIENT:
            zooconf['broker'] = {}
            zooconf['broker']['connectionstr'] = b"tcp://localhost:5555"

        elif conftype == ZooConst.BROKER:
            zooconf['bindstr']=b"tcp://*:5555"

        elif conftype == ZooConst.WORKER:
            zooconf['broker'] = {}
            zooconf['broker']['connectionstr'] = b"tcp://localhost:5555"

        else:
            raise Exception("ZooBorgconftype unknown")


        return zooconf
388469
def get_ai_chans(dev):
    
    buf = create_string_buffer(512)
    buflen = c_uint32(sizeof(buf))
    DAQmxGetDevAIPhysicalChans(dev.encode(), buf, buflen)
    pybuf = buf.value
    chans = pybuf.decode(u'utf-8').split(u", ")
    return chans
1109347
def _ufunc_wrapper(ufunc, name=None):
    
    if not isinstance(ufunc, np.ufunc):
        raise TypeError('{} is not a ufunc'.format(ufunc))

    ufunc_name = ufunc.__name__
    # Get hold of the masked array equivalent, if it exists.
    ma_ufunc = getattr(np.ma, ufunc_name, None)
    if ufunc.nin == 2 and ufunc.nout == 1:
        func = _dual_input_fn_wrapper('np.{}'.format(ufunc_name), ufunc,
                                      ma_ufunc, name)
    elif ufunc.nin == 1 and ufunc.nout == 1:
        func = _unary_fn_wrapper('np.{}'.format(ufunc_name), ufunc, ma_ufunc,
                                 name)
    else:
        raise ValueError('Unsupported ufunc {!r} with {} input arrays & {} '
                         'output arrays.'.format(ufunc_name, ufunc.nin,
                                                 ufunc.nout))
    return func
546682
def _extract_device_name_from_event(event):
  """"""
  plugin_data_content = json.loads(
      tf.compat.as_str(event.summary.value[0].metadata.plugin_data.content))
  return plugin_data_content['device']