How to use the pydm.utilities.is_pydm_app function in pydm

To help you get started, we’ve selected a few pydm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slaclab / pydm / pydm / widgets / embedded_display.py View on Github external
Returns
        -------
        display : QWidget
        """
        if (not force) and (not self._needs_load):
            return
            
        if not self.filename:
            return
        # Expand user (~ or ~user) and environment variables.
        fname = os.path.expanduser(os.path.expandvars(self.filename))
        if self.base_path:
            full_fname = os.path.join(self.base_path, fname)
        else:
            full_fname = fname
        if not is_pydm_app():
            (filename, extension) = os.path.splitext(full_fname)
            if extension == ".ui":
                loadfunc = load_ui_file
            elif extension == ".py":
                loadfunc = load_py_file
            try:
                w = loadfunc(full_fname, macros=self.parsed_macros())
                self._needs_load = False
                self.clear_error_text()
                return w
            except Exception as e:
                logger.exception("Exception while opening embedded display file.")
                self.display_error_text(e)
            return None
        
        # If you get this far, you are running inside a PyDMApplication, load
github slaclab / pydm / pydm / widgets / embedded_display.py View on Github external
self._disconnect_when_hidden = True
        self._is_connected = False
        self._only_load_when_shown = True
        self._needs_load = True
        self.base_path = ""
        self.base_macros = {}
        if is_pydm_app():
            self.base_path = self.app.directory_stack[-1]
            self.base_macros = self.app.macro_stack[-1]
        self.layout = QVBoxLayout(self)
        self.err_label = QLabel(self)
        self.err_label.setAlignment(Qt.AlignHCenter)
        self.layout.addWidget(self.err_label)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.err_label.hide()
        if not is_pydm_app():
            self.setFrameShape(QFrame.Box)
        else:
            self.setFrameShape(QFrame.NoFrame)
github slaclab / rogue / python / pyrogue / pydm / data_plugins / rogue_plugin.py View on Github external
def __init__(self, channel, address, protocol=None, parent=None):
        super(RogueConnection, self).__init__(channel, address, protocol, parent)

        self.app = QApplication.instance()

        self._host, self._port, self._path, self._mode = parseAddress(address)

        self._cmd    = False
        self._int    = False
        self._node   = None
        self._enum   = None
        self._notDev = False
        self._address = address

        if utilities.is_pydm_app():
            self._client = pyrogue.interfaces.VirtualClient(self._host, self._port)
            self._node   = self._client.root.getNode(self._path)

        if self._node is not None and not self._node.isinstance(pyrogue.Device):
            self._node.addListener(self._updateVariable)
            self._notDev = True

            if self._node.isinstance(pyrogue.BaseCommand):
                self._cmd = True

            if self._node.disp == 'enum' and self._node.enum is not None and self._node.mode != 'RO':
                self._enum = list(self._node.enum.values())

            elif self._mode == 'value' and ('Int' in self._node.typeStr or self._node.typeStr == 'int'):
                self._int = True