當前位置: 首頁>>代碼示例>>Python>>正文


Python FileManager.openFileXML方法代碼示例

本文整理匯總了Python中FileManager.FileManager.openFileXML方法的典型用法代碼示例。如果您正苦於以下問題:Python FileManager.openFileXML方法的具體用法?Python FileManager.openFileXML怎麽用?Python FileManager.openFileXML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FileManager.FileManager的用法示例。


在下文中一共展示了FileManager.openFileXML方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TileWindow

# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import openFileXML [as 別名]

#.........這裏部分代碼省略.........
        saveAsAction = Gtk.Action("SaveAs", None, None, Gtk.STOCK_SAVE_AS)
        actionGroup.add_action_with_accel(saveAsAction, "<Ctrl><Shift>s")
        saveAsAction.connect("activate", self.manageFile, "saveAs", "xml")

    def makeEditionMenuAction(self, actionGroup):
        editionMenuAction = Gtk.Action("EditionMenu", "_Edition", None, None)
        actionGroup.add_action(editionMenuAction)

        newTraceAction = Gtk.Action("NewTrace", "New _Trace", None, None)
        actionGroup.add_action_with_accel(newTraceAction, "<Ctrl><Shift>t")
        newTraceAction.connect("activate", self.newContents.newTrace, self.traceManager)

        newImageAction = Gtk.Action("NewImage", "New _Image", None, None)
        actionGroup.add_action_with_accel(newImageAction, "<Ctrl><Shift>i")
        newImageAction.connect("activate", self.manageFile, "open", "image")

        newObjectAction = Gtk.Action("NewObject", "New _Object", None, None)
        actionGroup.add_action_with_accel(newObjectAction, "<Ctrl><Shift>o")
        newObjectAction.connect("activate", self.objectManager.promptAddObject)

        changeSizeAction = Gtk.Action("ChangeSize", "Chan_ge size", None, None)
        changeSizeAction.connect("activate", self.promptSetSize)

    def makeToolMenuAction(self, actionGroup):
        toolsMenuAction = Gtk.Action("ToolsMenu", "_Tools", None, None)
        actionGroup.add_action(toolsMenuAction)

        changeSizeAction = Gtk.Action("ChangeSize", "Change size", None, None)
        actionGroup.add_action(changeSizeAction)
        self.zoomPlus = Gtk.Action("Zoom+", None, None, Gtk.STOCK_ZOOM_IN)
        actionGroup.add_action_with_accel(self.zoomPlus, None)
        self.zoomOut = Gtk.Action("Zoom-", None, None, Gtk.STOCK_ZOOM_OUT)
        actionGroup.add_action_with_accel(self.zoomOut, None)

        actionGroup.add_radio_actions([("Print", None, None, "p", None, 0), \
                ("Eraser", None, None, "e", None, 0)], "active", self.radioActionManager)

        actionGroup.get_action("Print").set_icon_name("pencil")
        actionGroup.get_action("Eraser").set_icon_name("eraser")

    def makeSFMLMenuAction(self, actionGroup):
        delCase = Gtk.Action("DelCase", "Delete", None, None)
        setTileProperties = Gtk.Action("SetTileProperties", "Set tile properties", None, None)
        actionGroup.add_action(delCase)
        actionGroup.add_action(setTileProperties)
        
    def createUIManager(self):
        with open("Ressources/UI_INFO.xml", 'r') as info:
            ui = Gtk.UIManager()
            ui.add_ui_from_string(info.read())
            self.add_accel_group(ui.get_accel_group())
            return ui

    def manageFile(self, widget, action, mime=""):
        if action=="open":
            if mime=="image":
                self.newContents.createNewImage(self.fileManager, self.tileBox)
            elif mime=="xml":
                self.fileManager.openFileXML(self.tileBox, self.traceManager, self.objectManager)

        elif action=="saveAs":
            self.fileManager.saveAsFile(self.tileBox, self.traceManager, self.objectManager)
        elif action=="save":
            self.fileManager.saveFile(self.tileBox, self.traceManager, self.objectManager)

    def handleToolPanedMoving(self, widget, paramSpec):
        self.miniMap.scalePixbuf()
    
    def newFile(self, widget):
        self.newContents.newFile(self.fileManager)

    def promptSetSize(self, widget):
        self.newContents.setSize()

    def getSaveFileElem(self):
        windowElem = ET.Element('Window')
        windowElem.set('numberCases', str(globalVar.sfmlArea.numberCases.x)+'x'+str(globalVar.sfmlArea.numberCases.y))
        windowElem.set('tileSize', str(globalVar.sfmlArea.sizeCase.x)+'x'+str(globalVar.sfmlArea.sizeCase.y))
        windowElem.set('title', str(self.get_title()))

        return windowElem

    def decodeXML(self, windowElement):
        windowValuesElement = dict()
        for item in windowElement.items():
            windowValuesElement[item[0]]=item[1]

        tileSizeSplit = windowValuesElement['tileSize'].split('x')
        windowValuesElement['tileSize'] = sf.Vector2(float(tileSizeSplit[0]), float(tileSizeSplit[1]))

        numberCasesSplit = windowValuesElement['numberCases'].split('x')
        windowValuesElement['numberCases'] = sf.Vector2(float(numberCasesSplit[0]), float(numberCasesSplit[1]))
        self.buildSFMLArea(windowValuesElement['numberCases'], windowValuesElement['tileSize'])

        self.set_title(windowValuesElement['title'])

    def radioActionManager(self, radioAction, current):
        if globalVar.sfmlArea:
            globalVar.sfmlArea.setMode(current.get_name())
        self.mode = current.get_name()
開發者ID:MickaelSERENO,項目名稱:TiledMapEditor,代碼行數:104,代碼來源:TileWindow.py


注:本文中的FileManager.FileManager.openFileXML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。