Esempio n. 1
0
void XmlResApp::MakePackagePython(const wxArrayString& flist)
{
    wxFFile file(parOutput, wxT("wt"));
    size_t i;

    if (flagVerbose)
        wxPrintf(_T("creating Python source file ") + parOutput +  _T("...\n"));

    file.Write(
       _T("#\n")
       _T("# This file was automatically generated by wxrc, do not edit by hand.\n")
       _T("#\n\n")
       _T("import wx\n")
       _T("import wx.xrc\n\n")
    );


    file.Write(_T("def ") + parFuncname + _T("():\n"));

    for (i = 0; i < flist.Count(); i++)
        file.Write(
          FileToPythonArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));

    file.Write(
        _T("    # check if the memory filesystem handler has been loaded yet, and load it if not\n")
        _T("    wx.MemoryFSHandler.AddFile('XRC_resource/dummy_file', 'dummy value')\n")
        _T("    fsys = wx.FileSystem()\n")
        _T("    f = fsys.OpenFile('memory:XRC_resource/dummy_file')\n")
        _T("    wx.MemoryFSHandler.RemoveFile('XRC_resource/dummy_file')\n")
        _T("    if f is not None:\n")
        _T("        f.Destroy()\n")
        _T("    else:\n")
        _T("        wx.FileSystem.AddHandler(wx.MemoryFSHandler())\n")
        _T("\n")
        _T("    # load all the strings as memory files and load into XmlRes\n")
        );


    for (i = 0; i < flist.Count(); i++)
    {
        wxString s;
        s.Printf(_T("    wx.MemoryFSHandler.AddFile('XRC_resource/") + flist[i] +
                 _T("', xml_res_file_%i)\n"), i);
        file.Write(s);
    }
    for (i = 0; i < parFiles.Count(); i++)
    {
        file.Write(_T("    wx.xrc.XmlResource.Get().Load('memory:XRC_resource/") +
                   GetInternalFileName(parFiles[i], flist) + _T("')\n"));
    }

    file.Write(_T("\n"));
}
Esempio n. 2
0
void wxcXmlResourceCmp::MakePackagePython(const wxArrayString& flist)
{
    wxFFile file(m_outputCppFile, wxT("wt"));
    unsigned i;

    file.Write("#\n"
               "# This file was automatically generated by wxrc, do not edit by hand.\n"
               "#\n\n"
               "import wx\n"
               "import wx.xrc\n\n");

    file.Write("def " + m_functionName + "():\n");

    for(i = 0; i < flist.GetCount(); i++)
        file.Write(FileToPythonArray(m_outputPath + wxFILE_SEP_PATH + flist[i], i));

    file.Write("    # check if the memory filesystem handler has been loaded yet, and load it if not\n"
               "    wx.MemoryFSHandler.AddFile('XRC_resource/dummy_file', 'dummy value')\n"
               "    fsys = wx.FileSystem()\n"
               "    f = fsys.OpenFile('memory:XRC_resource/dummy_file')\n"
               "    wx.MemoryFSHandler.RemoveFile('XRC_resource/dummy_file')\n"
               "    if f is not None:\n"
               "        f.Destroy()\n"
               "    else:\n"
               "        wx.FileSystem.AddHandler(wx.MemoryFSHandler())\n"
               "\n"
               "    # load all the strings as memory files and load into XmlRes\n");

    for(i = 0; i < flist.GetCount(); i++) {
        wxString s;
        s.Printf("    wx.MemoryFSHandler.AddFile('XRC_resource/" + flist[i] + "', xml_res_file_%u)\n", i);
        file.Write(s);
    }
    file.Write("    wx.xrc.XmlResource.Get().Load('memory:XRC_resource/" + GetInternalFileName(m_xrcFile, flist) +
               "')\n");
    file.Write("\n");
}