本文整理汇总了Python中PyQt4.QtGui.QListView.setIconSize方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setIconSize方法的具体用法?Python QListView.setIconSize怎么用?Python QListView.setIconSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.setIconSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Strategies
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setIconSize [as 别名]
class Strategies(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setMinimumSize(250, 1)
self.setupUI()
self.activeStrategy = None
def setupUI(self):
lay = QVBoxLayout()
lay.setContentsMargins(0, 0, 0, 0)
self.removeButton = QPushButton(QIcon(QPixmap("img/moduleRemove.png")), "")
self.addButton = QPushButton(QIcon(QPixmap("img/moduleAdd.png")),"")
self.reloadButton = QPushButton(QIcon(QPixmap("img/moduleReload.png")), "")
self.model = Model(self)
self.list = QListView()
self.list.setModel(self.model)
self.list.setIconSize(QSize(32, 32))
lay.addWidget(self.list)
hlay = QHBoxLayout()
hlay.setContentsMargins(0, 0, 0, 0)
hlay.addWidget(self.reloadButton)
hlay.addStretch()
hlay.addWidget(self.removeButton)
hlay.addWidget(self.addButton)
lay.addLayout(hlay)
self.setLayout(lay)
self.addButton.clicked.connect(self.addButtonClick)
self.removeButton.clicked.connect(self.removeButtonClick)
self.reloadButton.clicked.connect(self.reloadButtonClick)
self.list.doubleClicked.connect(self.selectStrategy)
self.modules = {}
def load(self, path):
if path:
module = self._createModule(path)
if module is not None:
self.model.add(module)
self.emit(SIGNAL('moduleLoaded'), module)
# Kompiluje moduł do wykonywania i dodaje go do listy strategii
def addButtonClick(self):
path = str( QFileDialog.getOpenFileName(parent=self, caption=u"Wybierz plik", filter=u"Moduły Python (*.py)", directory="../") )
if path:
module = self._createModule(path)
if module is not None:
self.model.add(module)
self.emit(SIGNAL('moduleLoaded'), module)
# Przeladowuje podany modul
def reloadButtonClick(self):
try:
index = self.list.selectedIndexes()[0];
module = self.model.get(index)
newModule = self._createModule(module.__path__)
self.model.list[index.row()] = newModule
if self.activeStrategy == module:
#self.activeStrategy = newModule
#self.model.dataChanged.emit(index, index)
self.emit(SIGNAL('moduleReloaded'), newModule)
self.selectStrategy(index)
except IndexError:
pass
# Usuwa zaznaczoną strategię
def removeButtonClick(self):
module = self.model.get(self.list.selectedIndexes()[0])
self.model.remove(self.list.selectedIndexes()[0])
self.emit(SIGNAL('moduleRemoved'), module)
if self.activeStrategy == module:
self.activeStrategy = None
self.emit(SIGNAL('strategyChanged'), module, None)
# Wybiera aktywną strategię (2xklik na liście)
def selectStrategy(self, index = None):
if index == None:
index = self.list.selectedIndexes()[0];
old = self.activeStrategy
new = self.model.get(index)
if old != new:
self.activeStrategy = new
else:
self.activeStrategy = None
self.model.dataChanged.emit(index, index)
self.emit(SIGNAL('strategyChanged'), old, self.activeStrategy)
def _verifyModule(self, module):
#.........这里部分代码省略.........
示例2: QtListControl
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setIconSize [as 别名]
#.........这里部分代码省略.........
# owner = getattr(item, 'item_owner', None)
# if owner is not None:
# owner.on_double_clicked()
#--------------------------------------------------------------------------
# ProxyListControl API
#--------------------------------------------------------------------------
def set_item_model(self, model):
""" Set the item model for the widget.
"""
if model is None:
self.widget.setModel(None)
else:
self.widget.setModel(QItemModelWrapper(model))
def set_model_column(self, column):
""" Set the model column for the widget.
"""
self.widget.setModelColumn(column)
def set_view_mode(self, mode):
""" Set the view mode of the underlying control.
"""
# Always set static movement for now. This can be revisited in
# the future if the need arises to support movable items.
widget = self.widget
widget.setViewMode(VIEW_MODES[mode])
widget.setMovement(QListView.Static)
def set_resize_mode(self, mode):
""" Set the resize mode of the underlying control.
"""
self.widget.setResizeMode(RESIZE_MODES[mode])
def set_flow_mode(self, mode):
""" Set the flow mode of the underlying control.
"""
if mode == 'default':
if self.widget.viewMode() == QListView.ListMode:
qflow = QListView.TopToBottom
else:
qflow = QListView.LeftToRight
else:
qflow = FLOW_MODES[mode]
self.widget.setFlow(qflow)
def set_item_wrap(self, wrap):
""" Set the item wrapping on the underlying control.
"""
if wrap is None:
wrap = self.widget.viewMode() == QListView.IconMode
self.widget.setWrapping(wrap)
def set_word_wrap(self, wrap):
""" Set the word wrap on the underlying control.
"""
self.widget.setWordWrap(wrap)
def set_item_spacing(self, spacing):
""" Set the item spacing on the underlying control.
"""
self.widget.setSpacing(spacing)
def set_icon_size(self, size):
""" Set the icon size on the underlying control.
"""
self.widget.setIconSize(QSize(*size))
def set_uniform_item_sizes(self, uniform):
""" Set the uniform item sizes flag on the underlying control.
"""
self.widget.setUniformItemSizes(uniform)
def set_layout_mode(self, mode):
""" Set the layout mode on the underlying control.
"""
self.widget.setLayoutMode(LAYOUT_MODES[mode])
def set_batch_size(self, size):
""" Set the batch size on the underlying control.
"""
self.widget.setBatchSize(size)
def refresh_items_layout(self):
""" Refresh the items layout.
"""
pass
示例3: RemotePicturesGui
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setIconSize [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)
#.........这里部分代码省略.........