本文整理汇总了Python中pyqtcore.QMap.get方法的典型用法代码示例。如果您正苦于以下问题:Python QMap.get方法的具体用法?Python QMap.get怎么用?Python QMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QMap
的用法示例。
在下文中一共展示了QMap.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QtButtonPropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import get [as 别名]
class QtButtonPropertyBrowserPrivate():
def __init__(self):
self.q_ptr = None
self.WidgetItem = WidgetItem()
self.m_indexToItem = QMap()
self.m_itemToIndex = QMap()
self.m_widgetToItem = QMap()
self.m_buttonToItem = QMap()
self.m_mainLayout = None
self.m_children = QList()
self.m_recreateQueue = QList()
def createEditor(self, property, parent):
return self.q_ptr.createEditor(property, parent)
def createButton(self, parent=None):
button = QToolButton(parent)
button.setCheckable(True)
button.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed))
button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
button.setArrowType(Qt.DownArrow)
button.setIconSize(QSize(3, 16))
###
#QIcon icon
#icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowDown), QIcon.Normal, QIcon.Off)
#icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowUp), QIcon.Normal, QIcon.On)
#button.setIcon(icon)
###
return button
def gridRow(self, item):
siblings = QList()
if (item.parent):
siblings = item.parent.children
else:
siblings = self.m_children
row = 0
for sibling in siblings:
if (sibling == item):
return row
row += self.gridSpan(sibling)
return -1
def gridSpan(self, item):
if (item.container and item.expanded):
return 2
return 1
def init(self, parent):
self.m_mainLayout = QGridLayout()
parent.setLayout(self.m_mainLayout)
item = QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)
self.m_mainLayout.addItem(item, 0, 0)
def slotEditorDestroyed(self):
editor = self.q_ptr.sender()
if (not editor):
return
if not self.m_widgetToItem.get(editor):
return
self.m_widgetToItem[editor].widget = 0
self.m_widgetToItem.remove(editor)
def slotUpdate(self):
for item in self.m_recreateQueue:
parent = item.parent
w = 0
l = 0
oldRow = self.gridRow(item)
if (parent):
w = parent.container
l = parent.layout
else:
w = self.q_ptr
l = self.m_mainLayout
span = 1
if (not item.widget and not item.widgetLabel):
span = 2
item.label = QLabel(w)
item.label.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
l.addWidget(item.label, oldRow, 0, 1, span)
self.updateItem(item)
self.m_recreateQueue.clear()
def setExpanded(self, item, expanded):
if (item.expanded == expanded):
return
if (not item.container):
return
item.expanded = expanded
row = self.gridRow(item)
parent = item.parent
l = 0
#.........这里部分代码省略.........
示例2: QtTreePropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import get [as 别名]
class QtTreePropertyBrowserPrivate():
def __init__(self):
self.q_ptr = None
self.m_indexToItem = QMap()
self.m_itemToIndex = QMap()
self.m_indexToBackgroundColor = QMap()
self.m_treeWidget = None
self.m_headerVisible = True
self.m_resizeMode = QtTreePropertyBrowser.Stretch
self.m_delegate = None
self.m_markPropertiesWithoutValue = False
self.m_browserChangedBlocked = False
self.m_expandIcon = QIcon()
def init(self, parent):
layout = QHBoxLayout(parent)
layout.setContentsMargins(0, 0, 0, 0)
self.m_treeWidget = QtPropertyEditorView(parent)
self.m_treeWidget.setEditorPrivate(self)
self.m_treeWidget.setIconSize(QSize(18, 18))
layout.addWidget(self.m_treeWidget)
parent.setFocusProxy(self.m_treeWidget)
self.m_treeWidget.setColumnCount(2)
labels = QList()
labels.append(QCoreApplication.translate("QtTreePropertyBrowser", "Property"))
labels.append(QCoreApplication.translate("QtTreePropertyBrowser", "Value"))
self.m_treeWidget.setHeaderLabels(labels)
self.m_treeWidget.setAlternatingRowColors(True)
self.m_treeWidget.setEditTriggers(QAbstractItemView.EditKeyPressed)
self.m_delegate = QtPropertyEditorDelegate(parent)
self.m_delegate.setEditorPrivate(self)
self.m_treeWidget.setItemDelegate(self.m_delegate)
self.m_treeWidget.header().setSectionsMovable(False)
self.m_treeWidget.header().setSectionResizeMode(QHeaderView.Stretch)
self.m_expandIcon = drawIndicatorIcon(self.q_ptr.palette(), self.q_ptr.style())
self.m_treeWidget.collapsed.connect(self.slotCollapsed)
self.m_treeWidget.expanded.connect(self.slotExpanded)
self.m_treeWidget.currentItemChanged.connect(self.slotCurrentTreeItemChanged)
def createEditor(self, property, parent):
return self.q_ptr.createEditor(property, parent)
def currentItem(self):
treeItem = self.m_treeWidget.currentItem()
if treeItem:
return self.m_itemToIndex.get(treeItem)
return 0
def setCurrentItem(self, browserItem, block):
blocked = False
if block:
blocked = self.m_treeWidget.blockSignals(True)
if browserItem == None:
self.m_treeWidget.setCurrentItem(None)
else:
self.m_treeWidget.setCurrentItem(self.m_indexToItem.get(browserItem))
if block:
self.m_treeWidget.blockSignals(blocked)
def indexToProperty(self, index):
item = self.m_treeWidget.indexToItem(index)
idx = self.m_itemToIndex.get(item)
if (idx):
return idx.property()
return 0
def indexToBrowserItem(self, index):
item = self.m_treeWidget.indexToItem(index)
return self.m_itemToIndex.get(item)
def indexToItem(self, index):
return self.m_treeWidget.indexToItem(index)
def lastColumn(self, column):
return self.m_treeWidget.header().visualIndex(column) == self.m_treeWidget.columnCount() - 1
def disableItem(self, item):
flags = item.flags()
if (flags & Qt.ItemIsEnabled):
flags &= ~Qt.ItemIsEnabled
item.setFlags(flags)
self.m_delegate.closeEditor(self.m_itemToIndex[item].property())
childCount = item.childCount()
for i in range(childCount):
child = item.child(i)
self.disableItem(child)
def enableItem(self, item):
flags = item.flags()
flags |= Qt.ItemIsEnabled
item.setFlags(flags)
childCount = item.childCount()
for i in range(childCount):
child = item.child(i)
property = self.m_itemToIndex[child].property()
if property.isEnabled():
#.........这里部分代码省略.........
示例3: DecoratedDoubleSpinBoxFactory
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import get [as 别名]
class DecoratedDoubleSpinBoxFactory(QtAbstractEditorFactory):
def __init__(self, parent=None):
super(DecoratedDoubleSpinBoxFactory, self).__init__(parent)
self.propertyToData = QMap()
# We delegate responsibilities for QtDoublePropertyManager, which is a base class
# of DecoratedDoublePropertyManager to appropriate
self.originalFactory = QtDoubleSpinBoxFactory(self)
self.createdEditors = QMapList()
self.editorToProperty = QMap()
# not need to delete editors because they will be deld by originalFactory in its destructor
def __del__(self):
pass
def connectPropertyManager(self, manager):
self.originalFactory.addPropertyManager(manager)
manager.prefixChangedSignal.connect(self.slotPrefixChanged)
manager.suffixChangedSignal.connect(self.slotSuffixChanged)
def createEditor(self, manager, property, parent):
base = self.originalFactory
w = base.findEditor(property, parent)
if (not w):
return 0
spinBox = w
if (not spinBox):
return 0
spinBox.setPrefix(manager.prefix(property))
spinBox.setSuffix(manager.suffix(property))
self.createdEditors[property].append(spinBox)
self.editorToProperty[spinBox] = property
return spinBox
def disconnectPropertyManager(self, manager):
self.originalFactory.removePropertyManager(manager)
manager.prefixChangedSignal.disconnect(self.slotPrefixChanged)
manager.suffixChangedSignal.disconnect(self.slotSuffixChanged)
def slotPrefixChanged(self, property, prefix):
if (not self.createdEditors.contains(property)):
return
manager = self.propertyManager(property)
if (not manager):
return
editors = self.createdEditors[property]
for editor in editors:
editor.setPrefix(prefix)
def slotSuffixChanged(self, property, prefix):
if (not self.createdEditors.contains(property)):
return
manager = self.propertyManager(property)
if (not manager):
return
editors = self.createdEditors[property]
for editor in editors:
editor.setSuffix(prefix)
def slotEditorDestroyed(self, object):
property = self.editorToProperty.get(object)
if property:
editor = object
self.editorToProperty.remove(editor)
self.createdEditors[property].removeAll(editor)
if (self.createdEditors[property].isEmpty()):
self.createdEditors.remove(property)
return
示例4: QtCursorDatabase
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import get [as 别名]
class QtCursorDatabase():
def __init__(self):
self.m_cursorNames = QList()
self.m_cursorIcons = QMap()
self.m_valueToCursorShape = QMap()
self.m_cursorShapeToValue = QMap()
self.appendCursor(Qt.ArrowCursor, QCoreApplication.translate("QtCursorDatabase", "Arrow"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png"))
self.appendCursor(Qt.UpArrowCursor, QCoreApplication.translate("QtCursorDatabase", "Up Arrow"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png"))
self.appendCursor(Qt.CrossCursor, QCoreApplication.translate("QtCursorDatabase", "Cross"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png"))
self.appendCursor(Qt.WaitCursor, QCoreApplication.translate("QtCursorDatabase", "Wait"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png"))
self.appendCursor(Qt.IBeamCursor, QCoreApplication.translate("QtCursorDatabase", "IBeam"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png"))
self.appendCursor(Qt.SizeVerCursor, QCoreApplication.translate("QtCursorDatabase", "Size Vertical"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png"))
self.appendCursor(Qt.SizeHorCursor, QCoreApplication.translate("QtCursorDatabase", "Size Horizontal"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png"))
self.appendCursor(Qt.SizeFDiagCursor, QCoreApplication.translate("QtCursorDatabase", "Size Backslash"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png"))
self.appendCursor(Qt.SizeBDiagCursor, QCoreApplication.translate("QtCursorDatabase", "Size Slash"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png"))
self.appendCursor(Qt.SizeAllCursor, QCoreApplication.translate("QtCursorDatabase", "Size All"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png"))
self.appendCursor(Qt.BlankCursor, QCoreApplication.translate("QtCursorDatabase", "Blank"),
QIcon())
self.appendCursor(Qt.SplitVCursor, QCoreApplication.translate("QtCursorDatabase", "Split Vertical"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png"))
self.appendCursor(Qt.SplitHCursor, QCoreApplication.translate("QtCursorDatabase", "Split Horizontal"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png"))
self.appendCursor(Qt.PointingHandCursor, QCoreApplication.translate("QtCursorDatabase", "Pointing Hand"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png"))
self.appendCursor(Qt.ForbiddenCursor, QCoreApplication.translate("QtCursorDatabase", "Forbidden"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png"))
self.appendCursor(Qt.OpenHandCursor, QCoreApplication.translate("QtCursorDatabase", "Open Hand"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png"))
self.appendCursor(Qt.ClosedHandCursor, QCoreApplication.translate("QtCursorDatabase", "Closed Hand"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png"))
self.appendCursor(Qt.WhatsThisCursor, QCoreApplication.translate("QtCursorDatabase", "What's This"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png"))
self.appendCursor(Qt.BusyCursor, QCoreApplication.translate("QtCursorDatabase", "Busy"),
QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png"))
def clear(self):
self.m_cursorNames.clear()
self.m_cursorIcons.clear()
self.m_valueToCursorShape.clear()
self.m_cursorShapeToValue.clear()
def appendCursor(self,shape, name, icon):
if self.m_cursorShapeToValue.get(shape):
return
value = len(self.m_cursorNames)
self.m_cursorNames.append(name)
self.m_cursorIcons[value] = icon
self.m_valueToCursorShape[value] = shape
self.m_cursorShapeToValue[shape] = value
def cursorShapeNames(self):
return self.m_cursorNames
def cursorShapeIcons(self):
return self.m_cursorIcons
def cursorToShapeName(self,cursor):
val = self.cursorToValue(cursor)
if val >= 0:
return self.m_cursorNames[val]
return ''
def cursorToShapeIcon(self,cursor):
val = self.cursorToValue(cursor)
return self.m_cursorIcons[val]
def cursorToValue(self,cursor):
shape = cursor.shape()
return self.m_cursorShapeToValue.get(shape, -1)
def valueToCursor(self,value):
if value in self.m_valueToCursorShape:
return QCursor(self.m_valueToCursorShape[value])
return QCursor()