本文整理汇总了Python中mcedit2.util.resources.resourcePath函数的典型用法代码示例。如果您正苦于以下问题:Python resourcePath函数的具体用法?Python resourcePath怎么用?Python resourcePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resourcePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"))
示例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
示例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)
示例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"))
示例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)
示例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
示例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()
示例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)
示例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
示例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
示例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()
示例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
示例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
示例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)
示例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])