• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python resources.resourcePath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mcedit2.util.resources.resourcePath函数的典型用法代码示例。如果您正苦于以下问题:Python resourcePath函数的具体用法?Python resourcePath怎么用?Python resourcePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __init__

    def __init__(self, rootTag, parent=None):
        super(NBTTreeModel, self).__init__(parent)

        self.rootItem = MakeNBTTreeItem(rootTag, None)
        self.rootTag = rootTag
        self.allowNameChanges = True
        self.addIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/add.png"))
        self.removeIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/remove.png"))
开发者ID:EvilSupahFly,项目名称:mcedit2,代码行数:8,代码来源:nbttreemodel.py


示例2: pickToolAction

    def pickToolAction(self):
        name = self.name
        iconName = self.iconName
        if iconName:
            iconPath = resourcePath("mcedit2/assets/mcedit2/toolicons/%s.png" % iconName)
            if not os.path.exists(iconPath):
                log.error("Tool icon %s not found", iconPath)
                icon = None
            else:
                icon = QtGui.QIcon(iconPath)
        else:
            icon = None

        action = QtGui.QAction(
            self.tr(name),
            self,
            #shortcut=self.toolShortcut(name),  # xxxx coordinate with view movement keys
            triggered=self.pick,
            checkable=True,
            icon=icon,
            enabled=not(self.editorSession.readonly and self.modifiesWorld)
            )
        action.toolName = name

        return action
开发者ID:mcedit,项目名称:mcedit2,代码行数:25,代码来源:__init__.py


示例3: loadPNGFile

def loadPNGFile(filename):
    img = QtGui.QImage()
    filename = resourcePath("mcedit2/assets/mcedit2/textures/%s" % filename)

    if not img.load(filename):
        raise IOError, "Failed to read PNG file " + filename
    return loadPNGImage(img)
开发者ID:101baja202,项目名称:mcedit2,代码行数:7,代码来源:load_png.py


示例4: __init__

    def __init__(self, rootTag, blocktypes):
        """

        Parameters
        ----------
        rootTag : mceditlib.nbt.TAG_Compound
        blocktypes : mceditlib.blocktypes.BlockTypeSet

        """
        super(NBTTreeModel, self).__init__()
        self.blocktypes = blocktypes
        self.rootItem = MakeNBTTreeItem(rootTag, None)
        self.rootTag = rootTag
        self.allowNameChanges = True
        self.addIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/add.png"))
        self.removeIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/remove.png"))
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:16,代码来源:nbttreemodel.py


示例5: __init__

    def __init__(self, *args, **kwargs):
        addShapes = kwargs.pop('addShapes', None)
        super(ShapeWidget, self).__init__(*args, **kwargs)
        buttons = self.buttons = []
        self.groupBox = QtGui.QGroupBox("Shape:")

        flowLayout = flowlayout.FlowLayout()
        actionGroup = QtGui.QActionGroup(self)
        actionGroup.setExclusive(True)
        iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
        actions = {}
        shapes = list(getShapes())
        if addShapes:
            shapes.extend(addShapes)

        for shape in shapes:
            if shape.icon is not None:
                filename = os.path.join(iconBase, shape.icon)
                assert os.path.exists(filename), "%r does not exist" % filename
                icon = QtGui.QIcon(filename)
                if icon is None:
                    log.warn("Failed to read shape icon file %s" % filename)
            else:
                icon = None

            def _handler(shape):
                def handler():
                    self.currentShape = shape
                    BrushShapeSetting.setValue(shape.ID)
                    self.shapeChanged.emit(shape)
                return handler
            if icon is None:
                action = QtGui.QAction(shape.ID, self, triggered=_handler(shape))
            else:
                action = QtGui.QAction(icon, shape.ID, self, triggered=_handler(shape))
            button = QtGui.QToolButton()
            action.setCheckable(True)
            button.setDefaultAction(action)
            button.setIconSize(QtCore.QSize(32, 32))
            buttons.append(button)
            flowLayout.addWidget(button)
            actionGroup.addAction(action)
            actions[shape.ID] = action
            shape.optionsChanged.connect(self.shapeOptionsChanged.emit)

        self.optionsHolder = QtGui.QStackedWidget()
        layout = Column(flowLayout, (self.optionsHolder, 1))
        self.groupBox.setLayout(layout)
        self.setLayout(Column(self.groupBox, margin=0))

        currentID = BrushShapeSetting.value(shapes[0].ID)
        shapesByID = {shape.ID: shape for shape in shapes}
        if currentID not in actions:
            currentID = shapes[0].ID
        actions[currentID].setChecked(True)

        self.currentShape = shapesByID.get(currentID, shapes[0])

        self.shapeChanged.connect(self.shapeDidChange)
        self.shapeDidChange(self.currentShape)
开发者ID:nkjcqvcpi,项目名称:mcedit2,代码行数:60,代码来源:shapewidget.py


示例6: __init__

    def __init__(self):
        super(RotationWidget, self).__init__()
        self.setupUi(self)

        self.xRotSlider.valueChanged.connect(self.setXRot)
        self.yRotSlider.valueChanged.connect(self.setYRot)
        self.zRotSlider.valueChanged.connect(self.setZRot)

        self.xRotSlider.sliderReleased.connect(self.sliderReleased)
        self.yRotSlider.sliderReleased.connect(self.sliderReleased)
        self.zRotSlider.sliderReleased.connect(self.sliderReleased)

        self.xRotSpinBox.valueChanged.connect(self.setXRot)
        self.yRotSpinBox.valueChanged.connect(self.setYRot)
        self.zRotSpinBox.valueChanged.connect(self.setZRot)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/right_angle.png"))
        self.xRot90Button.setIcon(icon)
        self.yRot90Button.setIcon(icon)
        self.zRot90Button.setIcon(icon)

        self.xRot90Button.clicked.connect(self.xRot90Clicked)
        self.yRot90Button.clicked.connect(self.yRot90Clicked)
        self.zRot90Button.clicked.connect(self.zRot90Clicked)

        self.xRot = self.yRot = self.zRot = 0
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:26,代码来源:rotation_widget.py


示例7: __init__

    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: MapPanel
        """
        super(MapPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)

        self.editorSession = editorSession
        self.pixmapItem = None
        self.mapListModel = None

        self.setupUi(self)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_map.png"))
        action = QtGui.QAction(icon, self.tr("Edit Maps"), self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.reloadModel()

        self.mapListView.clicked.connect(self.mapListClicked)

        self.splitter.splitterMoved.connect(self.updatePixmapSize)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)

        self.importImageButton.clicked.connect(self.importImage)

        self.deleteMapButton.clicked.connect(self.deleteMap)

        self.currentlyEditingLabel.setVisible(False)
        self.displayFirstMap()
开发者ID:mcedit,项目名称:mcedit2,代码行数:34,代码来源:map.py


示例8: __init__

    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(f=Qt.Tool)

        self.editorSession = editorSession
        self.selectedUUID = None

        load_ui("panels/player.ui", baseinstance=self)

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)
        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except PlayerNotFound:
            log.info("No single-player.")
            singlePlayerUUID = None
        except KeyError:
            log.info("Failed to get single-player UUID.")
            singlePlayerUUID = None

        for UUID in playerUUIDs:  # xxx live update?
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID  # xxx mojang api here
                try:
                    UUID = uuid.UUID(hex=UUID)
                    if UUID == singlePlayerUUID:
                        continue  # Don't count single-player twice when it appears under playerData/
                except ValueError:  # badly formed uuid?
                    log.warn("Could not get a UUID from %s", UUID)
                    continue

            self.playerListBox.addItem(displayName, UUID)

        self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, "Edit Player", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action

        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()

        self.nbtEditor.editorSession = self.editorSession
        self.nbtEditor.editMade.connect(self.nbtEditWasMade)

        centerWidgetInScreen(self)
开发者ID:101baja202,项目名称:mcedit2,代码行数:58,代码来源:player.py


示例9: load_ui

def load_ui(name, parent=None, baseinstance=None):
    loader = MCEUILoader(baseinstance=baseinstance)
    loader.setWorkingDirectory(resourcePath(os.path.join("mcedit2", "ui")))
    path = resourcePath("mcedit2/ui/" + name)
    uifile = QtCore.QFile(path)
    uifile.open(QtCore.QFile.ReadOnly)
    widget = loader.load(uifile, parent)
    uifile.close()
    assert isinstance(widget, QtGui.QWidget)
    # if not hasattr(sys, 'frozen'):
    #     log.info("Adding debug context menu: %s", name)
    #
    #     def showUISource():
    #         url = QtCore.QUrl.fromLocalFile(os.path.dirname(path))
    #         QtGui.QDesktopServices.openUrl(url)
    #
    #     def showCallerSource():
    #         cmd = r'C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.1\bin\pycharm.exe'
    #         args = [cmd, callerFile, b'--line', b"%s" % callerLine]
    #         subprocess.Popen(args,
    #                          stdin = None,
    #                          stdout = None,
    #                          stderr = None,
    #                          #shell=platform.system() == 'Windows'
    #                          )
            #os.system(" ".join([cmd, callerFile, '/l', "%s" % callerLine]))
            #log.warn("ARGS: %s", args)

        # if widget.contextMenuPolicy() == Qt.DefaultContextMenu:
        #     widget.setContextMenuPolicy(Qt.ActionsContextMenu)
        #     showUISourceAction = QtGui.QAction("Reveal .ui file", widget, triggered=showUISource)
        #     widget.addAction(showUISourceAction)
        #     frame = inspect.currentframe()
        #     frame = frame.f_back
        #     callerFile = frame.f_code.co_filename
        #     callerLine = frame.f_lineno


        # showCallerSourceAction = QtGui.QAction("Open source code", widget, triggered=showCallerSource)
        # widget.addAction(showCallerSourceAction)

    return widget
开发者ID:cagatayikim,项目名称:mcedit2,代码行数:42,代码来源:load_ui.py


示例10: NBTIcon

def NBTIcon(type):
    icon = _nbtIcons.get(type)
    if icon:
        return icon

    name = _iconTypes[type]
    path = resourcePath("mcedit2/assets/mcedit2/nbticons/" + name)
    assert os.path.exists(path), "%s does not exist" % path
    icon = QtGui.QIcon(path)
    assert icon is not None
    _nbtIcons[type] = icon
    return icon
开发者ID:mcedit,项目名称:mcedit2,代码行数:12,代码来源:nbttreemodel.py


示例11: clearTable

    def clearTable(self):
        addButton = QtGui.QPushButton("Add...", flat=True, clicked=self.addNewRow)
        addButton.setIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/add.png")))
        addButton.setMinimumHeight(48)
        addButton.setIconSize(QtCore.QSize(32, 32))

        addItem = QtGui.QTableWidgetItem(text="Add...")
        addItem.setSizeHint(addButton.sizeHint())

        self.findReplaceTable.clear()
        self.findReplaceTable.setRowCount(1)
        self.findReplaceTable.setItem(0, 0, addItem)
        self.findReplaceTable.setSpan(0, 0, 1, 2)
        self.findReplaceTable.setCellWidget(0, 0, addButton)
        self.findReplaceTable.resizeRowsToContents()
        self.findReplaceTable.resizeColumnsToContents()
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:16,代码来源:block_replacement_list.py


示例12: __init__

    def __init__(self):
        super(ScaleWidget, self).__init__()
        self.setupUi(self)

        self.xScaleSpinSlider.valueChanged.connect(self.setXScale)
        self.yScaleSpinSlider.valueChanged.connect(self.setYScale)
        self.zScaleSpinSlider.valueChanged.connect(self.setZScale)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/mirror.png"))
        self.xFlipButton.setIcon(icon)
        self.yFlipButton.setIcon(icon)
        self.zFlipButton.setIcon(icon)

        self.xFlipButton.clicked.connect(self.xFlipClicked)
        self.yFlipButton.clicked.connect(self.yFlipClicked)
        self.zFlipButton.clicked.connect(self.zFlipClicked)

        self.xScale = self.yScale = self.zScale = 1.0
开发者ID:mcedit,项目名称:mcedit2,代码行数:18,代码来源:scale_widget.py


示例13: frameButton

        def frameButton(button, withRemove=False):
            frame = QtGui.QFrame()
            frame.button = button
            layout = QtGui.QVBoxLayout()
            layout.addStretch(1)
            if withRemove:
                removeButton = QtGui.QPushButton("", flat=True)
                removeButton.setIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/remove.png")))
                removeButton.setIconSize(QtCore.QSize(24, 24))

                def _clicked():
                    self.removeRow(self.findReplaceTable.row(left))
                removeButton.__clicked = _clicked
                removeButton.clicked.connect(_clicked)
                layout.addLayout(Row((button, 1), removeButton))
            else:
                layout.addWidget(button)
            layout.addStretch(1)
            frame.setLayout(layout)
            return frame
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:20,代码来源:block_replacement_list.py


示例14: __init__

    def __init__(self, editorSession, dialog, *args, **kwargs):
        super(FindReplaceBlocks, self).__init__(*args, **kwargs)
        self.editorSession = editorSession
        self.dialog = dialog

        header = dialog.findReplaceTable.horizontalHeader()
        header.setResizeMode(0, QtGui.QHeaderView.Stretch)
        header.setResizeMode(1, QtGui.QHeaderView.Stretch)
        dialog.findReplaceTable.setRowCount(1)
        addButton = QtGui.QPushButton("Add...", flat=True, clicked=self.addNewRow)
        addButton.setIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/add.png")))
        addButton.setMinimumHeight(48)
        addButton.setIconSize(QtCore.QSize(32, 32))
        addItem = QtGui.QTableWidgetItem(text="Add...")
        addItem.setSizeHint(addButton.sizeHint())
        dialog.findReplaceTable.setItem(0, 0, addItem)
        dialog.findReplaceTable.setSpan(0, 0, 1, 2)
        dialog.findReplaceTable.setCellWidget(0, 0, addButton)
        dialog.findReplaceTable.resizeRowsToContents()
        dialog.findReplaceTable.resizeColumnsToContents()
        dialog.blocksReplaceButton.clicked.connect(self.doReplace)
开发者ID:pamunoz,项目名称:mcedit2,代码行数:21,代码来源:replace_blocks.py


示例15: __init__

    def __init__(self, *args, **kwargs):
        super(ShapeWidget, self).__init__(*args, **kwargs)
        buttons = self.buttons = []
        layout = flowlayout.FlowLayout()
        actionGroup = QtGui.QActionGroup(self)
        actionGroup.setExclusive(True)
        iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
        actions = {}
        for shape in Shapes.allShapes:
            filename = os.path.join(iconBase, shape.icon)
            assert os.path.exists(filename), "%r does not exist" % filename
            icon = QtGui.QIcon(filename)
            if icon is None:
                raise ValueError("Failed to read shape icon file %s" % filename)
            def _handler(shape):
                def handler():
                    self.currentShape = shape
                    BrushShapeSetting.setValue(shape.ID)
                    self.shapeChanged.emit()
                return handler
            action = QtGui.QAction(icon, shape.ID, self, triggered=_handler(shape))
            button = QtGui.QToolButton()
            action.setCheckable(True)
            button.setDefaultAction(action)
            button.setIconSize(QtCore.QSize(32, 32))
            buttons.append(button)
            layout.addWidget(button)
            actionGroup.addAction(action)
            actions[shape.ID] = action

        self.setLayout(layout)
        currentID = BrushShapeSetting.value(Shapes.allShapes[0].ID)
        shapesByID = {shape.ID:shape for shape in Shapes.allShapes}
        actions[currentID].setChecked(True)

        self.currentShape = shapesByID.get(currentID, Shapes.allShapes[0])
开发者ID:101baja202,项目名称:mcedit2,代码行数:36,代码来源:shapewidget.py


示例16: __init__

 def __init__(self, *args, **kwargs):
     super(PluginsTableModel, self).__init__(*args, **kwargs)
     self.pluginRefs = plugins.getAllPlugins()
     log.info("Plugin count: %d", len(self.pluginRefs))
     self.headerTitles = ["", "Plugin Name", "Filename"]
     self.reloadIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/reload.png"))
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:6,代码来源:plugins_dialog.py


示例17: _openImageStream

 def _openImageStream(self, name):
     if name == "MCEDIT_UNKNOWN":
         block_unknown = resourcePath("mcedit2/assets/mcedit2/block_unknown.png")
         return file(block_unknown, "rb")
     return self.resourceLoader.openStream(name)
开发者ID:KevinKelley,项目名称:mcedit2,代码行数:5,代码来源:textureatlas.py


示例18: __init__

    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)

        self.editorSession = editorSession
        self.selectedUUID = None

        load_ui("panels/player.ui", baseinstance=self)

        self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT)
        self.inventoryGroupBox.setLayout(Row(self.inventoryEditor))

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)
        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except PlayerNotFound:
            log.info("No single-player.")
            singlePlayerUUID = None
        except KeyError:
            log.info("Failed to get single-player UUID.")
            singlePlayerUUID = None

        if "" in playerUUIDs:
            # Move singleplayer to beginning of list
            playerUUIDs.remove("")
            playerUUIDs.insert(0, "")

        for UUID in playerUUIDs:  # xxx live update?
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID  # xxx mojang api here
                try:
                    UUID = uuid.UUID(hex=UUID)
                    if UUID == singlePlayerUUID:
                        displayName = "[Multiplayer](%s)" % singlePlayerUUID
                except ValueError:  # badly formed uuid?
                    log.warn("Could not get a UUID from %s", UUID)
                    continue

            self.playerListBox.addItem(displayName, UUID)

        self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, "Edit Player", self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action
                     
        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()

        self.nbtEditor.editorSession = self.editorSession

        centerWidgetInScreen(self)
开发者ID:CaulyKan,项目名称:mcedit2,代码行数:65,代码来源:player.py


示例19: __init__

    def __init__(self, argv):
        super(MCEditApp, self).__init__(argv)
        MCEditApp.app = self

        minecraftinstall.GetInstalls().ensureValidInstall()
        self.ensureSingle()

        self.commandLineWorlds = []
        self.parseArgs(argv)

        log.warn("UserFilesDirectory: %s", getUserFilesDirectory())

        # --- Necessities ---

        translator = QtCore.QTranslator()
        translator.load(resourcePath('mcedit2/i18n/en_US.ts'))
        self.installTranslator(translator)

        log.info("Loaded translator.")

        self.setOrganizationName("MCEdit")
        self.setOrganizationDomain("mcedit.net")
        self.setApplicationName("MCEdit")
        self.setWindowIcon(QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/mcediticon.png")))
        styleSheet = file(resourcePath("mcedit2/styles/mcedit2.qcss")).read()
        self.setStyleSheet(styleSheet)

        log.info("Loaded stylesheet.")

        # --- Main Window ---

        self.mainWindow = mainWindow = MCEditMainWindow()

        self.undoGroup = QtGui.QUndoGroup()

        self.tabWidget = self.mainWindow.tabWidget
        self.tabWidget.tabCloseRequested.connect(self.tabCloseRequested)
        self.tabWidget.currentChanged.connect(self.tabChanged)

        log.info("Loaded main window.")

        tttIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/toolbar_text.png"))

        self.toggleToolbarTextAction = QtGui.QAction(tttIcon, "Toolbar Text", self)

        self.toggleToolbarTextAction.setCheckable(True)
        self.toggleToolbarTextAction.setChecked(True)

        self.toggleToolbarTextAction.toggled.connect(self.toggleToolbarText)

        # --- OpenGL ---

        setDefaultFormat()

        # --- Sessions ---

        self._currentSession = None
        self.sessions = []
        self.sessionDockWidgets = []
        self.sessionChanged.connect(self.sessionDidChange)

        # --- Panel Widgets ---
        historyIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/history.png"))

        self.undoView = QtGui.QUndoView(self.undoGroup)
        self.undoDockWidget = MCEDockWidget("History", mainWindow, objectName="HistoryWidget")
        self.undoDockWidget.setWidget(self.undoView)
        self.undoDockWidget.setWindowIcon(historyIcon)
        self.undoDockWidget.setUnfocusedOpacity(0.8)

        mainWindow.addDockWidget(Qt.RightDockWidgetArea, self.undoDockWidget)
        undoToggleAction = self.undoDockWidget.toggleViewAction()
        undoToggleAction.setIcon(historyIcon)
        mainWindow.panelsToolBar.addAction(undoToggleAction)
        self.undoDockWidget.close()

        libraryIcon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/library.png"))
        self.libraryWidget = LibraryWidget()
        self.libraryDockWidget = MCEDockWidget("Library", mainWindow, objectName="LibraryWidget")
        self.libraryDockWidget.setWidget(self.libraryWidget)
        self.libraryDockWidget.setWindowIcon(libraryIcon)
        self.libraryDockWidget.setUnfocusedOpacity(0.8)

        mainWindow.addDockWidget(Qt.RightDockWidgetArea, self.libraryDockWidget)

        libraryToggleAction = self.libraryDockWidget.toggleViewAction()
        libraryToggleAction.setIcon(libraryIcon)
        mainWindow.panelsToolBar.addAction(libraryToggleAction)
        self.libraryDockWidget.close()
        self.sessionChanged.connect(self.libraryWidget.sessionDidChange)

        self.libraryWidget.doubleClicked.connect(self.libraryItemDoubleClicked)

        self.globalPanels = [self.undoDockWidget, self.libraryDockWidget]

        log.info("Loaded panels.")

        # --- Debug Widgets ---

        self.debugMenu = self.createDebugMenu()
#.........这里部分代码省略.........
开发者ID:qtx0213,项目名称:mcedit2,代码行数:101,代码来源:editorapp.py


示例20: __init__

    def __init__(self, editorSession):
        """

        :type editorSession: mcedit2.editorsession.EditorSession
        :rtype: PlayerPanel
        """
        super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool)
        self.setupUi(self)

        self.editorSession = editorSession
        self.selectedUUID = None
        self.nbtEditor.editorSession = self.editorSession

        self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT)
        self.inventoryGroupBox.setLayout(Row(self.inventoryEditor))

        self.movePlayerButton.clicked.connect(self.movePlayerToCamera)
        self.viewPlayerButton.clicked.connect(self.showPlayerView)
        playerUUIDs = list(editorSession.worldEditor.listPlayers())
        try:
            sp = editorSession.worldEditor.getPlayer("")
            singlePlayerUUID = sp.UUID
        except (PlayerNotFound, NBTFormatError):
            log.info("No single-player.")
            singlePlayerUUID = None
        except KeyError:
            log.info("Failed to get single-player UUID.")
            singlePlayerUUID = None

        if "" in playerUUIDs:
            # Move singleplayer to beginning of list
            playerUUIDs.remove("")
            playerUUIDs.insert(0, "")

        for UUID in playerUUIDs:
            if UUID == "":
                displayName = "[Single-player](%s)" % singlePlayerUUID
            else:
                displayName = UUID
                try:
                    UUID = uuid.UUID(hex=UUID)
                    if UUID == singlePlayerUUID:
                        displayName = "[Multiplayer](%s)" % singlePlayerUUID
                except ValueError:  # badly formed uuid?
                    log.warn("Could not get a UUID from %s", UUID)
                    continue

            idx = self.playerListBox.count()
            self.playerListBox.addItem(displayName, UUID)

            def _callback(idx, fmt="%s"):
                def callback(result, error):
                    if result:
                        name = result['name']
                        self.playerListBox.setItemText(idx, fmt % name)
                return callback

            if UUID == "":
                if singlePlayerUUID:
                    PlayerDataCache.getPlayerInfo(singlePlayerUUID, _callback(idx, "[Single-player]%s"))
            else:
                if UUID == singlePlayerUUID:
                    PlayerDataCache.getPlayerInfo(UUID, _callback(idx, "[Multiplayer]%s"))
                else:
                    PlayerDataCache.getPlayerInfo(UUID, _callback(idx))


        self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex)
        if len(playerUUIDs):
            self.setSelectedPlayerIndex(0)

        icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png"))
        action = QtGui.QAction(icon, self.tr("Edit Player"), self)
        action.setCheckable(True)
        action.triggered.connect(self.toggleView)
        self._toggleViewAction = action
                     
        self.editorSession.revisionChanged.connect(self.revisionDidChange)
        self.initPropertiesWidget()


        centerWidgetInScreen(self)
开发者ID:mcedit,项目名称:mcedit2,代码行数:82,代码来源:player.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings.Settings类代码示例发布时间:2022-05-27
下一篇:
Python load_ui.load_ui函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap