当前位置: 首页>>代码示例>>Python>>正文


Python QMap.keys方法代码示例

本文整理汇总了Python中pyqtcore.QMap.keys方法的典型用法代码示例。如果您正苦于以下问题:Python QMap.keys方法的具体用法?Python QMap.keys怎么用?Python QMap.keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqtcore.QMap的用法示例。


在下文中一共展示了QMap.keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: removeRow

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import keys [as 别名]
    def removeRow(self, layout, row):
        itemToPos = QMap()
        idx = 0
        while (idx < len(layout)):
            r, c, rs, cs = layout.getItemPosition(idx)
            if (r > row):
                itemToPos[layout.takeAt(idx)] = QRect(r - 1, c, rs, cs)
            else:
                idx += 1

        for k in itemToPos.keys():
            r = itemToPos[k]
            layout.addItem(k, r.x(), r.y(), r.width(), r.height())
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:15,代码来源:qtbuttonpropertybrowser.py

示例2: insertRow

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import keys [as 别名]
    def insertRow(self, layout, row):
        itemToPos = QMap()
        idx = 0
        while (idx < layout.count()):
            r, c, rs, cs = layout.getItemPosition(idx)
            if (r >= row):
                itemToPos[layout.takeAt(idx)] = QRect(r + 1, c, rs, cs)
            else:
                idx += 1

        for it in itemToPos.keys():
            r = itemToPos[it]
            layout.addItem(it, r.x(), r.y(), r.width(), r.height())
开发者ID:theall,项目名称:Python-Tiled,代码行数:15,代码来源:qtgroupboxpropertybrowser.py

示例3: QtGroupBoxPropertyBrowserPrivate

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import keys [as 别名]
class QtGroupBoxPropertyBrowserPrivate():
    def __init__(self):
        self.q_ptr = None
        self.m_indexToItem = QMap()
        self.m_itemToIndex = QMap()
        self.m_widgetToItem = QMap()
        self.m_mainLayout = 0
        self.m_children = QList()
        self.m_recreateQueue = QList()

    def createEditor(self, property, parent):
        return self.q_ptr.createEditor(property, parent)

    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 editor in self.m_widgetToItem.keys()):
            return
        self.m_widgetToItem[editor].widget = 0
        self.m_widgetToItem.remove(editor)

    def slotUpdate(self):
        for item in self.m_recreateQueue:
            par = item.parent
            w = 0
            l = 0
            oldRow = -1
            if (not par):
                w = self.q_ptr
                l = self.m_mainLayout
                oldRow = self.m_children.indexOf(item)
            else:
                w = par.groupBox
                l = par.layout
                oldRow = par.children.indexOf(item)
                if (self.hasHeader(par)):
                    oldRow += 2

            if (item.widget):
                item.widget.setParent(w)
            elif (item.widgetLabel):
                item.widgetLabel.setParent(w)
            else:
                item.widgetLabel = QLabel(w)
                item.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed))
                item.widgetLabel.setTextFormat(Qt.PlainText)

            span = 1
            if (item.widget):
                l.addWidget(item.widget, oldRow, 1, 1, 1)
            elif (item.widgetLabel):
                l.addWidget(item.widgetLabel, oldRow, 1, 1, 1)
            else:
                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 updateLater(self):
        QTimer.singleShot(0, self.q_ptr, self.slotUpdate())

    def propertyInserted(self, index, afterIndex):
        afterItem = self.m_indexToItem[afterIndex]
        parentItem = self.m_indexToItem.value(index.parent())

        newItem = WidgetItem()
        newItem.parent = parentItem

        layout = 0
        parentWidget = 0
        row = -1
        if (not afterItem):
            row = 0
            if (parentItem):
                parentItem.children.insert(0, newItem)
            else:
                self.m_children.insert(0, newItem)
        else:
            if (parentItem):
                row = parentItem.children.indexOf(afterItem) + 1
                parentItem.children.insert(row, newItem)
            else:
                row = self.m_children.indexOf(afterItem) + 1
                self.m_children.insert(row, newItem)

        if (parentItem and self.hasHeader(parentItem)):
            row += 2

        if (not parentItem):
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:qtgroupboxpropertybrowser.py

示例4: TilesetManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import keys [as 别名]

#.........这里部分代码省略.........
            imgSrc = tileset.imageSource()
            if (imgSrc != ''):
                self.mWatcher.addPath(imgSrc)

    ##
    # Removes a tileset reference. When the last reference has been removed,
    # the tileset is no longer watched for changes.
    ##
    def removeReference(self, tileset):
        if self.mTilesets[tileset]:
            self.mTilesets[tileset] -= 1
        if (self.mTilesets[tileset] == 0):
            self.mTilesets.remove(tileset)
            if (tileset.imageSource()!=''):
                self.mWatcher.removePath(tileset.imageSource())

    ##
    # Convenience method to add references to multiple tilesets.
    # @see addReference
    ##
    def addReferences(self, tilesets):
        for tileset in tilesets:
            self.addReference(tileset)

    ##
    # Convenience method to remove references from multiple tilesets.
    # @see removeReference
    ##
    def removeReferences(self, tilesets):
        for tileset in tilesets:
            self.removeReference(tileset)

    ##
    # Returns all currently available tilesets.
    ##
    def tilesets(self):
        return self.mTilesets.keys()

    ##
    # Forces a tileset to reload.
    ##
    def forceTilesetReload(self, tileset):
        if (not self.mTilesets.contains(tileset)):
            return
        fileName = tileset.imageSource()
        if (tileset.loadFromImage(fileName)):
            self.tilesetChanged.emit(tileset)

    ##
    # Sets whether tilesets are automatically reloaded when their tileset
    # image changes.
    ##
    def setReloadTilesetsOnChange(self, enabled):
        self.mReloadTilesetsOnChange = enabled
        # TODO: Clear the file system watcher when disabled

    def reloadTilesetsOnChange(self):
        return self.mReloadTilesetsOnChange
    ##
    # Sets whether tile animations are running.
    ##
    def setAnimateTiles(self, enabled):
        # TODO: Avoid running the driver when there are no animated tiles
        if (enabled):
            self.mAnimationDriver.start()
        else:
            self.mAnimationDriver.stop()

    def animateTiles(self):
        return self.mAnimationDriver.state() == QAbstractAnimation.Running

    def fileChanged(self, path):
        if (not self.mReloadTilesetsOnChange):
            return
        ##
        # Use a one-shot timer since GIMP (for example) seems to generate many
        # file changes during a save, and some of the intermediate attempts to
        # reload the tileset images actually fail (at least for .png files).
        ##
        self.mChangedFiles.insert(path)
        self.mChangedFilesTimer.start()

    def fileChangedTimeout(self):
        for tileset in self.tilesets():
            fileName = tileset.imageSource()
            if (self.mChangedFiles.contains(fileName)):
                if (tileset.loadFromImage(fileName)):
                    self.tilesetChanged.emit(tileset)

        self.mChangedFiles.clear()

    def advanceTileAnimations(self, ms):
        # TODO: This could be more optimal by keeping track of the list of
        # actually animated tiles
        for tileset in self.tilesets():
            imageChanged = False
            for tile in tileset.tiles():
                imageChanged |= tile.advanceAnimation(ms)
            if (imageChanged):
                self.repaintTileset.emit(tileset)
开发者ID:theall,项目名称:Python-Tiled,代码行数:104,代码来源:tilesetmanager.py

示例5: MainWindow

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import keys [as 别名]

#.........这里部分代码省略.........
        item = QtCanvasLine(self.canvas)
        item.setPoints(0, 0, rand() % self.canvas.width() - self.canvas.width() / 2, rand() % self.canvas.height() - self.canvas.height() / 2)
        item.move(rand() % self.canvas.width(), rand() % self.canvas.height())
        item.setPen(QPen(QColor(rand() % 32*8, rand() % 32*8, rand() % 32*8), 6))
        item.setZ(rand() % 256)
        item.show()
        return item

    def addText(self):
        item = QtCanvasText(self.canvas)
        item.setText(self.tr("Text"))
        item.setColor(QColor(rand() % 32*8, rand() % 32*8, rand() % 32*8))
        item.move(rand() % self.canvas.width(), rand() % self.canvas.height())
        item.setZ(rand() % 256)
        item.show()
        return item

    def itemMoved(self, item):
        if (item != self.currentItem or self.currentItem.isNone()):
            return

        self.doubleManager.setValue(self.idToProperty["xpos"], item.x())
        self.doubleManager.setValue(self.idToProperty["ypos"], item.y())
        self.doubleManager.setValue(self.idToProperty["zpos"], item.z())

    def updateExpandState(self):
        l = self.propertyEditor.topLevelItems()
        for item in l:
            prop = item.property()
            self.idToExpanded[self.propertyToId[prop]] = self.propertyEditor.isExpanded(item)

    def itemClicked(self, item):
        self.updateExpandState()
        for p in self.propertyToId.keys():
            p.destroy()
        self.propertyToId.clear()
        self.idToProperty.clear()

        self.currentItem = item
        if (not self.currentItem or self.currentItem.isNone()):
            self.deleteAction.setEnabled(False)
            return

        self.deleteAction.setEnabled(True)

        property = self.doubleManager.addProperty(self.tr("Position X"))
        self.doubleManager.setRange(property, 0, self.canvas.width())
        self.doubleManager.setValue(property, item.x())
        self.addProperty(property, "xpos")

        property = self.doubleManager.addProperty(self.tr("Position Y"))
        self.doubleManager.setRange(property, 0, self.canvas.height())
        self.doubleManager.setValue(property, item.y())
        self.addProperty(property, "ypos")

        property = self.doubleManager.addProperty(self.tr("Position Z"))
        self.doubleManager.setRange(property, 0, 256)
        self.doubleManager.setValue(property, item.z())
        self.addProperty(property, "zpos")

        if (item.rtti() == RttiValues.Rtti_Rectangle):
            i = item

            property = self.colorManager.addProperty(self.tr("Brush Color"))
            self.colorManager.setValue(property, i.brush().color())
            self.addProperty(property, "brush")
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:70,代码来源:canvas_typed.py


注:本文中的pyqtcore.QMap.keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。