本文整理汇总了Python中PyQt4.Qt.QListWidget.setCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.setCurrentItem方法的具体用法?Python QListWidget.setCurrentItem怎么用?Python QListWidget.setCurrentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setCurrentItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PM_Clipboard
# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import setCurrentItem [as 别名]
class PM_Clipboard(PM_GroupBox):
"""
The PM_Clipboard class provides a groupbox containing a list of clipboard
items that can be pasted in the 3D Workspace. The selected item in this
list is shown by its elementViewer (an instance of L{PM_PreviewGroupBox})
The object being previewed can then be deposited into the 3D workspace.
"""
def __init__(self,
parentWidget,
title = 'Clipboard',
win = None,
elementViewer = None
):
"""
Appends a PM_Clipboard groupbox widget to I{parentWidget},a L{PM_Dialog}
@param parentWidget: The parent dialog (Property manager) containing
this widget.
@type parentWidget: L{PM_Dialog}
@param title: The title (button) text.
@type title: str
@param win: MainWindow object
@type win: L{MWsemantics} or None
@param elementViewer: The associated preview pane groupbox. If provided,
The selected item in L{self.clipboardListWidget}
is shown (previewed) by L{elementViewer}.
The object being previewed can then be deposited
into the 3D workspace.
@type elementViewer: L{PM_PreviewGroupBox} or None
"""
self.w = win
self.elementViewer = elementViewer
self.elementViewer.setDisplay(diTUBES)
self.pastableItems = None
PM_GroupBox.__init__(self, parentWidget, title)
self._loadClipboardGroupbox()
def _loadClipboardGroupbox(self):
"""
Load the L{self.clipboardListWidget} widget used to display a list of
clipboard items inside this clipboard groupbox.
"""
self.clipboardListWidget = QListWidget(self)
self.gridLayout.addWidget(self.clipboardListWidget)
#Append to the widget list. This is important for expand -collapse
#functions (of the groupbox) to work properly.
self._widgetList.append(self.clipboardListWidget)
def _updateElementViewer(self, newModel = None):
"""
Update the view of L{self.elementViewer}
@param newModel: The model correseponding to the item selected
in L{self.clipboardListWidget}.
@type newModel: L{molecule} or L{Group}
"""
if not self.elementViewer:
return
assert isinstance(self.elementViewer, MMKitView)
self.elementViewer.resetView()
if newModel:
self.elementViewer.updateModel(newModel)
def update(self):
"""
Updates the clipboard items in the L{PM_Clipboard} groupbox. Also
updates its element viewer.
"""
PM_GroupBox.update(self)
self.pastableItems = self.w.assy.shelf.getPastables()
i = self.clipboardListWidget.currentRow()
self.clipboardListWidget.clear()
newModel = None
if len(self.pastableItems):
for item in self.pastableItems:
self.clipboardListWidget.addItem(item.name)
if i >= self.clipboardListWidget.count():
i = self.clipboardListWidget.count() - 1
if i < 0:
i = 0
self.clipboardListWidget.setCurrentItem(
self.clipboardListWidget.item(i))
newModel = self.pastableItems[i]
#.........这里部分代码省略.........