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


Python PluginManager.objects方法代码示例

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


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

示例1: load

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
    def load(fileName, mapFormat = None):
        error = ''
        tmxMapFormat = TmxMapFormat()
        
        if (not mapFormat and not tmxMapFormat.supportsFile(fileName)):
            # Try to find a plugin that implements support for this format
            formats = PluginManager.objects()
            for format in formats:
                if (format.supportsFile(fileName)):
                    mapFormat = format
                    break

        map = None
        errorString = ''

        if mapFormat:
            map = mapFormat.read(fileName)
            errorString = mapFormat.errorString()
        else:
            map = tmxMapFormat.read(fileName)
            errorString = tmxMapFormat.errorString()

        if (not map):
            error = errorString
            return None, error

        mapDocument = MapDocument(map, fileName)
        if mapFormat:
            mapDocument.setReaderFormat(mapFormat)
            if mapFormat.hasCapabilities(MapFormat.Write):
                mapDocument.setWriterFormat(mapFormat)

        return mapDocument, error
开发者ID:theall,项目名称:Python-Tiled,代码行数:35,代码来源:mapdocument.py

示例2: showExportFormats

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
    def showExportFormats(self):
        PluginManager.instance().loadPlugins()

        qWarning(self.tr("Export formats:"))
        formats = PluginManager.objects()
        for format in formats:
            if format.hasCapabilities(MapFormat.Write):
                qWarning(" " + format.nameFilter())

        self.quit = True
开发者ID:theall,项目名称:Python-Tiled,代码行数:12,代码来源:main.py

示例3: __init__

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
    def __init__(self, mainWindow, parent = None):
        super().__init__(parent)
        self.mMainWindow = mainWindow

        self.setRootIsDecorated(False)
        self.setHeaderHidden(True)
        self.setItemsExpandable(False)
        self.setUniformRowHeights(True)
        self.setDragEnabled(True)
        self.setDefaultDropAction(Qt.MoveAction)
        prefs = preferences.Preferences.instance()
        prefs.mapsDirectoryChanged.connect(self.onMapsDirectoryChanged)
        mapsDir = QDir(prefs.mapsDirectory())
        if (not mapsDir.exists()):
            mapsDir.setPath(QDir.currentPath())
        self.mFSModel = FileSystemModel(self)
        self.mFSModel.setRootPath(mapsDir.absolutePath())

        nameFilters = QStringList("*.tmx")
        # The file system model name filters are plain, whereas the plugins expose
        # a filter as part of the file description
        filterFinder = QRegExp("\\((\\*\\.[^\\)\\s]*)")
        for format in PluginManager.objects(MapFormat):
            if not (format.capabilities() & MapFormat.Read):
                continue

            filter = format.nameFilter()
            if (filterFinder.indexIn(filter) != -1):
                nameFilters.append(filterFinder.cap(1))

        self.mFSModel.setFilter(QDir.AllDirs | QDir.Files | QDir.NoDot)
        self.mFSModel.setNameFilters(nameFilters)
        self.mFSModel.setNameFilterDisables(False) # hide filtered files
        self.setModel(self.mFSModel)
        headerView = self.header()
        headerView.hideSection(1) # Size column
        headerView.hideSection(2)
        headerView.hideSection(3)
        self.setRootIndex(self.mFSModel.index(mapsDir.absolutePath()))
        self.header().setStretchLastSection(False)
        self.header().setSectionResizeMode(0, QHeaderView.Stretch)
        self.activated.connect(self.onActivated)

        self.mMainWindow = None
        self.mFSModel = None
开发者ID:theall,项目名称:Python-Tiled,代码行数:47,代码来源:mapsdock.py

示例4: __init__

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
    def __init__(self, parent = None):
        super().__init__(parent)

        self.setObjectName("ConsoleDock")
        self.setWindowTitle(self.tr("Debug Console"))
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        self.plainTextEdit = QPlainTextEdit()
        self.plainTextEdit.setReadOnly(True)
        self.plainTextEdit.setStyleSheet(QString(
                                "QAbstractScrollArea {"
                                " background-color: black;"
                                " color:green;"
                                "}"
                                ))
        layout.addWidget(self.plainTextEdit)
        
        for output in PluginManager.objects(LoggingInterface):
            self.registerOutput(output)

        PluginManager.instance().objectAdded.connect(self.onObjectAdded)

        self.setWidget(widget)
开发者ID:theall,项目名称:Python-Tiled,代码行数:26,代码来源:consoledock.py

示例5: readTileset

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
def readTileset(fileName):
    error = ''
    # Try the first registered tileset format that claims to support the file
    for format in PluginManager.objects(TilesetFormat):
        if format.supportsFile(fileName):
            tileset = format.read(fileName)
            if (error):
                if (not tileset):
                   error = format.errorString()
                else:
                   error = ''
            
            return tileset, error

    # Fall back to default reader (TSX format)
    reader = mapreader.MapReader()
    tileset = reader.readTileset(fileName)
    if (error):
        if (not tileset):
           error = reader.errorString()
        else:
           error = ''
    
    return tileset, error
开发者ID:theall,项目名称:Python-Tiled,代码行数:26,代码来源:tilesetformat.py

示例6: main

# 需要导入模块: from pluginmanager import PluginManager [as 别名]
# 或者: from pluginmanager.PluginManager import objects [as 别名]
def main(argv):
    a = TiledApplication(argv)
    a.setOrganizationDomain("mapeditor.org")
    a.setApplicationName("Tiled")
    a.setApplicationVersion("0.14.2")

    if sys.platform == 'darwin':
        a.setAttribute(Qt.AA_DontShowIconsInMenus)

    # Enable support for highres images (added in Qt 5.1, but off by default)
    a.setAttribute(Qt.AA_UseHighDpiPixmaps)
    if sys.platform != 'win32':
        baseName = QApplication.style().objectName()
        if (baseName == "windows"):
            # Avoid Windows 95 style at all cost
            if (QStyleFactory.keys().contains("Fusion")):
                baseName = "fusion" # Qt5
            else: # Qt4
                # e.g. if we are running on a KDE4 desktop
                desktopEnvironment = qgetenv("DESKTOP_SESSION")
                if (desktopEnvironment == "kde"):
                    baseName = "plastique"
                else:
                    baseName = "cleanlooks"

            a.setStyle(QStyleFactory.create(baseName))
    languageManager = LanguageManager.instance()
    languageManager.installTranslators()
    commandLine = CommandLineHandler()
    if (not commandLine.parse(QCoreApplication.arguments())):
        return 0
    if (commandLine.quit):
        return 0
    if (commandLine.disableOpenGL):
        preferences.Preferences.instance().setUseOpenGL(False)
    PluginManager.instance().loadPlugins()
    if (commandLine.exportMap):
        # Get the path to the source file and target file
        if (commandLine.filesToOpen().length() < 2):
            qWarning(QCoreApplication.translate("Command line", "Export syntax is --export-map [format] "))
            return 1

        index = 0
        if commandLine.filesToOpen().length() > 2:
            filter = commandLine.filesToOpen().at(index)
            index += 1
        else:
            filter = None
        sourceFile = commandLine.filesToOpen().at(index)
        index += 1
        targetFile = commandLine.filesToOpen().at(index)
        index += 1
        
        chosenFormat = None
        formats = PluginManager.objects()

        if filter:
            # Find the map format supporting the given filter
            for format in formats:
                if not format.hasCapabilities(MapFormat.Write):
                    continue
                if format.nameFilter().lower()==filter.lower():
                    chosenFormat = format
                    break
            if not chosenFormat:
                qWarning(QCoreApplication.translate("Command line", "Format not recognized (see --export-formats)"))
                return 1
        else:
            # Find the map format based on target file extension
            suffix = QFileInfo(targetFile).completeSuffix()
            for format in formats:
                if not format.hasCapabilities(MapFormat.Write):
                    continue
                if suffix.lower() in format.nameFilter().lower():
                    if chosenFormat:
                        qWarning(QCoreApplication.translate("Command line", "Non-unique file extension. Can't determine correct export format."))
                        return 1
                    chosenFormat = format
                    
            if not chosenFormat:
                qWarning(QCoreApplication.translate("Command line", "No exporter found for target file."))
                return 1

        # Load the source file
        reader = MapReader()
        map = reader.readMap(sourceFile)
        if (not map):
            qWarning(QCoreApplication.translate("Command line", "Failed to load source map."))
            return 1

        # Write out the file
        success = chosenFormat.write(map.data(), targetFile)

        if (not success):
            qWarning(QCoreApplication.translate("Command line", "Failed to export map to target file."))
            return 1

        return 0
    w = MainWindow()
    w.show()
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:main.py


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