--- a/PLCOpenEditor.py Fri Jul 24 12:49:57 2009 +0200
+++ b/PLCOpenEditor.py Fri Jul 24 17:12:59 2009 +0200
@@ -31,6 +31,75 @@
else:
USE_AUI = False
+import os, re, platform, sys, time, traceback, getopt
+import cPickle
+
+CWD = os.path.split(os.path.realpath(__file__))[0]
+base_folder = os.path.split(CWD)[0]
+sys.path.append(base_folder)
+from docutils import *
+
+from types import TupleType
+
+__version__ = "$Revision: 1.130 $"
+
+if __name__ == '__main__':
+ # Usage message displayed when help request or when error detected in
+ # command line
+ def usage():
+ print "\nUsage of PLCOpenEditor.py :"
+ print "\n %s [Filepath]\n"%sys.argv[0]
+
+ # Parse options given to PLCOpenEditor in command line
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
+ except getopt.GetoptError:
+ # print help information and exit:
+ usage()
+ sys.exit(2)
+
+ # Extract if help has been requested
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+
+ # Extract the optional filename to open
+ fileOpen = None
+ if len(args) > 1:
+ usage()
+ sys.exit()
+ elif len(args) == 1:
+ fileOpen = args[0]
+
+ # Create wxApp (Need to create App before internationalization because of
+ # Windows)
+ app = wx.PySimpleApp()
+
+# Import module for internationalization
+import gettext
+import __builtin__
+
+# Get folder containing translation files
+localedir = os.path.join(CWD,"locale")
+# Get the default language
+langid = wx.LANGUAGE_DEFAULT
+# Define translation domain (name of translation files)
+domain = "PLCOpenEditor"
+
+# Define locale for wx
+loc = __builtin__.__dict__.get('loc', None)
+if loc is None:
+ loc = wx.Locale(langid)
+ __builtin__.__dict__['loc'] = loc
+# Define location for searching translation files
+loc.AddCatalogLookupPathPrefix(localedir)
+# Define locale domain
+loc.AddCatalog(domain)
+
+if __name__ == '__main__':
+ __builtin__.__dict__['_'] = wx.GetTranslation
+
from SFCViewer import *
from LDViewer import *
from Viewer import *
@@ -41,18 +110,7 @@
from PLCControler import *
from plcopen.structures import LOCATIONDATATYPES
-import os, re, platform, sys, time, traceback, getopt
-
-base_folder = os.path.split(sys.path[0])[0]
-sys.path.append(base_folder)
-from docutils import *
-
-from types import TupleType
-
-__version__ = "$Revision$"
-
-CWD = os.path.split(os.path.realpath(__file__))[0]
-
+# Define PLCOpenEditor controls id
[ID_PLCOPENEDITOR, ID_PLCOPENEDITORTREENOTEBOOK,
ID_PLCOPENEDITORTYPESTREE, ID_PLCOPENEDITORINSTANCESTREE,
ID_PLCOPENEDITORMAINSPLITTER, ID_PLCOPENEDITORSECONDSPLITTER,
@@ -102,79 +160,79 @@
ToolBarItems = {
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", "Create a new comment"),
+ "add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", "Create a new variable"),
+ "add_variable.png", _("Create a new variable")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", "Create a new block"),
+ "add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", "Create a new connection")],
+ "add_connection.png", _("Create a new connection"))],
"LD" : [(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", "Create a new comment"),
+ "add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail.png", "Create a new power rail"),
+ "add_powerrail.png", _("Create a new power rail")),
(False, DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool",
- "add_rung.png", "Create a new rung"),
+ "add_rung.png", _("Create a new rung")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool",
- "add_coil.png", "Create a new coil"),
+ "add_coil.png", _("Create a new coil")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact.png", "Create a new contact"),
+ "add_contact.png", _("Create a new contact")),
(False, DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool",
- "add_branch.png", "Create a new branch"),
+ "add_branch.png", _("Create a new branch")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", "Create a new variable"),
+ "add_variable.png", _("Create a new variable")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", "Create a new block"),
+ "add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", "Create a new connection")],
+ "add_connection.png", _("Create a new connection"))],
"SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", "Create a new comment"),
+ "add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
- "add_initial_step.png", "Create a new initial step"),
+ "add_initial_step.png", _("Create a new initial step")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool",
- "add_step.png", "Create a new step"),
+ "add_step.png", _("Create a new step")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool",
- "add_transition.png", "Create a new transition"),
+ "add_transition.png", _("Create a new transition")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
- "add_action.png", "Create a new action block"),
+ "add_action.png", _("Create a new action block")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
- "add_divergence.png", "Create a new divergence"),
+ "add_divergence.png", _("Create a new divergence")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool",
- "add_jump.png", "Create a new jump"),
+ "add_jump.png", _("Create a new jump")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", "Create a new variable"),
+ "add_variable.png", _("Create a new variable")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", "Create a new block"),
+ "add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", "Create a new connection"),
+ "add_connection.png", _("Create a new connection")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail.png", "Create a new power rail"),
+ "add_powerrail.png", _("Create a new power rail")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact.png", "Create a new contact")],
+ "add_contact.png", _("Create a new contact"))],
"ST" : [],
"IL" : []
}
@@ -222,13 +280,15 @@
else:
remove_function(self.Controler, name)
else:
- self.ShowErrorMessage("\"%s\" is used by one or more POUs. It can't be removed!"%name)
+ self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!")%name)
return DeleteElementFunction
#-------------------------------------------------------------------------------
# PLCOpenEditor Main Class
#-------------------------------------------------------------------------------
+UNEDITABLE_NAMES_DICT = dict([(_(name), name) for name in UNEDITABLE_NAMES])
+
class PLCOpenEditor(wx.Frame):
# Compatibility function for wx versions < 2.6
@@ -240,50 +300,50 @@
event(self, function)
def _init_coll_MenuBar_Menus(self, parent):
- parent.Append(menu=self.FileMenu, title=u'File')
+ parent.Append(menu=self.FileMenu, title=_(u'File'))
if not self.Debug:
- parent.Append(menu=self.EditMenu, title=u'Edit')
- parent.Append(menu=self.DisplayMenu, title=u'Display')
- parent.Append(menu=self.HelpMenu, title=u'Help')
+ parent.Append(menu=self.EditMenu, title=_(u'Edit'))
+ parent.Append(menu=self.DisplayMenu, title=_(u'Display'))
+ parent.Append(menu=self.HelpMenu, title=_(u'Help'))
def _init_coll_FileMenu_Items(self, parent):
if self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_NEW,
- kind=wx.ITEM_NORMAL, text=u'New\tCTRL+N')
+ kind=wx.ITEM_NORMAL, text=_(u'New\tCTRL+N'))
AppendMenu(parent, help='', id=wx.ID_OPEN,
- kind=wx.ITEM_NORMAL, text=u'Open\tCTRL+O')
+ kind=wx.ITEM_NORMAL, text=_(u'Open\tCTRL+O'))
AppendMenu(parent, help='', id=wx.ID_CLOSE,
- kind=wx.ITEM_NORMAL, text=u'Close Tab\tCTRL+W')
+ kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W'))
if self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
- kind=wx.ITEM_NORMAL, text=u'Close Project')
+ kind=wx.ITEM_NORMAL, text=_(u'Close Project'))
parent.AppendSeparator()
if not self.Debug:
AppendMenu(parent, help='', id=wx.ID_SAVE,
- kind=wx.ITEM_NORMAL, text=u'Save\tCTRL+S')
+ kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S'))
if self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_SAVEAS,
- kind=wx.ITEM_NORMAL, text=u'Save As...\tCTRL+SHIFT+S')
+ kind=wx.ITEM_NORMAL, text=_(u'Save As...\tCTRL+SHIFT+S'))
AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATE,
- kind=wx.ITEM_NORMAL, text=u'Generate Program\tCTRL+G')
+ kind=wx.ITEM_NORMAL, text=_(u'Generate Program\tCTRL+G'))
parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP,
- kind=wx.ITEM_NORMAL, text=u'Page Setup')
+ kind=wx.ITEM_NORMAL, text=_(u'Page Setup'))
AppendMenu(parent, help='', id=wx.ID_PREVIEW,
- kind=wx.ITEM_NORMAL, text=u'Preview')
+ kind=wx.ITEM_NORMAL, text=_(u'Preview'))
AppendMenu(parent, help='', id=wx.ID_PRINT,
- kind=wx.ITEM_NORMAL, text=u'Print')
+ kind=wx.ITEM_NORMAL, text=_(u'Print'))
if not self.Debug:
parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_PROPERTIES,
- kind=wx.ITEM_NORMAL, text=u'Properties')
+ kind=wx.ITEM_NORMAL, text=_(u'Properties'))
parent.AppendSeparator()
if self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_EXIT,
- kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q')
+ kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q'))
else:
AppendMenu(parent, help='', id=wx.ID_STOP,
- kind=wx.ITEM_NORMAL, text=u'Close\tCTRL+Q')
+ kind=wx.ITEM_NORMAL, text=_(u'Close\tCTRL+Q'))
if self.ModeSolo:
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
@@ -309,35 +369,33 @@
def _init_coll_EditMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_UNDO,
- kind=wx.ITEM_NORMAL, text=u'Undo\tCTRL+Z')
+ kind=wx.ITEM_NORMAL, text=_(u'Undo\tCTRL+Z'))
AppendMenu(parent, help='', id=wx.ID_REDO,
- kind=wx.ITEM_NORMAL, text=u'Redo\tCTRL+Y')
- AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO,
- kind=wx.ITEM_CHECK, text=u'Enable Undo/Redo')
+ kind=wx.ITEM_NORMAL, text=_(u'Redo\tCTRL+Y'))
parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_CUT,
- kind=wx.ITEM_NORMAL, text=u'Cut\tCTRL+X')
+ kind=wx.ITEM_NORMAL, text=_(u'Cut\tCTRL+X'))
AppendMenu(parent, help='', id=wx.ID_COPY,
- kind=wx.ITEM_NORMAL, text=u'Copy\tCTRL+C')
+ kind=wx.ITEM_NORMAL, text=_(u'Copy\tCTRL+C'))
AppendMenu(parent, help='', id=wx.ID_PASTE,
- kind=wx.ITEM_NORMAL, text=u'Paste\tCTRL+V')
+ kind=wx.ITEM_NORMAL, text=_(u'Paste\tCTRL+V'))
parent.AppendSeparator()
addmenu = wx.Menu(title='')
- parent.AppendMenu(wx.ID_ADD, "Add Element", addmenu)
+ parent.AppendMenu(wx.ID_ADD, _("Add Element"), addmenu)
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDDATATYPE,
- kind=wx.ITEM_NORMAL, text=u'Data Type')
+ kind=wx.ITEM_NORMAL, text=_(u'Data Type'))
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTION,
- kind=wx.ITEM_NORMAL, text=u'Function')
+ kind=wx.ITEM_NORMAL, text=_(u'Function'))
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK,
- kind=wx.ITEM_NORMAL, text=u'Function Block')
+ kind=wx.ITEM_NORMAL, text=_(u'Function Block'))
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDPROGRAM,
- kind=wx.ITEM_NORMAL, text=u'Program')
+ kind=wx.ITEM_NORMAL, text=_(u'Program'))
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION,
- kind=wx.ITEM_NORMAL, text=u'Configuration')
+ kind=wx.ITEM_NORMAL, text=_(u'Configuration'))
AppendMenu(parent, help='', id=wx.ID_SELECTALL,
- kind=wx.ITEM_NORMAL, text=u'Select All\tCTRL+A')
+ kind=wx.ITEM_NORMAL, text=_(u'Select All\tCTRL+A'))
AppendMenu(parent, help='', id=wx.ID_DELETE,
- kind=wx.ITEM_NORMAL, text=u'Delete')
+ kind=wx.ITEM_NORMAL, text=_(u'Delete'))
self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO)
self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO)
self.Bind(wx.EVT_MENU, self.OnEnableUndoRedoMenu, id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO)
@@ -359,13 +417,13 @@
def _init_coll_DisplayMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_REFRESH,
- kind=wx.ITEM_NORMAL, text=u'Refresh\tF5')
+ kind=wx.ITEM_NORMAL, text=_(u'Refresh\tF5'))
if not self.Debug and not self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_CLEAR,
- kind=wx.ITEM_NORMAL, text=u'Clear Errors\tCTRL+K')
+ kind=wx.ITEM_NORMAL, text=_(u'Clear Errors\tCTRL+K'))
parent.AppendSeparator()
zoommenu = wx.Menu(title='')
- parent.AppendMenu(wx.ID_ZOOM_FIT, "ZOOM", zoommenu)
+ parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu)
for idx, value in enumerate(ZOOM_FACTORS):
new_id = wx.NewId()
AppendMenu(zoommenu, help='', id=new_id,
@@ -377,14 +435,14 @@
def _init_coll_HelpMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_HELP,
- kind=wx.ITEM_NORMAL, text=u'PLCOpenEditor\tF1')
+ kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor\tF1'))
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS,
# kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2')
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT,
# kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3')
if self.ModeSolo:
AppendMenu(parent, help='', id=wx.ID_ABOUT,
- kind=wx.ITEM_NORMAL, text=u'About')
+ kind=wx.ITEM_NORMAL, text=_(u'About'))
self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP)
#self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS)
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
@@ -424,7 +482,7 @@
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor',
parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600),
- style=wx.DEFAULT_FRAME_STYLE, title=u'PLCOpenEditor')
+ style=wx.DEFAULT_FRAME_STYLE, title=_(u'PLCOpenEditor'))
self._init_utils()
self.SetClientSize(wx.Size(1000, 600))
self.SetMenuBar(self.MenuBar)
@@ -436,7 +494,7 @@
self.Panes = {}
self.TreeNoteBook = wx.aui.AuiNotebook(self)
- self.AUIManager.AddPane(self.TreeNoteBook, wx.aui.AuiPaneInfo().Caption("Project").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False))
+ self.AUIManager.AddPane(self.TreeNoteBook, wx.aui.AuiPaneInfo().Caption(_("Project")).Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False))
else:
self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER,
@@ -498,8 +556,8 @@
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnInstancesTreeItemActivated,
id=ID_PLCOPENEDITORINSTANCESTREE)
- self.TreeNoteBook.AddPage(self.InstancesTree, "Instances")
- self.TreeNoteBook.AddPage(self.TypesTree, "Types")
+ self.TreeNoteBook.AddPage(self.InstancesTree, _("Instances"))
+ self.TreeNoteBook.AddPage(self.TypesTree, _("Types"))
if USE_AUI:
self.TabsOpened = wx.aui.AuiNotebook(self)
@@ -512,7 +570,7 @@
self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane())
self.DebugVariablePanel = DebugVariablePanel(self, self.Controler)
- self.AUIManager.AddPane(self.DebugVariablePanel, wx.aui.AuiPaneInfo().Caption("Variables").Right().Layer(0).BestSize(wx.Size(250, 600)).CloseButton(False))
+ self.AUIManager.AddPane(self.DebugVariablePanel, wx.aui.AuiPaneInfo().Caption(_("Variables")).Right().Layer(0).BestSize(wx.Size(250, 600)).CloseButton(False))
else:
self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
@@ -535,19 +593,19 @@
self.SecondSplitter.SplitVertically(self.TabsOpened, self.DebugVariablePanel, -250)
else:
- self.TreeNoteBook.AddPage(self.TypesTree, "Types")
- self.TreeNoteBook.AddPage(self.InstancesTree, "Instances")
+ self.TreeNoteBook.AddPage(self.TypesTree, _("Types"))
+ self.TreeNoteBook.AddPage(self.InstancesTree, _("Instances"))
if USE_AUI:
ToolBar = wx.ToolBar(self, ID_PLCOPENEDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
ToolBar.SetToolBitmapSize(wx.Size(25, 25))
ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION,
- wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
+ wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
ToolBar.Realize()
self.Panes["ToolBar"] = ToolBar
self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo().
- Name("ToolBar").Caption("Toolbar").
+ Name("ToolBar").Caption(_("Toolbar")).
ToolbarPane().Top().
LeftDockable(False).RightDockable(False))
else:
@@ -555,7 +613,7 @@
ID_PLCOPENEDITORTOOLBAR, 'ToolBar')
self.ToolBar.SetToolBitmapSize(wx.Size(25, 25))
self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION,
- wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
+ wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
self.ToolBar.Realize()
self.Bind(wx.EVT_TOOL, self.OnSelectionTool,
@@ -563,7 +621,7 @@
if USE_AUI:
self.VariablePanelIndexer = VariablePanelIndexer(self, self, self.Controler)
- self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption("Variables").Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False))
+ self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption(_("Variables")).Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False))
self.TabsOpened = wx.aui.AuiNotebook(self)
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
@@ -577,7 +635,7 @@
self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL,
name='LibraryPanel', parent=self, pos=wx.Point(0,
0), size=wx.Size(0, 0), style=0)
- self.AUIManager.AddPane(self.LibraryPanel, wx.aui.AuiPaneInfo().Caption("Library").Right().Layer(0).BestSize(wx.Size(250, 400)).CloseButton(False))
+ self.AUIManager.AddPane(self.LibraryPanel, wx.aui.AuiPaneInfo().Caption(_("Library")).Right().Layer(0).BestSize(wx.Size(250, 400)).CloseButton(False))
else:
self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
@@ -777,9 +835,9 @@
return self.DrawingMode
def RefreshTitle(self):
- name = "PLCOpenEditor"
+ name = _("PLCOpenEditor")
if self.Debug:
- name += " (Debug)"
+ name += _(" (Debug)")
if self.Controler.HasOpenedProject() > 0:
self.SetTitle("%s - %s"%(name, self.Controler.GetFilename()))
else:
@@ -892,7 +950,7 @@
## Function displaying an Error dialog in PLCOpenEditor.
# @param message The message to display.
def ShowErrorMessage(self, message):
- dialog = wx.MessageDialog(self, message, "Error", wx.OK|wx.ICON_ERROR)
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
dialog.ShowModal()
dialog.Destroy()
@@ -900,7 +958,7 @@
# @return False if closing cancelled.
def CheckSaveBeforeClosing(self):
if not self.Controler.ProjectIsSaved():
- dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
+ dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), _("Close Application"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
if answer == wx.ID_YES:
@@ -970,7 +1028,7 @@
directory = os.path.dirname(filepath)
else:
directory = os.getcwd()
- dialog = wx.FileDialog(self, "Choose a file", directory, "", "PLCOpen files (*.xml)|*.xml|All files|*.*", wx.OPEN)
+ dialog = wx.FileDialog(self, _("Choose a file"), directory, "", _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isfile(filepath):
@@ -1021,23 +1079,23 @@
event.Skip()
def OnGenerateProgramMenu(self, event):
- dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), self.Controler.GetProgramFilePath(), "ST files (*.st)|*.st|All files|*.*", wx.SAVE|wx.CHANGE_DIR)
+ dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(), _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE|wx.CHANGE_DIR)
if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
message_text = ""
- header, icon = "Done", wx.ICON_INFORMATION
+ header, icon = _("Done"), wx.ICON_INFORMATION
if os.path.isdir(os.path.dirname(filepath)):
program, errors, warnings = self.Controler.GenerateProgram(filepath)
- message_text += "".join(["warning: %s\n" for warning in warnings])
+ message_text += "".join([_("warning: %s\n") for warning in warnings])
if len(errors) > 0:
- message_text += "".join(["error: %s\n" for warning in warnings])
- message_text += "Can't generate program to file %s!"%filepath
- header, icon = "Error", wx.ICON_ERROR
+ message_text += "".join([_("error: %s\n") for warning in warnings])
+ message_text += _("Can't generate program to file %s!")%filepath
+ header, icon = _("Error"), wx.ICON_ERROR
else:
- message_text += "Program was successfully generated!"
+ message_text += _("Program was successfully generated!")
else:
- message_text += "%s is not a valid folder!"%os.path.dirname(filepath)
- header, icon = "Error", wx.ICON_ERROR
+ message_text += _("\"%s\" is not a valid folder!")%os.path.dirname(filepath)
+ header, icon = _("Error"), wx.ICON_ERROR
message = wx.MessageDialog(self, message_text, header, wx.OK|icon)
message.ShowModal()
message.Destroy()
@@ -1057,15 +1115,15 @@
directory, filename = os.path.split(filepath)
else:
directory, filename = os.getcwd(), "%(projectName)s.xml"%self.Controler.GetProjectProperties(self.Debug)
- dialog = wx.FileDialog(self, "Choose a file", directory, filename, "PLCOpen files (*.xml)|*.xml|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT)
+ dialog = wx.FileDialog(self, _("Choose a file"), directory, filename, _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT)
if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):
result = self.Controler.SaveXMLFile(filepath)
if not result:
- self.ShowErrorMessage("Can't save project to file %s!"%filepath)
+ self.ShowErrorMessage(_("Can't save project to file %s!")%filepath)
else:
- self.ShowErrorMessage("\"%s\" is not a valid folder!"%os.path.dirname(filepath))
+ self.ShowErrorMessage(_("\"%s\" is not a valid folder!")%os.path.dirname(filepath))
self.RefreshTitle()
dialog.Destroy()
@@ -1089,7 +1147,7 @@
preview = wx.PrintPreview(printout, printout2, data)
if preview.Ok():
- preview_frame = wx.PreviewFrame(preview, self, "Print preview")
+ preview_frame = wx.PreviewFrame(preview, self, _("Print preview"))
preview_frame.Initialize()
@@ -1108,7 +1166,7 @@
printout = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins)
if not printer.Print(self, printout, True):
- self.ShowErrorMessage("There was a problem printing.\nPerhaps your current printer is not set correctly?")
+ self.ShowErrorMessage(_("There was a problem printing.\nPerhaps your current printer is not set correctly?"))
printout.Destroy()
event.Skip()
@@ -1403,7 +1461,8 @@
def GenerateTypesTreeBranch(self, root, infos, topology=False):
to_delete = []
- self.TypesTree.SetItemText(root, infos["name"])
+ item_name = infos["name"]
+ self.TypesTree.SetItemText(root, _(item_name))
self.TypesTree.SetPyData(root, infos["type"])
if infos.get("tagname", None) in self.Errors:
self.TypesTree.SetItemBackgroundColour(root, wx.Colour(255, 255, 0))
@@ -1498,9 +1557,9 @@
new_name = event.GetLabel()
if new_name != "":
if not TestIdentifier(new_name):
- message = "\"%s\" is not a valid identifier!"%new_name
+ message = _("\"%s\" is not a valid identifier!")%new_name
elif new_name.upper() in IEC_KEYWORDS:
- message = "\"%s\" is a keyword. It can't be used!"%new_name
+ message = _("\"%s\" is a keyword. It can't be used!")%new_name
else:
item = event.GetItem()
old_name = self.TypesTree.GetItemText(item)
@@ -1509,7 +1568,7 @@
self.Controler.SetProjectProperties(name = new_name)
elif itemtype == ITEM_DATATYPE:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames(self.Debug) if name != old_name]:
- message = "\"%s\" data type already exists!"%new_name
+ message = _("\"%s\" data type already exists!")%new_name
abort = True
if not abort:
self.Controler.ChangeDataTypeName(old_name, new_name)
@@ -1518,10 +1577,10 @@
self.RefreshPageTitles()
elif itemtype == ITEM_POU:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug) if name != old_name]:
- message = "\"%s\" pou already exists!"%new_name
+ message = _("\"%s\" pou already exists!")%new_name
abort = True
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
- messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION)
+ messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
if messageDialog.ShowModal() == wx.ID_NO:
abort = True
messageDialog.Destroy()
@@ -1534,9 +1593,9 @@
elif itemtype == ITEM_TRANSITION:
pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
- message = "A pou with \"%s\" as name exists!"%new_name
+ message = _("A pou with \"%s\" as name exists!")%new_name
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
- message = "A variable with \"%s\" as name already exists in this pou!"%new_name
+ message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
else:
self.Controler.ChangePouTransitionName(pou_name, old_name, new_name)
self.RefreshEditorNames(self.Controler.ComputePouTransitionName(pou_name, old_name),
@@ -1545,9 +1604,9 @@
elif itemtype == ITEM_ACTION:
pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
- message = "A pou with \"%s\" as name exists!"%new_name
+ message = _("A pou with \"%s\" as name exists!")%new_name
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
- message = "A variable with \"%s\" as name already exists in this pou!"%new_name
+ message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
else:
self.Controler.ChangePouActionName(pou_name, old_name, new_name)
self.RefreshEditorNames(self.Controler.ComputePouActionName(pou_name, old_name),
@@ -1555,15 +1614,15 @@
self.RefreshPageTitles()
elif itemtype == ITEM_CONFIGURATION:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug) if name != old_name]:
- message = "\"%s\" config already exists!"%new_name
+ message = _("\"%s\" config already exists!")%new_name
abort = True
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
- messageDialog = wx.MessageDialog(self, "A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION)
+ messageDialog = wx.MessageDialog(self, _("A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
if messageDialog.ShowModal() == wx.ID_NO:
abort = True
messageDialog.Destroy()
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
- messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION)
+ messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
if messageDialog.ShowModal() == wx.ID_NO:
abort = True
messageDialog.Destroy()
@@ -1575,15 +1634,15 @@
elif itemtype == ITEM_RESOURCE:
config_name = GetParentName(self.TypesTree, item, ITEM_CONFIGURATION)
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug)]:
- message = "\"%s\" config already exists!"%new_name
+ message = _("\"%s\" config already exists!")%new_name
abort = True
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
- messageDialog = wx.MessageDialog(self, "A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION)
+ messageDialog = wx.MessageDialog(self, _("A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
if messageDialog.ShowModal() == wx.ID_NO:
abort = True
messageDialog.Destroy()
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
- messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION)
+ messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
if messageDialog.ShowModal() == wx.ID_NO:
abort = True
messageDialog.Destroy()
@@ -1608,7 +1667,7 @@
selected = event.GetItem()
name = self.TypesTree.GetItemText(selected)
data = self.TypesTree.GetPyData(selected)
- if name == "Properties":
+ if UNEDITABLE_NAMES_DICT.get(name, name) == "Properties":
self.ShowProperties()
if data == ITEM_DATATYPE:
self.EditProjectElement(data, self.Controler.ComputeDataTypeName(name))
@@ -1735,71 +1794,72 @@
menu = wx.Menu(title='')
if self.Controler.GetPouBodyType(name, self.Debug) == "SFC":
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Transition")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition"))
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id)
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Action")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action"))
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id)
menu.AppendSeparator()
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Create A New POU From")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Create a new POU from"))
self.Bind(wx.EVT_MENU, self.OnCreatePouFromMenu, id=new_id)
pou_type = self.Controler.GetPouType(name, self.Debug)
if pou_type in ["function", "functionBlock"]:
change_menu = wx.Menu(title='')
if pou_type == "function":
new_id = wx.NewId()
- AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Function Block")
+ AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Function Block"))
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), id=new_id)
new_id = wx.NewId()
- AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Program")
+ AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Program"))
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id)
- menu.AppendMenu(wx.NewId(), "Change POU Type To", change_menu)
+ menu.AppendMenu(wx.NewId(), _("Change POU Type To"), change_menu)
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Rename")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Rename"))
self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id)
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete"))
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id)
self.PopupMenu(menu)
elif type == ITEM_CONFIGURATION:
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Resource")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource"))
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id)
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete"))
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id)
self.PopupMenu(menu)
elif type in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]:
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete"))
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id)
self.PopupMenu(menu)
elif type in ITEMS_UNEDITABLE:
+ name = UNEDITABLE_NAMES_DICT[name]
if name == "Data Types":
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add DataType")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add DataType"))
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, id=new_id)
self.PopupMenu(menu)
elif name in ["Functions", "Function Blocks", "Programs"]:
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Pou")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Pou"))
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions" : "function", "Function Blocks" : "functionBlock", "Programs" : "program"}[name]), id=new_id)
self.PopupMenu(menu)
elif name == "Configurations":
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Configuration")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Configuration"))
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, id=new_id)
self.PopupMenu(menu)
elif name == "Transitions":
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Transition")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition"))
parent = self.TypesTree.GetItemParent(item)
parent_type = self.TypesTree.GetPyData(parent)
while parent_type != ITEM_POU:
@@ -1810,7 +1870,7 @@
elif name == "Actions":
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Action")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action"))
parent = self.TypesTree.GetItemParent(item)
parent_type = self.TypesTree.GetPyData(parent)
while parent_type != ITEM_POU:
@@ -1821,7 +1881,7 @@
elif name == "Resources":
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Resource")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource"))
parent = self.TypesTree.GetItemParent(item)
parent_type = self.TypesTree.GetPyData(parent)
while parent_type != ITEM_CONFIGURATION:
@@ -1965,10 +2025,10 @@
menu = wx.Menu(title='')
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Graphic Panel")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Graphic Panel"))
self.Bind(wx.EVT_MENU, self.AddVariableGraphicFunction(var_path), id=new_id)
new_id = wx.NewId()
- AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="CSV Log")
+ AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("CSV Log"))
self.PopupMenu(menu)
event.Skip()
@@ -2014,7 +2074,7 @@
root = self.LibraryTree.GetRootItem()
if not root.IsOk():
if wx.Platform == '__WXMSW__':
- root = self.LibraryTree.AddRoot("Block Types")
+ root = self.LibraryTree.AddRoot(_("Block Types"))
self.LibraryTree.SetPyData(root, {"type" : CATEGORY})
else:
root = self.LibraryTree.AddRoot("")
@@ -2023,12 +2083,13 @@
else:
category_item, root_cookie = self.LibraryTree.GetFirstChild(root, 0)
for category in blocktypes:
+ category_name = category["name"]
if not category_item.IsOk():
- category_item = self.LibraryTree.AppendItem(root, category["name"])
+ category_item = self.LibraryTree.AppendItem(root, _(category_name))
if wx.Platform != '__WXMSW__':
category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
else:
- self.LibraryTree.SetItemText(category_item, category["name"])
+ self.LibraryTree.SetItemText(category_item, _(category_name))
self.LibraryTree.SetPyData(category_item, {"type" : CATEGORY})
if wx.VERSION >= (2, 6, 0):
blocktype_item, category_cookie = self.LibraryTree.GetFirstChild(category_item)
@@ -2061,7 +2122,8 @@
if pydata is not None and pydata["type"] != CATEGORY:
blocktype = self.Controler.GetBlockType(self.LibraryTree.GetItemText(selected), pydata["inputs"], debug = self.Debug)
if blocktype:
- self.LibraryComment.SetValue(blocktype["comment"])
+ comment = blocktype["comment"]
+ self.LibraryComment.SetValue(_(comment) + blocktype.get("usage", ""))
else:
self.LibraryComment.SetValue("")
else:
@@ -2294,7 +2356,7 @@
#-------------------------------------------------------------------------------
def OnAddDataTypeMenu(self, event):
- dialog = DataTypeDialog(self, "Add a new data type", "Please enter data type name", "", wx.OK|wx.CANCEL)
+ dialog = DataTypeDialog(self, _("Add a new data type"), _("Please enter data type name"), "", wx.OK|wx.CANCEL)
dialog.SetDataTypeNames(self.Controler.GetProjectDataTypeNames(self.Debug))
if dialog.ShowModal() == wx.ID_OK:
self.Controler.ProjectAddDataType(dialog.GetValue())
@@ -2351,7 +2413,7 @@
return OnAddActionMenu
def OnAddConfigurationMenu(self, event):
- dialog = ConfigurationNameDialog(self, "Please enter configuration name", "Add new configuration")
+ dialog = ConfigurationNameDialog(self, _("Please enter configuration name"), _("Add new configuration"))
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(debug = self.Debug))
if dialog.ShowModal() == wx.ID_OK:
@@ -2366,7 +2428,7 @@
def GenerateAddResourceFunction(self, config_name):
def OnAddResourceMenu(event):
- dialog = ResourceNameDialog(self, "Please enter resource name", "Add new resource")
+ dialog = ResourceNameDialog(self, _("Please enter resource name"), _("Add new resource"))
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(debug = self.Debug))
if dialog.ShowModal() == wx.ID_OK:
@@ -2396,7 +2458,7 @@
def OnCreatePouFromMenu(self, event):
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_POU:
- dialog = PouNameDialog(self, "Please enter POU name", "Create a new POU from", "", wx.OK|wx.CANCEL)
+ dialog = PouNameDialog(self, _("Please enter POU name"), _("Create a new POU from"), "", wx.OK|wx.CANCEL)
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
if dialog.ShowModal() == wx.ID_OK:
self.Controler.ProjectCreatePouFrom(dialog.GetValue(), self.TypesTree.GetItemText(selected))
@@ -2426,7 +2488,7 @@
self.RefreshTypesTree()
self.RefreshToolBar()
else:
- message = wx.MessageDialog(self, "\"%s\" is used by one or more POUs. It can't be removed!"%name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is used by one or more POUs. It can't be removed!")%name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Skip()
@@ -2455,7 +2517,7 @@
self.RefreshLibraryTree()
self.RefreshToolBar()
else:
- message = wx.MessageDialog(self, "\"%s\" is used by one or more POUs. It can't be removed!"%name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is used by one or more POUs. It can't be removed!")%name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Skip()
@@ -2541,7 +2603,7 @@
event.Skip()
def OnPLCOpenEditorMenu(self, event):
- wx.MessageBox("No documentation available.\nComing soon.")
+ wx.MessageBox(_("No documentation available.\nComing soon."))
#event.Skip()
def OnPLCOpenMenu(self, event):
@@ -2549,7 +2611,7 @@
event.Skip()
def OnAboutMenu(self, event):
- OpenHtmlFrame(self,"About PLCOpenEditor", os.path.join(CWD, "doc","about.html"), wx.Size(350, 350))
+ OpenHtmlFrame(self,_("About PLCOpenEditor"), os.path.join(CWD, "doc","about.html"), wx.Size(350, 350))
event.Skip()
@@ -2610,16 +2672,16 @@
class ScalingPanel(wx.Panel):
def _init_coll_ScalingPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT)
+ parent.AddWindow(self.staticText1, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
parent.AddWindow(self.XScale, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
- parent.AddWindow(self.staticText2, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT)
+ parent.AddWindow(self.staticText2, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.LEFT)
parent.AddWindow(self.YScale, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
def _init_coll_ScalingPanelSizer_Growables(self, parent):
parent.AddGrowableCol(1)
def _init_sizers(self):
- self.ScalingPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=5)
+ self.ScalingPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
self._init_coll_ScalingPanelSizer_Items(self.ScalingPanelSizer)
self._init_coll_ScalingPanelSizer_Growables(self.ScalingPanelSizer)
@@ -2632,16 +2694,16 @@
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.staticText1 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT1,
- label='X Scale:', name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
+ label=_('X Scale:'), name='staticText1', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.XScale = wx.SpinCtrl(id=ID_SCALINGPANELXSCALE,
name='XScale', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0, min=0, max=2**16)
self.staticText2 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT2,
- label='Y Scale:', name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
+ label=_('Y Scale:'), name='staticText2', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.YScale = wx.SpinCtrl(id=ID_SCALINGPANELYSCALE,
name='YScale', parent=self, pos=wx.Point(0, 0),
@@ -2696,37 +2758,37 @@
parent.AddGrowableRow(0)
def _init_coll_ProjectPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT)
+ parent.AddWindow(self.staticText1, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
parent.AddWindow(self.ProjectName, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
- parent.AddWindow(self.staticText2, 0, border=10, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText2, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.ProjectVersion, 0, border=10, flag=wx.GROW|wx.RIGHT)
- parent.AddWindow(self.staticText3, 0, border=10, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText3, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.ProductName, 0, border=10, flag=wx.GROW|wx.RIGHT)
- parent.AddWindow(self.staticText4, 0, border=10, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText4, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.ProductVersion, 0, border=10, flag=wx.GROW|wx.RIGHT)
- parent.AddWindow(self.staticText5, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT)
+ parent.AddWindow(self.staticText5, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.LEFT)
parent.AddWindow(self.ProductRelease, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
def _init_coll_ProjectPanelSizer_Growables(self, parent):
parent.AddGrowableCol(1)
def _init_coll_AuthorPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText6, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT)
+ parent.AddWindow(self.staticText6, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
parent.AddWindow(self.CompanyName, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
- parent.AddWindow(self.staticText7, 0, border=10, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText7, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.CompanyURL, 0, border=10, flag=wx.GROW|wx.RIGHT)
- parent.AddWindow(self.staticText8, 0, border=10, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText8, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.AuthorName, 0, border=10, flag=wx.GROW|wx.RIGHT)
- parent.AddWindow(self.staticText9, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT)
+ parent.AddWindow(self.staticText9, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.LEFT)
parent.AddWindow(self.Organization, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
def _init_coll_AuthorPanelSizer_Growables(self, parent):
parent.AddGrowableCol(1)
def _init_coll_GraphicsPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText12, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+ parent.AddWindow(self.staticText12, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT)
parent.AddSizer(self.GraphicsPageSizeSizer, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
- parent.AddWindow(self.staticText15, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
+ parent.AddWindow(self.staticText15, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT)
parent.AddWindow(self.ScalingNotebook, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
def _init_coll_GraphicsPanelSizer_Growables(self, parent):
@@ -2734,18 +2796,18 @@
parent.AddGrowableRow(3)
def _init_coll_GraphicsPageSizeSizer_Items(self, parent):
- parent.AddWindow(self.staticText13, 0, border=12, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText13, 0, border=12, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.PageWidth, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText14, 0, border=12, flag=wx.GROW|wx.LEFT)
+ parent.AddWindow(self.staticText14, 0, border=12, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
parent.AddWindow(self.PageHeight, 0, border=0, flag=wx.GROW)
def _init_coll_GraphicsPageSizeSizer_Growables(self, parent):
parent.AddGrowableCol(1)
def _init_coll_MiscellaneousPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText10, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT)
+ parent.AddWindow(self.staticText10, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
parent.AddWindow(self.Language, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
- parent.AddWindow(self.staticText11, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT)
+ parent.AddWindow(self.staticText11, 0, border=10, flag=wx.BOTTOM|wx.LEFT)
parent.AddWindow(self.ContentDescription, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
def _init_coll_MiscellaneousPanelSizer_Growables(self, parent):
@@ -2754,11 +2816,11 @@
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.ProjectPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=5, vgap=15)
- self.AuthorPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=15)
- self.GraphicsPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=5)
- self.GraphicsPageSizeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=5)
- self.MiscellaneousPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15)
+ self.ProjectPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15)
+ self.AuthorPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15)
+ self.GraphicsPanelSizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5)
+ self.GraphicsPageSizeSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
+ self.MiscellaneousPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
@@ -2783,7 +2845,7 @@
wx.Dialog.__init__(self, id=ID_PROJECTDIALOG,
name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
size=wx.Size(500, 350), style=wx.DEFAULT_DIALOG_STYLE,
- title='Project properties')
+ title=_('Project properties'))
self.SetClientSize(wx.Size(500, 350))
self.MainNotebook = wx.Notebook(id=ID_PROJECTDIALOGMAINNOTEBOOK,
@@ -2797,46 +2859,46 @@
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.staticText1 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT1,
- label='Project Name (required):', name='staticText1', parent=self.ProjectPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Project Name (required):'), name='staticText1', parent=self.ProjectPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ProjectName = wx.TextCtrl(id=ID_PROJECTDIALOGPROJECTNAME,
name='ProjectName', parent=self.ProjectPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText2 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT2,
- label='Project Version (optional):', name='staticText2', parent=self.ProjectPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Project Version (optional):'), name='staticText2', parent=self.ProjectPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ProjectVersion = wx.TextCtrl(id=ID_PROJECTDIALOGPROJECTVERSION,
name='ProjectVersion', parent=self.ProjectPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText3 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT3,
- label='Product Name (required):', name='staticText3', parent=self.ProjectPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Product Name (required):'), name='staticText3', parent=self.ProjectPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ProductName = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTNAME,
name='ProductName', parent=self.ProjectPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText4 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT4,
- label='Product Version (required):', name='staticText4', parent=self.ProjectPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Product Version (required):'), name='staticText4', parent=self.ProjectPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ProductVersion = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTVERSION,
name='ProductVersion', parent=self.ProjectPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText5 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT5,
- label='Product Release (optional):', name='staticText5', parent=self.ProjectPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Product Release (optional):'), name='staticText5', parent=self.ProjectPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ProductRelease = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTRELEASE,
name='ProductRelease', parent=self.ProjectPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
- self.MainNotebook.AddPage(self.ProjectPanel, "Project")
+ self.MainNotebook.AddPage(self.ProjectPanel, _("Project"))
# Author Panel elements
@@ -2845,38 +2907,38 @@
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.staticText6 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT6,
- label='Company Name (required):', name='staticText6', parent=self.AuthorPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Company Name (required):'), name='staticText6', parent=self.AuthorPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.CompanyName = wx.TextCtrl(id=ID_PROJECTDIALOGCOMPANYNAME,
name='CompanyName', parent=self.AuthorPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText7 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT7,
- label='Company URL (optional):', name='staticText7', parent=self.AuthorPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Company URL (optional):'), name='staticText7', parent=self.AuthorPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.CompanyURL = wx.TextCtrl(id=ID_PROJECTDIALOGCOMPANYURL,
name='CompanyURL', parent=self.AuthorPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText8 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT8,
- label='Author Name (optional):', name='staticText8', parent=self.AuthorPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Author Name (optional):'), name='staticText8', parent=self.AuthorPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.AuthorName = wx.TextCtrl(id=ID_PROJECTDIALOGAUTHORNAME,
name='AuthorName', parent=self.AuthorPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText9 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT9,
- label='Organization (optional):', name='staticText9', parent=self.AuthorPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Organization (optional):'), name='staticText9', parent=self.AuthorPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.Organization = wx.TextCtrl(id=ID_PROJECTDIALOGORGANIZATION,
name='Organization', parent=self.AuthorPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
- self.MainNotebook.AddPage(self.AuthorPanel, "Author")
+ self.MainNotebook.AddPage(self.AuthorPanel, _("Author"))
# Graphics Panel elements
@@ -2885,40 +2947,40 @@
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.staticText12 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT12,
- label='Page Size (optional):', name='staticText12', parent=self.GraphicsPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Page Size (optional):'), name='staticText12', parent=self.GraphicsPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.staticText13 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT13,
- label='Width:', name='staticText13', parent=self.GraphicsPanel,
- pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
+ label=_('Width:'), name='staticText13', parent=self.GraphicsPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.PageWidth = wx.SpinCtrl(id=ID_PROJECTDIALOGPAGEWIDTH,
name='PageWidth', parent=self.GraphicsPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0, min=0, max=2**16)
self.staticText14 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT14,
- label='Height:', name='staticText14', parent=self.GraphicsPanel,
- pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
+ label=_('Height:'), name='staticText14', parent=self.GraphicsPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.PageHeight = wx.SpinCtrl(id=ID_PROJECTDIALOGPAGEHEIGHT,
name='PageHeight', parent=self.GraphicsPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0, min=0, max=2**16)
self.staticText15 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT15,
- label='Scaling:', name='staticText15', parent=self.GraphicsPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Scaling:'), name='staticText15', parent=self.GraphicsPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ScalingNotebook = wx.Notebook(id=ID_PROJECTDIALOGSCALINGNOTEBOOK,
name='ScalingNotebook', parent=self.GraphicsPanel, pos=wx.Point(0,
0), size=wx.Size(0, 0), style=0)
self.Scalings = {}
- for language in ["FBD", "LD", "SFC"]:
+ for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]:
window = ScalingPanel(self.ScalingNotebook)
self.Scalings[language] = window
- self.ScalingNotebook.AddPage(window, language)
-
- self.MainNotebook.AddPage(self.GraphicsPanel, "Graphics")
+ self.ScalingNotebook.AddPage(window, translation)
+
+ self.MainNotebook.AddPage(self.GraphicsPanel, _("Graphics"))
# Miscellaneous Panel elements
@@ -2927,22 +2989,22 @@
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.staticText10 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT10,
- label='Language (optional):', name='staticText10', parent=self.MiscellaneousPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Language (optional):'), name='staticText10', parent=self.MiscellaneousPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.Language = wx.ComboBox(id=ID_PROJECTDIALOGLANGUAGE,
name='Language', parent=self.MiscellaneousPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 28), style=wx.CB_READONLY)
self.staticText11 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT11,
- label='Content Description (optional):', name='staticText11', parent=self.MiscellaneousPanel,
- pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0)
+ label=_('Content Description (optional):'), name='staticText11', parent=self.MiscellaneousPanel,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ContentDescription = wx.TextCtrl(id=ID_PROJECTDIALOGCONTENTDESCRIPTION,
name='ContentDescription', parent=self.MiscellaneousPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=wx.TE_MULTILINE)
- self.MainNotebook.AddPage(self.MiscellaneousPanel, "Miscellaneous")
+ self.MainNotebook.AddPage(self.MiscellaneousPanel, _("Miscellaneous"))
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
@@ -2952,7 +3014,7 @@
def __init__(self, parent):
self._init_ctrls(parent)
- languages = ["", "en-US", "fr-FR"]
+ languages = ["", "en-US", "fr-FR", "zh-CN"]
for language in languages:
self.Language.Append(language)
@@ -2976,7 +3038,7 @@
text += " and %s"%item
else:
text += ", %s"%item
- message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
@@ -3053,7 +3115,7 @@
else:
event(self, function)
- def __init__(self, parent, message, caption = "Please enter text", defaultValue = "",
+ def __init__(self, parent, message, caption = _("Please enter text"), defaultValue = "",
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
@@ -3068,19 +3130,19 @@
def OnOK(self, event):
datatype_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if datatype_name == "":
- message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(datatype_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%datatype_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif datatype_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%datatype_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif datatype_name.upper() in self.DataTypeNames:
- message = wx.MessageDialog(self, "\"%s\" data type already exists!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" data type already exists!")%datatype_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
@@ -3101,6 +3163,21 @@
ID_POUDIALOGSTATICTEXT2, ID_POUDIALOGSTATICTEXT3,
] = [wx.NewId() for _init_ctrls in range(7)]
+def GetTransitionLanguages():
+ _ = lambda x : x
+ return [_("IL"), _("ST"), _("LD"), _("FBD")]
+TRANSITION_LANGUAGES_DICT = dict([(_(language), language) for language in GetTransitionLanguages()])
+
+def GetPouTypes():
+ _ = lambda x : x
+ return [_("function"), _("functionBlock"), _("program")]
+POU_TYPES_DICT = dict([(_(pou_type), pou_type) for pou_type in GetPouTypes()])
+
+def GetPouLanguages():
+ _ = lambda x : x
+ return [_("IL"), _("ST"), _("LD"), _("FBD"), _("SFC")]
+POU_LANGUAGES_DICT = dict([(_(language), language) for language in GetPouLanguages()])
+
class PouDialog(wx.Dialog):
if wx.VERSION < (2, 6, 0):
def Bind(self, event, function, id = None):
@@ -3118,11 +3195,11 @@
parent.AddGrowableRow(0)
def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText1, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.PouName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.PouType, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText3, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText3, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
def _init_coll_MainSizer_Growables(self, parent):
@@ -3130,7 +3207,7 @@
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=3, vgap=15)
+ self.MainSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
@@ -3143,20 +3220,20 @@
wx.Dialog.__init__(self, id=ID_POUDIALOG,
name='PouDialog', parent=prnt, pos=wx.Point(376, 223),
size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE,
- title='Create a new POU')
+ title=_('Create a new POU'))
self.SetClientSize(wx.Size(300, 200))
self.staticText1 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT1,
- label='POU Name:', name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
+ label=_('POU Name:'), name='staticText1', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.PouName = wx.TextCtrl(id=ID_POUDIALOGPOUNAME,
name='POUName', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText2 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT2,
- label='POU Type:', name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
+ label=_('POU Type:'), name='staticText2', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.PouType = wx.ComboBox(id=ID_POUDIALOGPOUTYPE,
name='POUType', parent=self, pos=wx.Point(0, 0),
@@ -3164,8 +3241,8 @@
self.Bind(wx.EVT_COMBOBOX, self.OnTypeChanged, id=ID_POUDIALOGPOUTYPE)
self.staticText3 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT3,
- label='Language:', name='staticText3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
+ label=_('Language:'), name='staticText3', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.Language = wx.ComboBox(id=ID_POUDIALOGLANGUAGE,
name='Language', parent=self, pos=wx.Point(0, 0),
@@ -3179,10 +3256,10 @@
def __init__(self, parent, pou_type = None):
self._init_ctrls(parent)
- for option in ["function", "functionBlock", "program"]:
- self.PouType.Append(option)
+ for option in GetPouTypes():
+ self.PouType.Append(_(option))
if pou_type is not None:
- self.PouType.SetStringSelection(pou_type)
+ self.PouType.SetStringSelection(_(pou_type))
self.RefreshLanguage()
self.PouNames = []
@@ -3192,37 +3269,37 @@
error = []
pou_name = self.PouName.GetValue()
if pou_name == "":
- error.append("POU Name")
- if self.PouType.GetStringSelection() == "":
- error.append("POU Type")
- if self.Language.GetStringSelection() == "":
- error.append("Language")
+ error.append(_("POU Name"))
+ if self.PouType.GetSelection() == -1:
+ error.append(_("POU Type"))
+ if self.Language.GetSelection() == -1:
+ error.append(_("Language"))
if len(error) > 0:
text = ""
for i, item in enumerate(error):
if i == 0:
text += item
elif i == len(error) - 1:
- text += " and %s"%item
+ text += _(" and %s")%item
else:
- text += ", %s"%item
- message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
+ text += _(", %s")%item
+ message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(pou_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%pou_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%pou_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif pou_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%pou_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%pou_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif pou_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, "\"%s\" pou already exists!"%pou_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%pou_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif pou_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%pou_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION)
+ message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%pou_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
result = message.ShowModal()
message.Destroy()
if result == wx.ID_YES:
@@ -3231,13 +3308,13 @@
self.EndModal(wx.ID_OK)
def RefreshLanguage(self):
- selection = self.Language.GetStringSelection()
+ selection = POU_LANGUAGES_DICT.get(self.Language.GetStringSelection(), "")
self.Language.Clear()
- for option in ["IL","ST","LD","FBD","SFC"]:
- if option != "SFC" or self.PouType.GetStringSelection() != "function":
- self.Language.Append(option)
- if self.Language.FindString(selection) != wx.NOT_FOUND:
- self.Language.SetStringSelection(selection)
+ for language in GetPouLanguages():
+ if language != "SFC" or POU_TYPES_DICT[self.PouType.GetStringSelection()] != "function":
+ self.Language.Append(language)
+ if self.Language.FindString(_(selection)) != wx.NOT_FOUND:
+ self.Language.SetStringSelection(_(selection))
def OnTypeChanged(self, event):
self.RefreshLanguage()
@@ -3254,15 +3331,15 @@
if item == "pouName":
self.PouName.SetValue(value)
elif item == "pouType":
- self.PouType.SetStringSelection(value)
+ self.PouType.SetStringSelection(_(value))
elif item == "language":
- self.Language.SetStringSelection(value)
+ self.Language.SetStringSelection(_(POU_LANGUAGES_DICT))
def GetValues(self):
values = {}
values["pouName"] = self.PouName.GetValue()
- values["pouType"] = self.PouType.GetStringSelection()
- values["language"] = self.Language.GetStringSelection()
+ values["pouType"] = POU_TYPES_DICT[self.PouType.GetStringSelection()]
+ values["language"] = POU_LANGUAGES_DICT[self.Language.GetStringSelection()]
return values
@@ -3275,6 +3352,11 @@
ID_POUTRANSITIONDIALOGSTATICTEXT2,
] = [wx.NewId() for _init_ctrls in range(5)]
+def GetTransitionLanguages():
+ _ = lambda x : x
+ return [_("IL"), _("ST"), _("LD"), _("FBD")]
+TRANSITION_LANGUAGES_DICT = dict([(_(language), language) for language in GetTransitionLanguages()])
+
class PouTransitionDialog(wx.Dialog):
if wx.VERSION < (2, 6, 0):
def Bind(self, event, function, id = None):
@@ -3292,9 +3374,9 @@
parent.AddGrowableRow(0)
def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText1, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.TransitionName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
def _init_coll_MainSizer_Growables(self, parent):
@@ -3302,7 +3384,7 @@
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15)
+ self.MainSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
@@ -3315,20 +3397,20 @@
wx.Dialog.__init__(self, id=ID_POUTRANSITIONDIALOG,
name='PouTransitionDialog', parent=prnt, pos=wx.Point(376, 223),
size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE,
- title='Create a new transition')
+ title=_('Create a new transition'))
self.SetClientSize(wx.Size(350, 160))
self.staticText1 = wx.StaticText(id=ID_POUTRANSITIONDIALOGSTATICTEXT1,
- label='Transition Name:', name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(120, 17), style=0)
+ label=_('Transition Name:'), name='staticText1', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.TransitionName = wx.TextCtrl(id=ID_POUTRANSITIONDIALOGTRANSITIONNAME,
name='TransitionName', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText2 = wx.StaticText(id=ID_POUTRANSITIONDIALOGSTATICTEXT2,
- label='Language:', name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(120, 17), style=0)
+ label=_('Language:'), name='staticText2', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.Language = wx.ComboBox(id=ID_POUTRANSITIONDIALOGLANGUAGE,
name='Language', parent=self, pos=wx.Point(0, 0),
@@ -3342,8 +3424,8 @@
def __init__(self, parent):
self._init_ctrls(parent)
- for option in ["IL","ST","LD","FBD"]:
- self.Language.Append(option)
+ for language in GetTransitionLanguages():
+ self.Language.Append(_(language))
self.PouNames = []
self.PouElementNames = []
@@ -3352,35 +3434,35 @@
error = []
transition_name = self.TransitionName.GetValue()
if self.TransitionName.GetValue() == "":
- error.append("Transition Name")
- if self.Language.GetStringSelection() == "":
- error.append("Language")
+ error.append(_("Transition Name"))
+ if self.Language.GetSelection() == -1:
+ error.append(_("Language"))
if len(error) > 0:
text = ""
for i, item in enumerate(error):
if i == 0:
text += item
elif i == len(error) - 1:
- text += " and %s"%item
+ text += _(" and %s")%item
else:
- text += ", %s"%item
- message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
+ text += _(", %s")%item
+ message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(transition_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%transition_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif transition_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%transition_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif transition_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, "A pou with \"%s\" for name exists!"%transition_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif transition_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, "\"%s\" element for this pou already exists!"%transition_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
@@ -3397,12 +3479,12 @@
if item == "transitionName":
self.TransitionName.SetValue(value)
elif item == "language":
- self.Language.SetStringSelection(value)
+ self.Language.SetSelection(_(value))
def GetValues(self):
values = {}
values["transitionName"] = self.TransitionName.GetValue()
- values["language"] = self.Language.GetStringSelection()
+ values["language"] = TRANSITION_LANGUAGES_DICT[self.Language.GetStringSelection()]
return values
#-------------------------------------------------------------------------------
@@ -3414,6 +3496,11 @@
ID_POUACTIONDIALOGSTATICTEXT2,
] = [wx.NewId() for _init_ctrls in range(5)]
+def GetActionLanguages():
+ _ = lambda x : x
+ return [_("IL"), _("ST"), _("LD"), _("FBD")]
+ACTION_LANGUAGES_DICT = dict([(_(language), language) for language in GetActionLanguages()])
+
class PouActionDialog(wx.Dialog):
if wx.VERSION < (2, 6, 0):
def Bind(self, event, function, id = None):
@@ -3431,9 +3518,9 @@
parent.AddGrowableRow(0)
def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText1, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.ActionName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
def _init_coll_MainSizer_Growables(self, parent):
@@ -3441,7 +3528,7 @@
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15)
+ self.MainSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
@@ -3454,20 +3541,20 @@
wx.Dialog.__init__(self, id=ID_POUACTIONDIALOG,
name='PouActionDialog', parent=prnt, pos=wx.Point(376, 223),
size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title='Create a new action')
+ title=_('Create a new action'))
self.SetClientSize(wx.Size(320, 160))
self.staticText1 = wx.StaticText(id=ID_POUACTIONDIALOGSTATICTEXT1,
- label='Action Name:', name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
+ label=_('Action Name:'), name='staticText1', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ActionName = wx.TextCtrl(id=ID_POUACTIONDIALOGACTIONNAME,
name='ActionName', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
self.staticText2 = wx.StaticText(id=ID_POUACTIONDIALOGSTATICTEXT2,
- label='Language:', name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
+ label=_('Language:'), name='staticText2', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.Language = wx.ComboBox(id=ID_POUACTIONDIALOGLANGUAGE,
name='Language', parent=self, pos=wx.Point(0, 0),
@@ -3481,8 +3568,8 @@
def __init__(self, parent):
self._init_ctrls(parent)
- for option in ["IL","ST","LD","FBD"]:
- self.Language.Append(option)
+ for option in GetActionLanguages():
+ self.Language.Append(_(option))
self.PouNames = []
self.PouElementNames = []
@@ -3491,35 +3578,35 @@
error = []
action_name = self.ActionName.GetValue()
if action_name == "":
- error.append("Action Name")
- if self.Language.GetStringSelection() == "":
- error.append("Language")
+ error.append(_("Action Name"))
+ if self.Language.GetSelection() == -1:
+ error.append(_("Language"))
if len(error) > 0:
text = ""
for i, item in enumerate(error):
if i == 0:
text += item
elif i == len(error) - 1:
- text += " and %s"%item
+ text += _(" and %s")%item
else:
- text += ", %s"%item
- message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
+ text += _(", %s")%item
+ message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(action_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%action_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif action_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%action_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif action_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, "A pou with \"%s\" for name exists!"%action_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif action_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, "\"%s\" element for this pou already exists!"%action_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
@@ -3536,12 +3623,12 @@
if item == "actionName":
self.ActionName.SetValue(value)
elif item == "language":
- self.Language.SetStringSelection(value)
+ self.Language.SetStringSelection(_(value))
def GetValues(self):
values = {}
values["actionName"] = self.ActionName.GetValue()
- values["language"] = self.Language.GetStringSelection()
+ values["language"] = ACTION_LANGUAGES_DICT[self.Language.GetStringSelection()]
return values
#-------------------------------------------------------------------------------
@@ -3557,7 +3644,7 @@
else:
event(self, function)
- def __init__(self, parent, message, caption = "Please enter configuration name", defaultValue = "",
+ def __init__(self, parent, message, caption = _("Please enter configuration name"), defaultValue = "",
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
@@ -3574,23 +3661,23 @@
def OnOK(self, event):
config_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if config_name == "":
- message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(config_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%config_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif config_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%config_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif config_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%config_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif config_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%config_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION)
+ message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%config_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
result = message.ShowModal()
message.Destroy()
if result == wx.ID_YES:
@@ -3620,7 +3707,7 @@
else:
event(self, function)
- def __init__(self, parent, message, caption = "Please enter resource name", defaultValue = "",
+ def __init__(self, parent, message, caption = _("Please enter resource name"), defaultValue = "",
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
@@ -3637,23 +3724,23 @@
def OnOK(self, event):
resource_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if resource_name == "":
- message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif not TestIdentifier(resource_name):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%resource_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif resource_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%resource_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif resource_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%resource_name, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
elif resource_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%resource_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION)
+ message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%resource_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
result = message.ShowModal()
message.Destroy()
if result == wx.ID_YES:
@@ -3755,6 +3842,25 @@
# Variables Editor Panel
#-------------------------------------------------------------------------------
+def GetVariableTableColnames(location):
+ _ = lambda x : x
+ if location:
+ return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Retain"), _("Constant")]
+ return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Retain"), _("Constant")]
+
+def GetAlternativeOptions():
+ _ = lambda x : x
+ return [_("Yes"), _("No")]
+ALTERNATIVE_OPTIONS_DICT = dict([(_(option), option) for option in GetAlternativeOptions()])
+
+def GetFilterChoiceTransfer():
+ _ = lambda x : x
+ return {_("All"): _("All"), _("Interface"): _("Interface"),
+ _(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"),
+ _(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"),
+ _(" Temp"): _("Temp"), _("Global"): _("Global")}#, _("Access") : _("Access")}
+VARIABLE_CLASSES_DICT = dict([(_(_class), _class) for _class in GetFilterChoiceTransfer().itervalues()])
+
class VariableTable(wx.grid.PyGridTableBase):
"""
@@ -3780,25 +3886,34 @@
def GetNumberRows(self):
return len(self.data)
- def GetColLabelValue(self, col):
+ def GetColLabelValue(self, col, translate=True):
if col < len(self.colnames):
+ if translate:
+ return _(self.colnames[col])
return self.colnames[col]
- def GetRowLabelValues(self, row):
+ def GetRowLabelValues(self, row, translate=True):
return row
def GetValue(self, row, col):
if row < self.GetNumberRows():
if col == 0:
return self.data[row]["Number"]
- name = str(self.data[row].get(self.GetColLabelValue(col), ""))
- return name
+ colname = self.GetColLabelValue(col, False)
+ value = str(self.data[row].get(colname, ""))
+ if colname in ["Class", "Retain", "Constant"]:
+ return _(value)
+ return value
def SetValue(self, row, col, value):
if col < len(self.colnames):
- colname = self.GetColLabelValue(col)
+ colname = self.GetColLabelValue(col, False)
if colname == "Name":
self.old_value = self.data[row][colname]
+ elif colname == "Class":
+ value = VARIABLE_CLASSES_DICT[value]
+ elif colname in ["Retain", "Constant"]:
+ value = ALTERNATIVE_OPTIONS_DICT[value]
self.data[row][colname] = value
def GetValueByName(self, row, colname):
@@ -3854,13 +3969,11 @@
Otherwise default to the default renderer.
"""
- typelist = None
- accesslist = None
for row in range(self.GetNumberRows()):
for col in range(self.GetNumberCols()):
editor = None
renderer = None
- colname = self.GetColLabelValue(col)
+ colname = self.GetColLabelValue(col, False)
if col != 0 and self.GetValueByName(row, "Edit"):
grid.SetReadOnly(row, col, False)
if colname == "Name":
@@ -3888,10 +4001,10 @@
excluded.extend(["Input","Output","InOut"])
if self.Parent.IsFunctionBlockType(self.data[row]["Type"]):
excluded.extend(["Local","Temp"])
- editor.SetParameters(",".join([choice for choice in self.Parent.ClassList if choice not in excluded]))
+ editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
elif colname in ["Retain", "Constant"]:
editor = wx.grid.GridCellChoiceEditor()
- editor.SetParameters(self.Parent.OptionList)
+ editor.SetParameters(",".join(map(_, self.Parent.OptionList)))
elif colname == "Type":
editor = wx.grid.GridCellTextEditor()
else:
@@ -3950,21 +4063,21 @@
col = self.ParentWindow.VariablesGrid.XToCol(x)
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize())
if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
- if self.ParentWindow.Table.GetColLabelValue(col) != "Location":
+ if self.ParentWindow.Table.GetColLabelValue(col, False) != "Location":
return
message = None
if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
- message = "Can't affect a location to a function block instance"
+ message = _("Can't affect a location to a function block instance")
elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]:
- message = "Can affect a location only to local or global variables"
+ message = _("Can affect a location only to local or global variables")
else:
try:
values = eval(data)
except:
- message = "Invalid value \"%s\" for location"%data
+ message = _("Invalid value \"%s\" for location")%data
values = None
if not isinstance(values, TupleType):
- message = "Invalid value \"%s\" for location"%data
+ message = _("Invalid value \"%s\" for location")%data
values = None
if values is not None and values[1] == "location":
location = values[0]
@@ -3973,20 +4086,20 @@
message = None
if location.startswith("%"):
if base_type != values[2]:
- message = "Incompatible data types between \"%s\" and \"%s\""%(values[2], variable_type)
+ message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type)
else:
self.ParentWindow.Table.SetValue(row, col, location)
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
self.ParentWindow.SaveValues()
else:
if location[0].isdigit() and base_type != "BOOL":
- message = "Incompatible size of data between \"%s\" and \"BOOL\""%location
+ message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location
elif location[0] not in LOCATIONDATATYPES:
- message = "Unrecognized data size \"%s\""%location[0]
+ message = _("Unrecognized data size \"%s\"")%location[0]
elif base_type not in LOCATIONDATATYPES[location[0]]:
- message = "Incompatible size of data between \"%s\" and \"%s\""%(location, variable_type)
+ message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
else:
- dialog = wx.SingleChoiceDialog(self.ParentWindow, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+ dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
if dialog.ShowModal() == wx.ID_OK:
selected = dialog.GetSelection()
if selected == 0:
@@ -4003,7 +4116,7 @@
wx.CallAfter(self.ShowMessage, message)
def ShowMessage(self, message):
- message = wx.MessageDialog(self.ParentWindow, message, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
@@ -4111,8 +4224,8 @@
self.ControlPanel.SetScrollRate(0, 10)
self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1,
- label='Return Type:', name='staticText1', parent=self.ControlPanel,
- pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
+ label=_('Return Type:'), name='staticText1', parent=self.ControlPanel,
+ pos=wx.Point(0, 0), size=wx.Size(145, 17), style=0)
self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE,
name='ReturnType', parent=self.ControlPanel, pos=wx.Point(0, 0),
@@ -4120,22 +4233,22 @@
self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE)
self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2,
- label='Class Filter:', name='staticText2', parent=self.ControlPanel,
- pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
+ label=_('Class Filter:'), name='staticText2', parent=self.ControlPanel,
+ pos=wx.Point(0, 0), size=wx.Size(145, 17), style=0)
self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER,
name='ClassFilter', parent=self.ControlPanel, pos=wx.Point(0, 0),
size=wx.Size(145, 28), style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER)
- self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label='Add',
+ self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label=_('Add'),
name='AddButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(72, 32), style=0)
+ size=wx.DefaultSize, style=0)
self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_VARIABLEEDITORPANELADDBUTTON)
- self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label='Delete',
+ self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label=_('Delete'),
name='DeleteButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(72, 32), style=0)
+ size=wx.DefaultSize, style=0)
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_VARIABLEEDITORPANELDELETEBUTTON)
self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^',
@@ -4158,10 +4271,7 @@
self.Filter = "All"
self.FilterChoices = []
- self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface",
- " Input" : "Input", " Output" : "Output", " InOut" : "InOut",
- " External" : "External", "Variables" : "Variables", " Local" : "Local",
- " Temp" : "Temp", "Global" : "Global", "Access" : "Access"}
+ self.FilterChoiceTransfer = GetFilterChoiceTransfer()
if element_type in ["config", "resource"]:
self.DefaultTypes = {"All" : "Global"}
@@ -4170,27 +4280,30 @@
self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True}
if element_type in ["config", "resource"] or element_type in ["program", "transition", "action"]:
- self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"])
+ self.Table = VariableTable(self, [], GetVariableTableColnames(True))
if element_type not in ["config", "resource"]:
- self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp","Global","Access"]
+ self.FilterChoices = ["All", "Interface", " Input", " Output", " InOut", " External", "Variables", " Local", " Temp"]#,"Access"]
else:
- self.FilterChoices = ["All","Global","Access"]
+ self.FilterChoices = ["All", "Global"]#,"Access"]
self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70]
self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER]
else:
- self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Initial Value", "Retain", "Constant"])
- self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp"]
+ self.Table = VariableTable(self, [], GetVariableTableColnames(False))
+ if element_type == "function":
+ self.FilterChoices = ["All", "Interface", " Input", " Output", " InOut", "Variables", " Local", " Temp"]
+ else:
+ self.FilterChoices = ["All", "Interface", " Input", " Output", " InOut", " External", "Variables", " Local", " Temp"]
self.ColSizes = [40, 120, 70, 80, 120, 60, 70]
self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER]
for choice in self.FilterChoices:
- self.ClassFilter.Append(choice)
+ self.ClassFilter.Append(_(choice))
reverse_transfer = {}
for filter, choice in self.FilterChoiceTransfer.items():
reverse_transfer[choice] = filter
- self.ClassFilter.SetStringSelection(reverse_transfer[self.Filter])
+ self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter]))
self.RefreshTypeList()
- self.OptionList = "Yes,No"
+ self.OptionList = GetAlternativeOptions()
if element_type == "function":
for base_type in self.Controler.GetBaseTypes():
@@ -4207,7 +4320,8 @@
attr = wx.grid.GridCellAttr()
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
self.VariablesGrid.SetColAttr(col, attr)
- self.VariablesGrid.SetColSize(col, self.ColSizes[col])
+ self.VariablesGrid.SetColMinimalWidth(col, self.ColSizes[col])
+ self.VariablesGrid.AutoSizeColumn(col, False)
def SetTagName(self, tagname):
self.TagName = tagname
@@ -4327,22 +4441,22 @@
value = self.Table.GetValue(row, col)
if colname == "Name" and value != "":
if not TestIdentifier(value):
- message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%value, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
elif value.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%value, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
elif value.upper() in self.PouNames:
- message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%value, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]:
- message = wx.MessageDialog(self, "A variable with \"%s\" as name exists in this pou!"%value, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Veto()
@@ -4374,13 +4488,13 @@
new_id = wx.NewId()
AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)
- type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu)
+ type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu)
datatype_menu = wx.Menu(title='')
for datatype in self.Controler.GetDataTypes(basetypes = False, debug = self.ParentWindow.Debug):
new_id = wx.NewId()
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
- type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu)
+ type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)
functionblock_menu = wx.Menu(title='')
bodytype = self.Controler.GetEditedElementBodyType(self.TagName, self.ParentWindow.Debug)
pouname, poutype = self.Controler.GetEditedElementType(self.TagName, self.ParentWindow.Debug)
@@ -4389,7 +4503,7 @@
new_id = wx.NewId()
AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type)
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id)
- type_menu.AppendMenu(wx.NewId(), "Function Block Types", functionblock_menu)
+ type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu)
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))
self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())
event.Veto()
@@ -4495,6 +4609,10 @@
# Debug Variables Panel
#-------------------------------------------------------------------------------
+def GetDebugVariablesTableColnames():
+ _ = lambda x : x
+ return [_("Variable"), _("Value")]
+
class VariableTableItem(DebugDataConsumer):
def __init__(self, parent, variable, value):
@@ -4545,21 +4663,23 @@
def GetNumberRows(self):
return len(self.data)
- def GetColLabelValue(self, col):
+ def GetColLabelValue(self, col, translate=True):
if col < len(self.colnames):
+ if translate:
+ return _(self.colnames[col])
return self.colnames[col]
- def GetRowLabelValues(self, row):
+ def GetRowLabelValues(self, row, translate=True):
return row
def GetValue(self, row, col):
if row < self.GetNumberRows():
- return self.GetValueByName(row, self.GetColLabelValue(col))
+ return self.GetValueByName(row, self.GetColLabelValue(col, False))
return ""
def SetValue(self, row, col, value):
if col < len(self.colnames):
- self.SetValueByName(row, self.GetColLabelValue(col), value)
+ self.SetValueByName(row, self.GetColLabelValue(col, False), value)
def GetValueByName(self, row, colname):
if row < self.GetNumberRows():
@@ -4661,10 +4781,10 @@
try:
values = eval(data)
except:
- message = "Invalid value \"%s\" for debug variable"%data
+ message = _("Invalid value \"%s\" for debug variable")%data
values = None
if not isinstance(values, TupleType):
- message = "Invalid value \"%s\" for debug variable"%data
+ message = _("Invalid value \"%s\" for debug variable")%data
values = None
if values is not None and values[1] == "debug":
self.ParentWindow.InsertValue(row, values[0])
@@ -4672,7 +4792,7 @@
wx.CallAfter(self.ShowMessage, message)
def ShowMessage(self, message):
- message = wx.MessageDialog(self.ParentWindow, message, "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
@@ -4739,7 +4859,7 @@
size=wx.Size(32, 32), style=0)
self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DEBUGVARIABLEPANELDOWNBUTTON)
- self.DeleteButton = wx.Button(id=ID_DEBUGVARIABLEPANELDELETEBUTTON, label='Delete',
+ self.DeleteButton = wx.Button(id=ID_DEBUGVARIABLEPANELDELETEBUTTON, label=_('Delete'),
name='DeleteButton', parent=self, pos=wx.Point(0, 0),
size=wx.Size(72, 32), style=0)
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DEBUGVARIABLEPANELDELETEBUTTON)
@@ -4752,7 +4872,7 @@
self.Controler = controler
self.HasNewData = False
- self.Table = DebugVariableTable(self, [], ["Variable", "Value"])
+ self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames())
self.VariablesGrid.SetTable(self.Table)
self.VariablesGrid.SetRowLabelSize(0)
@@ -4877,7 +4997,7 @@
block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:])
text_width, text_height = dc.GetTextExtent(block_name)
dc.DrawText(block_name, margin_left, margin_top - text_height - self.TextMargin)
- dc.DrawText("Page: %d" % page, margin_left, margin_top + area_height + self.TextMargin)
+ dc.DrawText(_("Page: %d") % page, margin_left, margin_top + area_height + self.TextMargin)
# Calculate the position on the DC for centering the graphic
posX = area_width * ((page - 1) % self.PageGrid[0])
@@ -4907,12 +5027,12 @@
def Display_Exception_Dialog(e_type,e_value,e_tb):
trcbck_lst = []
for i,line in enumerate(traceback.extract_tb(e_tb)):
- trcbck = " " + str(i+1) + ". "
+ trcbck = " " + str(i+1) + _(". ")
if line[0].find(os.getcwd()) == -1:
- trcbck += "file : " + str(line[0]) + ", "
- else:
- trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", "
- trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2])
+ trcbck += _("file : ") + str(line[0]) + _(", ")
+ else:
+ trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(", ")
+ trcbck += _("line : ") + str(line[1]) + _(", ") + _("function : ") + str(line[2])
trcbck_lst.append(trcbck)
# Allow clicking....
@@ -4921,7 +5041,7 @@
cap.ReleaseMouse()
dlg = wx.SingleChoiceDialog(None,
- """
+ _("""
An error happens.
Click on OK for saving an error report.
@@ -4932,9 +5052,9 @@
Error:
-""" +
- str(e_type) + " : " + str(e_value),
- "Error",
+""") +
+ str(e_type) + _(" : ") + str(e_value),
+ _("Error"),
trcbck_lst)
try:
res = (dlg.ShowModal() == wx.ID_OK)
@@ -4944,7 +5064,7 @@
return res
def Display_Error_Dialog(e_value):
- message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR)
+ message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
@@ -5002,30 +5122,6 @@
sys.excepthook = handle_exception
if __name__ == '__main__':
- def usage():
- print "\nUsage of PLCOpenEditor.py :"
- print "\n %s [Filepath]\n"%sys.argv[0]
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
- except getopt.GetoptError:
- # print help information and exit:
- usage()
- sys.exit(2)
-
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
-
- fileOpen = None
- if len(args) > 1:
- usage()
- sys.exit()
- elif len(args) == 1:
- fileOpen = args[0]
-
- app = wx.PySimpleApp()
wx.InitAllImageHandlers()
# Install a exception handle for bug reports