Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
--- a/Beremiz.py Mon Jan 20 11:04:19 2014 +0100
+++ b/Beremiz.py Sun Jan 26 13:18:29 2014 +0100
@@ -110,18 +110,9 @@
splash.SetText(text=updateinfo)
wx.Yield()
-from util.TranslationCatalogs import AddCatalog
-from util.BitmapLibrary import AddBitmapFolder, GetBitmap
-
-AddCatalog(os.path.join(CWD, "locale"))
-AddBitmapFolder(os.path.join(CWD, "images"))
-
-if __name__ == '__main__':
- # Import module for internationalization
- import gettext
-
- __builtin__.__dict__['_'] = wx.GetTranslation
-
+ from util.misc import InstallLocalRessources
+ InstallLocalRessources(CWD)
+
# Load extensions
for extfilename in extensions:
extension_folder = os.path.split(os.path.realpath(extfilename))[0]
@@ -130,14 +121,12 @@
AddBitmapFolder(os.path.join(extension_folder, "images"))
execfile(extfilename, locals())
+
import wx.lib.buttons, wx.lib.statbmp, wx.stc
import cPickle
import types, time, re, platform, time, traceback, commands
from docutil import OpenHtmlFrame
-from IDEFrame import IDEFrame, AppendMenu
-from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES
-from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
from editors.EditorPanel import EditorPanel
from editors.Viewer import Viewer
from editors.TextViewer import TextViewer
@@ -278,6 +267,20 @@
ID_FILEMENURECENTPROJECTS = wx.NewId()
+from IDEFrame import TITLE,\
+ EDITORTOOLBAR,\
+ FILEMENU,\
+ EDITMENU,\
+ DISPLAYMENU,\
+ PROJECTTREE,\
+ POUINSTANCEVARIABLESPANEL,\
+ LIBRARYTREE,\
+ SCALING,\
+ PAGETITLES,\
+ IDEFrame, AppendMenu,\
+ EncodeFileSystemPath, DecodeFileSystemPath
+from util.BitmapLibrary import GetBitmap
+
class Beremiz(IDEFrame):
def _init_utils(self):
--- a/PLCOpenEditor.py Mon Jan 20 11:04:19 2014 +0100
+++ b/PLCOpenEditor.py Sun Jan 26 13:18:29 2014 +0100
@@ -62,21 +62,10 @@
# Windows)
app = wx.PySimpleApp()
+ from util.misc import InstallLocalRessources
+ InstallLocalRessources(CWD)
+
from docutil import *
-
-from util.TranslationCatalogs import AddCatalog
-from util.BitmapLibrary import AddBitmapFolder, GetBitmap
-
-AddCatalog(os.path.join(CWD, "locale"))
-AddBitmapFolder(os.path.join(CWD, "images"))
-
-if __name__ == '__main__':
- # Import module for internationalization
- import gettext
- import __builtin__
-
- __builtin__.__dict__['_'] = wx.GetTranslation
-
from IDEFrame import IDEFrame, AppendMenu
from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, PAGETITLES
from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
--- a/util/misc.py Mon Jan 20 11:04:19 2014 +0100
+++ b/util/misc.py Sun Jan 26 13:18:29 2014 +0100
@@ -22,3 +22,19 @@
return fac
else:
return classpath
+
+def InstallLocalRessources(CWD):
+ from BitmapLibrary import AddBitmapFolder
+ from TranslationCatalogs import AddCatalog
+ import wx
+
+ # Beremiz bitmaps
+ AddBitmapFolder(os.path.join(CWD, "images"))
+
+ # Internationalization
+ AddCatalog(os.path.join(CWD, "locale"))
+ import gettext
+ import __builtin__
+
+ __builtin__.__dict__['_'] = wx.GetTranslation
+