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


Python QWidget.setTabOrder方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setTabOrder [as 别名]
  def __init__(self, *args, **kwargs):
    # set parent
    super().__init__(kwargs['main_window'])

    self.setModal(True)
    self.show()
    
    self.setWindowTitle("New Course")

    self.setFixedSize(400, 150)

    # main widget
    #main_widget = QWidget()
    main_layout = QBoxLayout(QBoxLayout.TopToBottom)

    # form widget
    form_widget = QWidget()
    form_layout = QFormLayout()
    form_layout.setFormAlignment(QtCore.Qt.AlignLeft)
    new_course_label = QLabel("Course Name:")
    new_course_entry = CustomLineEdit(default_entry="<Enter course name>")
    new_course_entry.setFixedWidth(230)
    form_layout.addRow(new_course_label, new_course_entry)
    form_widget.setLayout(form_layout)

    # action buttons
    action_widget = QWidget()
    add_course_button = QPushButton("Add Course")
    cancel_button = QPushButton("Cancel")
    action_layout = QBoxLayout(QBoxLayout.LeftToRight)
    action_layout.addWidget(cancel_button)
    action_layout.addWidget(add_course_button)
    action_widget.setLayout(action_layout)
    action_widget.setTabOrder(add_course_button, cancel_button)

    # add widgets
    main_layout.addWidget(form_widget)
    main_layout.addWidget(action_widget)
    self.setLayout(main_layout)

    new_course_entry.setFocus()
    new_course_entry.selectAll()
开发者ID:schmudu,项目名称:gradebook,代码行数:44,代码来源:new_course_dialog.py

示例2: init

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setTabOrder [as 别名]
    def init(self, volumina):
        self.editor = volumina

        self.hudsShown = [True] * 3

        def onViewFocused():
            axis = self.editor._lastImageViewFocus
            self.toggleSelectedHUD.setChecked(self.editor.imageViews[axis]._hud.isVisible())

        self.editor.newImageView2DFocus.connect(onViewFocused)

        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        self.setLayout(self.layout)

        # setup quadview
        axisLabels = ["X", "Y", "Z"]
        axisColors = [QColor("#dc143c"), QColor("green"), QColor("blue")]
        for i, v in enumerate(self.editor.imageViews):
            v.hud = ImageView2DHud(v)
            # connect interpreter
            v.hud.createImageView2DHud(axisLabels[i], 0, axisColors[i], QColor("white"))
            v.hud.sliceSelector.valueChanged.connect(partial(self.editor.navCtrl.changeSliceAbsolute, axis=i))

        self.quadview = QuadView(
            self, self.editor.imageViews[2], self.editor.imageViews[0], self.editor.imageViews[1], self.editor.view3d
        )
        self.quadview.installEventFilter(self)
        self.quadViewStatusBar = QuadStatusBar()
        self.quadViewStatusBar.createQuadViewStatusBar(
            QColor("#dc143c"), QColor("white"), QColor("green"), QColor("white"), QColor("blue"), QColor("white")
        )
        self.quadview.addStatusBar(self.quadViewStatusBar)
        self.layout.addWidget(self.quadview)

        # Little hack: Can't call setTabOrder on these widgets until the
        #              layout has been added to a widget, so we do this here.
        QWidget.setTabOrder(self.quadViewStatusBar.zSpinBox, self.quadViewStatusBar.timeSpinBox)

        # Here we subscribe to the dirtyChanged() signal from all slicing views,
        #  and show the status bar "busy indicator" if any view is dirty.
        # Caveat: To avoid a flickering indicator for quick updates, we use a
        #         timer that prevents the indicator from showing for a bit.
        def updateDirtyStatus(fromTimer=False):
            # We only care about views that are both VISIBLE and DIRTY.
            dirties = [v.scene().dirty for v in self.editor.imageViews]
            visibilities = [v.isVisible() for v in self.editor.imageViews]
            visible_dirtiness = numpy.logical_and(visibilities, dirties)

            if not any(visible_dirtiness):
                # Not dirty: Hide immediately
                self.quadViewStatusBar.busyIndicator.setVisible(False)
            else:
                if fromTimer:
                    # The timer finished and we're still dirty:
                    # Time to show the busy indicator.
                    self.quadViewStatusBar.busyIndicator.setVisible(True)
                elif not self.quadViewStatusBar.busyIndicator.isVisible() and not self._dirtyTimer.isActive():
                    # We're dirty, but delay for a bit before showing the busy indicator.
                    self._dirtyTimer.start(750)

        self._dirtyTimer = QTimer()
        self._dirtyTimer.setSingleShot(True)
        self._dirtyTimer.timeout.connect(partial(updateDirtyStatus, fromTimer=True))
        for i, view in enumerate(self.editor.imageViews):
            view.scene().dirtyChanged.connect(updateDirtyStatus)

        # If the user changes the position in the quad-view status bar (at the bottom),
        # Update the position of the whole editor.
        def setPositionFromQuadBar(x, y, z):
            self.editor.posModel.slicingPos = (x, y, z)
            self.editor.posModel.cursorPos = (x, y, z)
            self.editor.navCtrl.panSlicingViews((x, y, z), [0, 1, 2])

        self.quadViewStatusBar.positionChanged.connect(setPositionFromQuadBar)

        ## Why do we have to prevent TimerEvents reaching the SpinBoxes?
        #
        # Sometimes clicking a SpinBox once caused the value to increase by
        # two. This is why:
        #
        # When a MouseClicked event is received by the SpinBox it fires a timerevent to control
        # the repeated increase of the value as long as the mouse button is pressed. The timer
        # is killed when it receives a MouseRelease event. If a slot connected to the valueChanged
        # signal of the SpinBox takes to long to process the signal the mouse release
        # and timer events get queued up and sometimes the timer event reaches the widget before
        # the mouse release event. That's why it increases the value by another step. To prevent
        # this we are blocking the timer events at the cost of no autorepeat anymore.
        #
        # See also:
        # http://lists.trolltech.com/qt-interest/2002-04/thread00137-0.html
        # http://www.qtcentre.org/threads/43078-QSpinBox-Timer-Issue
        # http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/widgets/qabstractspinbox.cpp#line1195
        self.quadview.statusBar.timeSpinBox.installEventFilter(_timerEater)

        def setTime(t):
            if t == self.editor.posModel.time:
                return
#.........这里部分代码省略.........
开发者ID:ilastik,项目名称:volumina,代码行数:103,代码来源:volumeEditorWidget.py


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