108 updateinfoThread.start() |
108 updateinfoThread.start() |
109 updateinfoThread.join(2) |
109 updateinfoThread.join(2) |
110 splash.SetText(text=updateinfo) |
110 splash.SetText(text=updateinfo) |
111 wx.Yield() |
111 wx.Yield() |
112 |
112 |
113 # Import module for internationalization |
113 from util.TranslationCatalogs import AddCatalog, locale |
114 import gettext |
114 from util.BitmapLibrary import AddBitmapFolder, GetBitmap |
115 |
115 |
116 # Get folder containing translation files |
116 AddCatalog(os.path.join(CWD, "locale")) |
117 localedir = os.path.join(CWD,"locale") |
117 AddBitmapFolder(os.path.join(CWD, "images")) |
118 # Get the default language |
|
119 langid = wx.LANGUAGE_DEFAULT |
|
120 # Define translation domain (name of translation files) |
|
121 domain = "Beremiz" |
|
122 |
|
123 # Define locale for wx |
|
124 loc = __builtin__.__dict__.get('loc', None) |
|
125 if loc is None: |
|
126 test_loc = wx.Locale(langid) |
|
127 test_loc.AddCatalogLookupPathPrefix(localedir) |
|
128 if test_loc.AddCatalog(domain): |
|
129 loc = wx.Locale(langid) |
|
130 else: |
|
131 loc = wx.Locale(wx.LANGUAGE_ENGLISH) |
|
132 __builtin__.__dict__['loc'] = loc |
|
133 # Define location for searching translation files |
|
134 loc.AddCatalogLookupPathPrefix(localedir) |
|
135 # Define locale domain |
|
136 loc.AddCatalog(domain) |
|
137 |
|
138 def unicode_translation(message): |
|
139 return wx.GetTranslation(message).encode("utf-8") |
|
140 |
118 |
141 if __name__ == '__main__': |
119 if __name__ == '__main__': |
142 __builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
120 # Import module for internationalization |
143 |
121 import gettext |
144 base_folder = os.path.split(sys.path[0])[0] |
122 |
145 sys.path.append(base_folder) |
123 __builtin__.__dict__['loc'] = locale |
146 sys.path.append(os.path.join(base_folder, "plcopeneditor")) |
124 __builtin__.__dict__['_'] = wx.GetTranslation |
147 |
125 |
148 from utils.BitmapLibrary import AddBitmapFolder, GetBitmap |
|
149 AddBitmapFolder(os.path.join(CWD, "images")) |
|
150 |
|
151 if __name__ == '__main__': |
|
152 # Load extensions |
126 # Load extensions |
153 for extfilename in extensions: |
127 for extfilename in extensions: |
154 extension_folder = os.path.split(os.path.realpath(extfilename))[0] |
128 extension_folder = os.path.split(os.path.realpath(extfilename))[0] |
155 sys.path.append(extension_folder) |
129 sys.path.append(extension_folder) |
|
130 AddCatalog(os.path.join(extension_folder, "locale")) |
156 AddBitmapFolder(os.path.join(extension_folder, "images")) |
131 AddBitmapFolder(os.path.join(extension_folder, "images")) |
157 execfile(extfilename, locals()) |
132 execfile(extfilename, locals()) |
158 |
133 |
159 import wx.lib.buttons, wx.lib.statbmp |
134 import wx.lib.buttons, wx.lib.statbmp |
160 import cPickle |
135 import cPickle |
161 import types, time, re, platform, time, traceback, commands |
136 import types, time, re, platform, time, traceback, commands |
162 |
137 |
163 from docutil import OpenHtmlFrame |
138 from docutil import OpenHtmlFrame |
164 from PLCOpenEditor import IDEFrame, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
139 from IDEFrame import IDEFrame, AppendMenu |
165 from PLCOpenEditor import EditorPanel, Viewer, TextViewer, GraphicViewer, ResourceEditor, ConfigurationEditor, DataTypeEditor |
140 from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
166 from PLCOpenEditor import EncodeFileSystemPath, DecodeFileSystemPath |
141 from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath |
167 from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE |
142 from editors.EditorPanel import EditorPanel |
168 |
143 from editors.Viewer import Viewer |
169 from util.TextCtrlAutoComplete import TextCtrlAutoComplete |
144 from editors.TextViewer import TextViewer |
170 from util.BrowseValuesLibraryDialog import BrowseValuesLibraryDialog |
145 from editors.GraphicViewer import GraphicViewer |
|
146 from editors.ResourceEditor import ConfigurationEditor, ResourceEditor |
|
147 from editors.DataTypeEditor import DataTypeEditor |
171 from util.MiniTextControler import MiniTextControler |
148 from util.MiniTextControler import MiniTextControler |
172 from util.ProcessLogger import ProcessLogger |
149 from util.ProcessLogger import ProcessLogger |
|
150 |
|
151 from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE |
173 from ProjectController import ProjectController, MATIEC_ERROR_MODEL, ITEM_CONFNODE |
152 from ProjectController import ProjectController, MATIEC_ERROR_MODEL, ITEM_CONFNODE |
|
153 |
174 |
154 |
175 MAX_RECENT_PROJECTS = 10 |
155 MAX_RECENT_PROJECTS = 10 |
176 |
156 |
177 class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap): |
157 class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap): |
178 """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
158 """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
301 |
281 |
302 IDEFrame._init_utils(self) |
282 IDEFrame._init_utils(self) |
303 |
283 |
304 def _init_coll_FileMenu_Items(self, parent): |
284 def _init_coll_FileMenu_Items(self, parent): |
305 AppendMenu(parent, help='', id=wx.ID_NEW, |
285 AppendMenu(parent, help='', id=wx.ID_NEW, |
306 kind=wx.ITEM_NORMAL, text=_(u'New\tCTRL+N')) |
286 kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
307 AppendMenu(parent, help='', id=wx.ID_OPEN, |
287 AppendMenu(parent, help='', id=wx.ID_OPEN, |
308 kind=wx.ITEM_NORMAL, text=_(u'Open\tCTRL+O')) |
288 kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
309 parent.AppendMenu(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
289 parent.AppendMenu(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
310 parent.AppendSeparator() |
290 parent.AppendSeparator() |
311 AppendMenu(parent, help='', id=wx.ID_SAVE, |
291 AppendMenu(parent, help='', id=wx.ID_SAVE, |
312 kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
292 kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
313 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
293 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
314 kind=wx.ITEM_NORMAL, text=_(u'Save as\tCTRL+SHIFT+S')) |
294 kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
315 AppendMenu(parent, help='', id=wx.ID_CLOSE, |
295 AppendMenu(parent, help='', id=wx.ID_CLOSE, |
316 kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W')) |
296 kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') |
317 AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
297 AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
318 kind=wx.ITEM_NORMAL, text=_(u'Close Project\tCTRL+SHIFT+W')) |
298 kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') |
319 parent.AppendSeparator() |
299 parent.AppendSeparator() |
320 AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
300 AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
321 kind=wx.ITEM_NORMAL, text=_(u'Page Setup\tCTRL+ALT+P')) |
301 kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') |
322 AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
302 AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
323 kind=wx.ITEM_NORMAL, text=_(u'Preview\tCTRL+SHIFT+P')) |
303 kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') |
324 AppendMenu(parent, help='', id=wx.ID_PRINT, |
304 AppendMenu(parent, help='', id=wx.ID_PRINT, |
325 kind=wx.ITEM_NORMAL, text=_(u'Print\tCTRL+P')) |
305 kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') |
326 parent.AppendSeparator() |
306 parent.AppendSeparator() |
327 AppendMenu(parent, help='', id=wx.ID_EXIT, |
307 AppendMenu(parent, help='', id=wx.ID_EXIT, |
328 kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
308 kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') |
329 |
309 |
330 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
310 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
331 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
311 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
332 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
312 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
333 self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
313 self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |