當前位置: 首頁>>代碼示例>>Python>>正文


Python QListWidget.setMovement方法代碼示例

本文整理匯總了Python中PySide.QtGui.QListWidget.setMovement方法的典型用法代碼示例。如果您正苦於以下問題:Python QListWidget.setMovement方法的具體用法?Python QListWidget.setMovement怎麽用?Python QListWidget.setMovement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySide.QtGui.QListWidget的用法示例。


在下文中一共展示了QListWidget.setMovement方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: QtReducePreferencePane

# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import setMovement [as 別名]
class QtReducePreferencePane(QDialog):
    # QtReducePreferencePane are the dialog windows for setting preferences.
    # Instances are created via menu or keyboard shortcut in QtReduceMainWindow.

    def __init__(self, parent=None):
        super(QtReducePreferencePane, self).__init__(parent)

        self.__createContents()

        self.toolBar = QtReducePreferencesToolBar(self)
        self.worksheet = QtReducePreferencesWorksheet(self)
        self.computation = QtReducePreferencesComputation(self)

        self.pagesWidget = QStackedWidget()
        self.pagesWidget.addWidget(self.toolBar)
        self.pagesWidget.addWidget(self.worksheet)
        self.pagesWidget.addWidget(self.computation)

        self.pagesWidget.setCurrentIndex(
            self.contentsWidget.row(self.contentsWidget.currentItem()))

        closeButton = QPushButton(self.tr("Close"))
        closeButton.clicked.connect(self.close)

        horizontalLayout = QHBoxLayout()
        horizontalLayout.addWidget(self.contentsWidget)
        horizontalLayout.addWidget(self.pagesWidget)

        buttonsLayout = QHBoxLayout()
        buttonsLayout.addStretch(1)
        buttonsLayout.addWidget(closeButton)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(horizontalLayout)
        mainLayout.addLayout(buttonsLayout)

        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("QReduce Preferences"))

    def changePage(self,current,previous):
        if not current:
            current = previous
        QSettings().setValue("preferences/currentitem",current.text())
        self.pagesWidget.setCurrentIndex(self.contentsWidget.row(current))

    def __createContents(self):
        self.contentsWidget = QListWidget()
        self.contentsWidget.setViewMode(QListView.ListMode)
        self.contentsWidget.setMovement(QListView.Static)

        toolBar = QListWidgetItem(self.contentsWidget)
        toolBar.setText(self.tr("Toolbar"))
        toolBar.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        worksheet = QListWidgetItem(self.contentsWidget)
        worksheet.setText(self.tr("Worksheet"))
        worksheet.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        computation = QListWidgetItem(self.contentsWidget)
        computation.setText(self.tr("Computation"))
        computation.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        currentItem = QSettings().value("preferences/currentitem",
                                        self.tr(QtReduceDefaults.CURRENTITEM))
        if currentItem == self.tr("Toolbar"):
            self.contentsWidget.setCurrentItem(toolBar)
        elif currentItem == self.tr("Worksheet"):
            self.contentsWidget.setCurrentItem(worksheet)
        elif currentItem == self.tr("Computation"):
            self.contentsWidget.setCurrentItem(computation)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
開發者ID:webushka,項目名稱:reduce,代碼行數:75,代碼來源:qrpreferences.py


注:本文中的PySide.QtGui.QListWidget.setMovement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。