当前位置: 首页>>代码示例>>Python>>正文


Python TaurusWidget.layout方法代码示例

本文整理汇总了Python中taurus.qt.qtgui.container.TaurusWidget.layout方法的典型用法代码示例。如果您正苦于以下问题:Python TaurusWidget.layout方法的具体用法?Python TaurusWidget.layout怎么用?Python TaurusWidget.layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taurus.qt.qtgui.container.TaurusWidget的用法示例。


在下文中一共展示了TaurusWidget.layout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fillWithChildren

# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import layout [as 别名]
    def fillWithChildren(self):
        frame = TaurusWidget()
        frame.setLayout(Qt.QGridLayout())
        frame.layout().addItem(Qt.QSpacerItem(
            0, 0, Qt.QSizePolicy.Minimum, Qt.QSizePolicy.MinimumExpanding))

        parent_name = None
        if self.getUseParentModel():
            parent_model = self.getParentModelObj()
            if parent_model:
                parent_name = parent_model.getFullName()

        for i, model in enumerate(self.getModel()):
            if not model:
                continue
            if parent_name:
                # @todo: Change this (it assumes tango model naming!)
                model = "%s/%s" % (parent_name, model)
            klass, args, kwargs = self.getFormWidget(model=model)
            widget = klass(frame, *args, **kwargs)
            # @todo UGLY... See if this can be done in other ways... (this causes trouble with widget that need more vertical space , like PoolMotorTV)
            widget.setMinimumHeight(20)

            try:
                widget.setCompact(self.isCompact())
                widget.setModel(model)
                widget.setParent(frame)
            except:
                # raise
                self.warning(
                    'an error occurred while adding the child "%s". Skipping' % model)
                self.traceback(level=taurus.Debug)
            try:
                widget.setModifiableByUser(self.isModifiableByUser())
            except:
                pass
            widget.setObjectName("__item%i" % i)
            self.registerConfigDelegate(widget)
            self._children.append(widget)

        frame.layout().addItem(Qt.QSpacerItem(
            0, 0, Qt.QSizePolicy.Minimum, Qt.QSizePolicy.MinimumExpanding))
        self.scrollArea.setWidget(frame)
#        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setMinimumWidth(frame.layout().sizeHint().width() + 20)
开发者ID:cmft,项目名称:taurus,代码行数:47,代码来源:taurusform.py

示例2: TaurusDevicePanel

# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import layout [as 别名]
class TaurusDevicePanel(TaurusWidget):
    '''
    TaurusDevPanel is a Taurus Application inspired in Jive and Atk Panel.

    It Provides a Device selector and a panel for displaying information from
    the selected device.
    '''
    # TODO: Tango-centric (This whole class should be called TangoDevicePanel)
    # TODO: a scheme-agnostic base class should be implemented

    READ_ONLY = False
    # A dictionary like {device_regexp:[attribute_regexps]}
    _attribute_filter = {}
    # A dictionary like {device_regexp:[(command_regexp,default_args)]}
    _command_filter = {}
    _icon_map = {}  # A dictionary like {device_regexp:pixmap_url}

    @classmethod
    def setIconMap(klass, filters):
        """A dictionary like {device_regexp:pixmap_url}"""
        klass._icon_map = filters

    @classmethod
    def getIconMap(klass):
        return klass._icon_map

    @classmethod
    def setAttributeFilters(klass, filters):
        """
        It will set the attribute filters
        filters will be like: {device_regexp:[attribute_regexps]}
        example: {'.*/VGCT-.*': ['ChannelState','p[0-9]']}
        """
        klass._attribute_filter.update(filters)

    @classmethod
    def getAttributeFilters(klass):
        return klass._attribute_filter

    @classmethod
    def setCommandFilters(klass, filters):
        """
        It will set the command filters
        filters will be like: {device_regexp:[command_regexps]}
        example::

          {'.*/IPCT-.*': (
                           ('setmode',('SERIAL','LOCAL','STEP','FIXED','START','PROTECT')),
                           ('onhv1',()), ('offhv1',()), ('onhv2',()), ('offhv2',()),
                           ('sendcommand',())
                         ),}

        """
        klass._command_filter.update(filters)

    @classmethod
    def getCommandFilters(klass):
        return klass._command_filter

    ###########################################################################

    def __init__(self, parent=None, model=None, palette=None, bound=True):
        TaurusWidget.__init__(self, parent)
        if palette:
            self.setPalette(palette)
        self.setLayout(Qt.QGridLayout())
        self.bound = bound
        self._dups = []

        self.setWindowTitle('TaurusDevicePanel')
        self._label = Qt.QLabel()
        self._label.font().setBold(True)

        self._stateframe = TaurusWidget(self)
        self._stateframe.setLayout(Qt.QGridLayout())
        self._stateframe.layout().addWidget(Qt.QLabel('State'), 0, 0, Qt.Qt.AlignCenter)
        self._statelabel = TaurusLabel(self._stateframe)
        self._statelabel.setMinimumWidth(100)
        self._statelabel.setBgRole('state')
        self._stateframe.layout().addWidget(self._statelabel, 0, 1, Qt.Qt.AlignCenter)
        self._state = TaurusLed(self._stateframe)
        self._state.setShowQuality(False)
        self._stateframe.layout().addWidget(self._state, 0, 2, Qt.Qt.AlignCenter)

        self._statusframe = Qt.QScrollArea(self)
        self._status = TaurusLabel(self._statusframe)
        self._status.setBgRole('none')
        self._status.setAlignment(Qt.Qt.AlignLeft)
        self._status.setFixedHeight(2000)
        self._status.setFixedWidth(5000)
        # self._statusframe.setFixedHeight(STATUS_HEIGHT)
        self._statusframe.setHorizontalScrollBarPolicy(Qt.Qt.ScrollBarAlwaysOn)
        self._statusframe.setVerticalScrollBarPolicy(Qt.Qt.ScrollBarAlwaysOn)
        self._statusframe.setWidget(self._status)
        self._statusframe.setPalette(get_White_palette())

        self._attrsframe = Qt.QTabWidget(self)

        # Horizontal will not allow to show labels of attributes!
        self._splitter = Qt.QSplitter(Qt.Qt.Vertical, self)
#.........这里部分代码省略.........
开发者ID:cmft,项目名称:taurus,代码行数:103,代码来源:taurusdevicepanel.py

示例3: __init__

# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import layout [as 别名]
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent, designMode)
        # list representing all macros ids (all from sequence) currently
        # executed
        self._macroIds = []
        self._sequencesPath = str(Qt.QDir.homePath())
        self._sequenceModel = MacroSequenceTreeModel()

        self.registerConfigProperty(
            "sequencesPath", "setSequencesPath", "sequencesPath")

        self.setLayout(Qt.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        splitter = Qt.QSplitter()
        self.layout().addWidget(splitter)
        splitter.setOrientation(Qt.Qt.Vertical)

        sequenceEditor = TaurusWidget()
        splitter.addWidget(sequenceEditor)
        sequenceEditor.setUseParentModel(True)
        sequenceEditor.setLayout(Qt.QVBoxLayout())
        sequenceEditor.layout().setContentsMargins(0, 0, 0, 0)

        self.tree = MacroSequenceTree(sequenceEditor)
        self.sequenceProxyModel = MacroSequenceProxyModel()
        self.sequenceProxyModel.setSourceModel(self._sequenceModel)
        self.tree.setModel(self.sequenceProxyModel)
        self.tree.setItemDelegate(SequenceEditorDelegate(self.tree))

        actionsLayout = Qt.QHBoxLayout()
        actionsLayout.setContentsMargins(0, 0, 0, 0)
        self.newSequenceAction = Qt.QAction(
            getThemeIcon("document-new"), "New", self)
        self.newSequenceAction.triggered.connect(self.onNewSequence)
        self.newSequenceAction.setToolTip("New sequence")
        self.newSequenceAction.setEnabled(False)
        newSequenceButton = Qt.QToolButton()
        newSequenceButton.setDefaultAction(self.newSequenceAction)
        actionsLayout.addWidget(newSequenceButton)

        self.openSequenceAction = Qt.QAction(
            getThemeIcon("document-open"), "Open...", self)
        self.openSequenceAction.triggered.connect(self.onOpenSequence)
        self.openSequenceAction.setToolTip("Open sequence...")
        openSequenceButton = Qt.QToolButton()
        openSequenceButton.setDefaultAction(self.openSequenceAction)
        actionsLayout.addWidget(openSequenceButton)

        self.saveSequenceAction = Qt.QAction(
            getThemeIcon("document-save"), "Save...", self)
        self.saveSequenceAction.triggered.connect(self.onSaveSequence)
        self.saveSequenceAction.setToolTip("Save sequence...")
        self.saveSequenceAction.setEnabled(False)
        saveSequenceButton = Qt.QToolButton()
        saveSequenceButton.setDefaultAction(self.saveSequenceAction)
        actionsLayout.addWidget(saveSequenceButton)

        self.stopSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_stop.svg"), "Stop", self)
        self.stopSequenceAction.triggered.connect(self.onStopSequence)
        self.stopSequenceAction.setToolTip("Stop sequence")
        stopSequenceButton = Qt.QToolButton()
        stopSequenceButton.setDefaultAction(self.stopSequenceAction)
        actionsLayout.addWidget(stopSequenceButton)

        self.pauseSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_pause.svg"), "Pause", self)
        self.pauseSequenceAction.triggered.connect(self.onPauseSequence)
        self.pauseSequenceAction.setToolTip("Pause sequence")
        pauseSequenceButton = Qt.QToolButton()
        pauseSequenceButton.setDefaultAction(self.pauseSequenceAction)
        actionsLayout.addWidget(pauseSequenceButton)

        self.playSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_start.svg"), "Play", self)
        self.playSequenceAction.triggered.connect(self.onPlaySequence)
        self.playSequenceAction.setToolTip("Play sequence")
        playSequenceButton = Qt.QToolButton()
        playSequenceButton.setDefaultAction(self.playSequenceAction)
        actionsLayout.addWidget(playSequenceButton)

        self.doorStateLed = TaurusLed(self)
        actionsLayout.addWidget(self.doorStateLed)

        #@todo this feature will be replaced by checkboxes in the
        # sequence tree view indicating clearing of the plot after execution
        self.fullSequencePlotCheckBox = Qt.QCheckBox(
            "Full sequence plot", self)
        self.fullSequencePlotCheckBox.toggled.connect(self.setFullSequencePlot)
        self.fullSequencePlotCheckBox.setChecked(True)
        actionsLayout.addWidget(self.fullSequencePlotCheckBox)

        spacerItem = Qt.QSpacerItem(
            0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
        actionsLayout.addItem(spacerItem)

        sequenceEditor.layout().addLayout(actionsLayout)

        macroLayout = Qt.QHBoxLayout()
        macroLayout.setContentsMargins(0, 0, 0, 0)
#.........这里部分代码省略.........
开发者ID:rhomspuron,项目名称:sardana,代码行数:103,代码来源:sequenceeditor.py

示例4: TaurusCommandsForm

# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import layout [as 别名]
class TaurusCommandsForm(TaurusWidget):
    '''A form that shows commands available for a Device Server'''

    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent, designMode)

        self.setLayout(Qt.QVBoxLayout())

        self._splitter = Qt.QSplitter()
        self._splitter.setOrientation(Qt.Qt.Vertical)
        self.layout().addWidget(self._splitter)

        self._frame = TaurusWidget(self)
        self._frame.setLayout(Qt.QGridLayout())

        self._scrollArea = TaurusScrollArea(self)
        self._scrollArea.setWidget(self._frame)
        self._scrollArea.setWidgetResizable(True)
        self._splitter.addWidget(self._scrollArea)

        self._outputTE = Qt.QTextEdit()
        self._outputTE.setReadOnly(True)
        self._splitter.addWidget(self._outputTE)
        #self._splitter.moveSplitter(self._splitter.getRange(0)[-1], 0)

        self._cmdWidgets = []
        self._paramWidgets = []
        self._viewFilters = []
        self._defaultParameters = []
        self._sortKey = lambda x: x.cmd_name

        self._operatorViewFilter = lambda x: x.disp_level == PyTango.DispLevel.OPERATOR

        # self.setLayout(Qt.QGridLayout())
        self.modelChanged.connect(self._updateCommandWidgets)

    def createConfig(self, allowUnpickable=False):
        '''
        extending  :meth:`TaurusBaseWidget.createConfig`
        :param alllowUnpickable:  (bool)

        :return: (dict<str,object>) configurations (which can be loaded with :meth:`applyConfig`).

        .. seealso: :meth:`TaurusBaseWidget.createConfig`, :meth:`applyConfig`
        '''
        # get the basic config
        configdict = TaurusWidget.createConfig(
            self, allowUnpickable=allowUnpickable)
        # store the splitter config
        configdict['splitter/state'] = self._splitter.saveState().data()
        return configdict

    def applyConfig(self, configdict, **kwargs):
        """extending :meth:`TaurusBaseWidget.applyConfig` to restore the splitter config

        :param configdict: (dict)

        .. seealso:: :meth:`TaurusBaseWidget.applyConfig`, :meth:`createConfig`
        """
        # first do the basic stuff...
        TaurusWidget.applyConfig(self, configdict, **kwargs)
        # restore the splitter config
        self._splitter.restoreState(
            Qt.QByteArray(configdict['splitter/state']))

    def getModelClass(self):
        '''see :meth:`TaurusBaseComponent.getModelClass`'''
        return taurus.core.taurusdevice.TaurusDevice

    def _updateCommandWidgets(self, *args):
        '''
        Inserts command buttons and parameter widgets in the layout, according to
        the commands from the model
        '''
        #self.debug('In TaurusCommandsForm._updateCommandWidgets())')
        dev = self.getModelObj()
        if dev is None or dev.state != TaurusDevState.Ready:
            self.debug('Cannot connect to device')
            self._clearFrame()
            return
        commands = sorted(dev.command_list_query(), key=self._sortKey)

        for f in self.getViewFilters():
            commands = filter(f, commands)

        self._clearFrame()

        layout = self._frame.layout()

        for row, c in enumerate(commands):
            self.debug('Adding button for command %s' % c.cmd_name)
            button = TaurusCommandButton(command=c.cmd_name, text=c.cmd_name)
            layout.addWidget(button, row, 0)
            button.setUseParentModel(True)
            self._cmdWidgets.append(button)
            button.commandExecuted.connect(self._onCommandExecuted)

            if c.in_type != PyTango.CmdArgType.DevVoid:
                self.debug('Adding arguments for command %s' % c.cmd_name)
                pwidget = ParameterCB()
#.........这里部分代码省略.........
开发者ID:cmft,项目名称:taurus,代码行数:103,代码来源:taurusform.py

示例5: called

# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import layout [as 别名]
# here we call setUseParentModel before the parent is known!

c.setUseParentModel(True)

# we prepare the layouts

m.setLayout(Qt.QVBoxLayout())
p.setLayout(Qt.QVBoxLayout())

# Now, by adding the widgets to the layout we are actually reparenting them.
# The order in which we reparent determines success/failure:
# if we do m-->p and then c-->m, it works, but if we do it in the opposite
# order, we trigger the error.
# (i.e., if we had called "p.layout().addWidget(m)" it would work work)
m.layout().addWidget(c)
p.layout().addWidget(m)

# the problem arises because the Taurus ancestry of c is only checked when:
# a) c.setUseParentModel() is called (and it effectively changes something) or
# b) when c is Qt-reparented
##
# In this example, c is reparented before m, so when it checks for a Taurus
# ancestor, none is found. Then m is reparented and c now would find its right
# Taurus ancestor (p)... but c never gets notified!

# Manually calling c.recheckTaurusParent() after the parenting has changed is
# another way to work around this issue (you can test by uncommenting
# the following line):

# c.recheckTaurusParent()
开发者ID:cmft,项目名称:taurus,代码行数:32,代码来源:parentmodel_issue_demo.py


注:本文中的taurus.qt.qtgui.container.TaurusWidget.layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。