本文整理汇总了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)