• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QTabWidget

    下一话题

    QTabBar

    QStatusBar

    概要

    函数

    信号

    详细描述

    PySide.QtGui.QStatusBar class provides a horizontal bar suitable for presenting status information.

    Each status indicator falls into one of three categories:

    • Temporary - briefly occupies most of the status bar. Used to explain tool tip texts or menu entries, for example.
    • Normal - occupies part of the status bar and may be hidden by temporary messages. Used to display the page and line number in a word processor, for example.
    • Permanent - is never hidden. Used for important mode indications, for example, some applications put a Caps Lock indicator in the status bar.

    PySide.QtGui.QStatusBar lets you display all three types of indicators.

    Typically, a request for the status bar functionality occurs in relation to a PySide.QtGui.QMainWindow 对象。 PySide.QtGui.QMainWindow provides a main application window, with a menu bar, tool bars, dock widgets and a status bar around a large central widget. The status bar can be retrieved using the QMainWindow.statusBar() function, and replaced using the QMainWindow.setStatusBar() 函数。

    使用 PySide.QtGui.QStatusBar.showMessage() slot to display a temporary message:

    def createStatusBar(self):
        statusBar().showMessage(tr("Ready"))
    										

    To remove a temporary message, use the PySide.QtGui.QStatusBar.clearMessage() slot, or set a time limit when calling PySide.QtGui.QStatusBar.showMessage() 。例如:

    def print(self)
        document = textEdit.document()
        printer = QPrinter()
        dlg =  QPrintDialog(&printer, self)
        if dlg.exec() != QDialog.Accepted:
            return
        document.print(printer)
        statusBar().showMessage(tr("Ready"), 2000)
    									

    使用 PySide.QtGui.QStatusBar.currentMessage() function to retrieve the temporary message currently shown. The PySide.QtGui.QStatusBar class also provide the PySide.QtGui.QStatusBar.messageChanged() signal which is emitted whenever the temporary status message changes.

    Normal and Permanent messages are displayed by creating a small widget ( PySide.QtGui.QLabel , PySide.QtGui.QProgressBar or even PySide.QtGui.QToolButton ) and then adding it to the status bar using the PySide.QtGui.QStatusBar.addWidget() PySide.QtGui.QStatusBar.addPermanentWidget() function. Use the PySide.QtGui.QStatusBar.removeWidget() function to remove such messages from the status bar.

    statusBar().addWidget(MyReadWriteIndication())
    										

    默认情况下 PySide.QtGui.QStatusBar 提供 PySide.QtGui.QSizeGrip in the lower-right corner. You can disable it using the PySide.QtGui.QStatusBar.setSizeGripEnabled() function. Use the PySide.QtGui.QStatusBar.isSizeGripEnabled() function to determine the current status of the size grip.

    ../../_images/plastique-statusbar.png

    另请参阅

    PySide.QtGui.QMainWindow PySide.QtGui.QStatusTipEvent GUI Design Handbook: Status Bar 应用程序范例

    class PySide.QtGui. QStatusBar ( [ parent=None ] )
    参数: parent PySide.QtGui.QWidget

    Constructs a status bar with a size grip and the given parent .

    PySide.QtGui.QStatusBar. addPermanentWidget ( widget [ , stretch=0 ] )
    参数:

    添加给定 widget permanently to this status bar, reparenting the widget if it isn't already a child of this PySide.QtGui.QStatusBar 对象。 stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

    Permanently means that the widget may not be obscured by temporary messages. It is is located at the far right of the status bar.

    PySide.QtGui.QStatusBar. addWidget ( widget [ , stretch=0 ] )
    参数:

    添加给定 widget to this status bar, reparenting the widget if it isn't already a child of this PySide.QtGui.QStatusBar 对象。 stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

    The widget is located to the far left of the first permanent widget (see PySide.QtGui.QStatusBar.addPermanentWidget() ) and may be obscured by temporary messages.

    PySide.QtGui.QStatusBar. clearMessage ( )

    Removes any temporary message being shown.

    PySide.QtGui.QStatusBar. currentMessage ( )
    返回类型: unicode

    Returns the temporary message currently shown, or an empty string if there is no such message.

    PySide.QtGui.QStatusBar. hideOrShow ( )

    Ensures that the right widgets are visible.

    Used by the PySide.QtGui.QStatusBar.showMessage() and PySide.QtGui.QStatusBar.clearMessage() 函数。

    PySide.QtGui.QStatusBar. insertPermanentWidget ( index , widget [ , stretch=0 ] )
    参数:
    返回类型:

    PySide.QtCore.int

    Inserts the given widget at the given index permanently to this status bar, reparenting the widget if it isn't already a child of this PySide.QtGui.QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

    stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

    Permanently means that the widget may not be obscured by temporary messages. It is is located at the far right of the status bar.

    PySide.QtGui.QStatusBar. insertWidget ( index , widget [ , stretch=0 ] )
    参数:
    返回类型:

    PySide.QtCore.int

    Inserts the given widget at the given index to this status bar, reparenting the widget if it isn't already a child of this PySide.QtGui.QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

    stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

    The widget is located to the far left of the first permanent widget (see PySide.QtGui.QStatusBar.addPermanentWidget() ) and may be obscured by temporary messages.

    PySide.QtGui.QStatusBar. isSizeGripEnabled ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the PySide.QtGui.QSizeGrip in the bottom-right corner of the status bar is enabled.

    The size grip is enabled by default.

    PySide.QtGui.QStatusBar. messageChanged ( text )
    参数: text – unicode
    PySide.QtGui.QStatusBar. reformat ( )

    Changes the status bar's appearance to account for item changes.

    Special subclasses may need this function, but geometry management will usually take care of any necessary rearrangements.

    PySide.QtGui.QStatusBar. removeWidget ( widget )
    参数: widget PySide.QtGui.QWidget

    移除指定 widget from the status bar.

    注意

    This function does not delete the widget but hides it. To add the widget again, you must call both the PySide.QtGui.QStatusBar.addWidget() and PySide.QtGui.QWidget.show() 函数。

    PySide.QtGui.QStatusBar. setSizeGripEnabled ( arg__1 )
    参数: arg__1 PySide.QtCore.bool

    This property holds whether the PySide.QtGui.QSizeGrip in the bottom-right corner of the status bar is enabled.

    The size grip is enabled by default.

    PySide.QtGui.QStatusBar. showMessage ( text [ , timeout=0 ] )
    参数:
    • text – unicode
    • timeout PySide.QtCore.int

    Hides the normal status indications and displays the given message for the specified number of milli-seconds ( timeout )。若 timeout is 0 (default), the message remains displayed until the PySide.QtGui.QStatusBar.clearMessage() slot is called or until the PySide.QtGui.QStatusBar.showMessage() slot is called again to change the message.

    注意: PySide.QtGui.QStatusBar.showMessage() is called to show temporary explanations of tool tip texts, so passing a timeout of 0 is not sufficient to display a permanent message .