本文整理汇总了Python中PyQt4.QtGui.QListView.setViewMode方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setViewMode方法的具体用法?Python QListView.setViewMode怎么用?Python QListView.setViewMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.setViewMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ResultWin
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setViewMode [as 别名]
class ResultWin(QMainWindow):
""" Window use to display pylint results """
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.parent = parent
try:
self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
except AttributeError:
pass
self.list_view = QListView()
self.list_model = ResultModel()
self.list_view.setViewMode(QListView.ListMode)
self.list_view.setWordWrap(True)
self.list_view.setResizeMode(QListView.Adjust)
self.list_view.setModel(self.list_model)
self.setCentralWidget(self.list_view)
def set_results(self, results):
""" Set the tuple in the model """
self.list_model.set_data(results)
def append_results(self, results):
""" Append the tuple in the model """
self.list_model.append_data(results)
示例2: QuickAccessWidget
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setViewMode [as 别名]
class QuickAccessWidget(QFrame):
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setFrameStyle(QFrame.Box | QFrame.Sunken)
self.setStyleSheet("QListView {background: transparent; }")
self.setLayout(QHBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.listView = QListView(self)
self.layout().addWidget(self.listView)
self.listView.setModel(self.window().quickAccessModel)
self.listView.setMovement(QListView.Snap)
self.listView.setFlow(QListView.LeftToRight)
self.listView.setResizeMode(QListView.Adjust)
gridSize = self.logicalDpiX() / 96 * 60
self.listView.setGridSize(QSize(gridSize, gridSize))
self.listView.setViewMode(QListView.IconMode)
self.listView.activated.connect(self.listView.model().runShortcut)
示例3: DesktopIconWidget
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setViewMode [as 别名]
class DesktopIconWidget(QFrame):
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setFrameStyle(QFrame.Box | QFrame.Sunken)
self.setStyleSheet("QListView{background:transparent;}")
self.listView = QListView(self)
self.setLayout(QHBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().addWidget(self.listView)
self.listView.setContextMenuPolicy(Qt.CustomContextMenu)
self.listView.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.listView.setMovement(QListView.Snap)
self.listView.setFlow(QListView.LeftToRight)
self.listView.setResizeMode(QListView.Adjust)
self.listView.setGridSize(QSize(self.logicalDpiX() / 96 * 70,
self.logicalDpiY() / 96 * 70))
self.listView.setViewMode(QListView.IconMode)
self.quickDesktopModel = QuickDesktopModel(self.window().platform.databaseFile)
self.listView.setModel(self.quickDesktopModel)
self.createActions()
self.makeConnections()
def createActions(self):
self.actionCreateComputer = QAction(self.trUtf8("我的电脑(&C)"), self)
self.actionCreateDocuments = QAction(self.trUtf8("我的文档(&D)"), self)
self.actionCreateMusic = QAction(self.trUtf8("我的音乐(&M)"), self)
self.actionCreatePictures = QAction(self.trUtf8("我的图片(&P)"), self)
self.actionCreateShortcut = QAction(self.trUtf8("创建快捷方式(&C)"), self)
self.actionCreateShortcut.setIcon(QIcon(":/images/new.png"))
self.actionCreateBookmark = QAction(self.trUtf8("创建网络链接(&B)"), self)
self.actionCreateBookmark.setIcon(QIcon(":/images/insert-link.png"))
self.actionRemoveShortcut = QAction(self.trUtf8("删除快捷方式(&R)"), self)
self.actionRemoveShortcut.setIcon(QIcon(":/images/delete.png"))
self.actionRenameShortcut = QAction(self.trUtf8("重命名(&N)"), self)
self.actionRenameShortcut.setIcon(QIcon(":/images/edit-rename.png"))
self.actionEditShortcut = QAction(self.trUtf8("编辑快捷方式(&E)"), self)
self.actionEditShortcut.setIcon(QIcon(":/images/edit.png"))
def makeConnections(self):
self.listView.customContextMenuRequested.connect(self.onQuickDesktopContextMenuRequest)
self.listView.activated.connect(self.runQuickDesktopShortcut)
self.actionCreateComputer.triggered.connect(self.createComputerShortcut)
self.actionCreateDocuments.triggered.connect(self.createDocumentsShortcut)
self.actionCreateMusic.triggered.connect(self.createMusicShortcut)
self.actionCreatePictures.triggered.connect(self.createPicturesShortcut)
self.actionCreateShortcut.triggered.connect(self.createShortcut)
self.actionCreateBookmark.triggered.connect(self.createBookmark)
self.actionEditShortcut.triggered.connect(self.editShortcut)
self.actionRemoveShortcut.triggered.connect(self.removeShortcut)
self.actionRenameShortcut.triggered.connect(self.renameShortcut)
def onQuickDesktopContextMenuRequest(self, pos):
index = self.listView.indexAt(pos)
self.listView.setCurrentIndex(index)
menu = QMenu()
menu.addAction(self.actionCreateShortcut)
menu.addAction(self.actionCreateBookmark)
menu2 = menu.addMenu(self.trUtf8("创建特殊快捷方式(&S)"))
if os.name == "nt":
menu2.addAction(self.actionCreateComputer)
menu2.addAction(self.actionCreateDocuments)
menu2.addAction(self.actionCreatePictures)
menu2.addAction(self.actionCreateMusic)
if index.isValid():
menu.addAction(self.actionRemoveShortcut)
if not self.quickDesktopModel.isSpecialShortcut(index):
menu.addAction(self.actionEditShortcut)
menu.addAction(self.actionRenameShortcut)
try:
getattr(menu, "exec")(QCursor.pos())
except AttributeError:
getattr(menu, "exec_")(QCursor.pos())
def createShortcut(self):
d = ShortcutDialog(self)
if self.window().runDialog(d.create) == QDialog.Accepted:
shortcut = d.getResult()
shortcut["id"] = str(uuid.uuid4())
self.quickDesktopModel.addShortcut(shortcut)
d.deleteLater()
def createBookmark(self):
d = BookmarkDialog(self)
if self.window().runDialog(d.create) == QDialog.Accepted:
shortcut = {
"id": str(uuid.uuid4()),
"icon": "",
"openwith": "",
"dir": "",
}
shortcut.update(d.getResult())
self.quickDesktopModel.addShortcut(shortcut)
d.deleteLater()
def createComputerShortcut(self):
shortcut = {
#.........这里部分代码省略.........
示例4: RemotePicturesGui
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setViewMode [as 别名]
class RemotePicturesGui(QStackedWidget):
openCategory = pyqtSignal(object) # category
displayNext = pyqtSignal(object, int) # current category, current ID
displayPrev = pyqtSignal(object, int) # current category, current ID
pictureDownloaded = pyqtSignal(object, object, object) # current category, url, pic data
minOpacityChanged = pyqtSignal(float)
maxOpacityChanged = pyqtSignal(float)
setCategoryThumbnail = pyqtSignal(object, QImage) # category, thumbnail pixmap
_categoryOpened = pyqtSignal() # used to flash hidden widgets
def __init__(self, parent, logger, smoothScaling, minOpacity, maxOpacity):
super(RemotePicturesGui, self).__init__(parent)
self.logger = logger
self.good = True
self.settings = None
self.categoryPictures = {}
self.currentCategory = None
self.curPicIndex = 0
self.categoryModel = CategoriesModel(logger)
self.sortProxy = None
self.categoryView = QListView(self)
self.categoryView.setViewMode(QListView.IconMode);
self.categoryView.setIconSize(QSize(200,200));
self.categoryView.setResizeMode(QListView.Adjust);
self.categoryView.doubleClicked.connect(self._itemDoubleClicked)
self.categoryView.setFrameShape(QFrame.NoFrame)
self.sortProxy = QSortFilterProxyModel(self)
self.sortProxy.setSortCaseSensitivity(Qt.CaseInsensitive)
self.sortProxy.setSortRole(CategoriesModel.SORT_ROLE)
self.sortProxy.setDynamicSortFilter(True)
self.sortProxy.setSourceModel(self.categoryModel)
self.sortProxy.sort(0)
self.categoryView.setModel(self.sortProxy)
self.addWidget(self.categoryView)
self.imageLabel = ResizingWebImageLabel(self, self.logger, smooth_scaling=smoothScaling)
self.imageLabel.imageDownloaded.connect(self.pictureDownloadedSlot)
self.imageLabel.setContextMenuPolicy(Qt.CustomContextMenu)
self.imageLabel.customContextMenuRequested.connect(self._showImageContextMenu)
imageViewerLayout = QVBoxLayout(self.imageLabel)
imageViewerLayout.setContentsMargins(0, 0, 0, 0)
imageViewerLayout.setSpacing(0)
defaultFont = self.font()
self.categoryLabel = HiddenLabel(self.imageLabel, self.logger, fontSize=16, fontOptions=QFont.Bold)
topLayout = QHBoxLayout(self.categoryLabel)
topLayout.setContentsMargins(0, 0, 0, 0)
backButton = QToolButton(self.categoryLabel)
backButton.setFont(QFont(defaultFont.family(), defaultFont.pointSize(), 0))
backButton.setFocusPolicy(Qt.NoFocus)
backButton.setArrowType(Qt.LeftArrow)
backButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
backButton.setText("Categories")
topLayout.addWidget(backButton, 0, Qt.AlignLeft)
imageViewerLayout.addWidget(self.categoryLabel, 0)
navButtonsWidget = QWidget(self.imageLabel)
navButtonsLayout = QHBoxLayout(navButtonsWidget)
navButtonsLayout.setContentsMargins(0, 0, 0, 0)
self.prevButton = HiddenToolButton(self.imageLabel, self.logger)
self.prevButton.setArrowType(Qt.LeftArrow)
self.prevButton.setEnabled(False)
self.prevButton.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)
navButtonsLayout.addWidget(self.prevButton, 0, Qt.AlignLeft)
self.nextButton = HiddenToolButton(self.imageLabel, self.logger)
self.nextButton.setArrowType(Qt.RightArrow)
self.nextButton.setEnabled(False)
self.nextButton.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)
navButtonsLayout.addWidget(self.nextButton, 0, Qt.AlignRight)
imageViewerLayout.addWidget(navButtonsWidget, 1)
self.descriptionLabel = HiddenLabel(self.imageLabel, self.logger, fontSize=14)
self.descriptionLabel.setWordWrap(True)
imageViewerLayout.addWidget(self.descriptionLabel, 0)
self.addWidget(self.imageLabel)
self.nextButton.clicked.connect(self._displayNextImage)
self.prevButton.clicked.connect(self._displayPreviousImage)
backButton.clicked.connect(partial(self.setCurrentIndex, 0))
self._initializeHiddenWidget(self.categoryLabel)
self._initializeHiddenWidget(self.prevButton)
self._initializeHiddenWidget(self.nextButton)
self._initializeHiddenWidget(self.descriptionLabel)
self.minOpacityChanged.emit(float(minOpacity) / 100.)
self.maxOpacityChanged.emit(float(maxOpacity) / 100.)
def getCategoryIcon(self, cat):
return self.categoryModel.getCategoryIcon(cat)
#.........这里部分代码省略.........