--- a/PLCOpenEditor.py Wed Sep 02 18:21:46 2009 +0200
+++ b/PLCOpenEditor.py Tue Sep 15 14:59:33 2009 +0200
@@ -111,7 +111,8 @@
from plcopen.structures import LOCATIONDATATYPES
# Define PLCOpenEditor controls id
-[ID_PLCOPENEDITOR, ID_PLCOPENEDITORTREENOTEBOOK,
+[ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK,
+ ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK,
ID_PLCOPENEDITORTYPESTREE, ID_PLCOPENEDITORINSTANCESTREE,
ID_PLCOPENEDITORMAINSPLITTER, ID_PLCOPENEDITORSECONDSPLITTER,
ID_PLCOPENEDITORTHIRDSPLITTER, ID_PLCOPENEDITORLIBRARYPANEL,
@@ -120,7 +121,7 @@
ID_PLCOPENEDITORTOOLBAR, ID_PLCOPENEDITORDEFAULTTOOLBAR,
ID_PLCOPENEDITORSFCTOOLBAR, ID_PLCOPENEDITORFBDTOOLBAR,
ID_PLCOPENEDITORLDTOOLBAR,
-] = [wx.NewId() for _init_ctrls in range(17)]
+] = [wx.NewId() for _init_ctrls in range(19)]
# Define PLCOpenEditor FileMenu extra items id
[ID_PLCOPENEDITORFILEMENUGENERATE,
@@ -273,7 +274,7 @@
def GetDeleteElementFunction(remove_function, parent_type=None, check_function=None):
def DeleteElementFunction(self, selected):
name = self.TypesTree.GetItemText(selected)
- if check_function is None or not check_function(self.Controler, name, self.Debug):
+ if check_function is None or not check_function(self.Controler, name):
if parent_type is not None:
parent_name = GetParentName(self.TypesTree, selected, parent_type)
remove_function(self.Controler, parent_name, name)
@@ -285,12 +286,12 @@
#-------------------------------------------------------------------------------
-# PLCOpenEditor Main Class
+# IDEFrame Base Class
#-------------------------------------------------------------------------------
UNEDITABLE_NAMES_DICT = dict([(_(name), name) for name in UNEDITABLE_NAMES])
-class PLCOpenEditor(wx.Frame):
+class IDEFrame(wx.Frame):
# Compatibility function for wx versions < 2.6
if wx.VERSION < (2, 6, 0):
@@ -302,71 +303,12 @@
def _init_coll_MenuBar_Menus(self, parent):
parent.Append(menu=self.FileMenu, title=_(u'File'))
- if not self.Debug:
- parent.Append(menu=self.EditMenu, title=_(u'Edit'))
+ 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'))
- AppendMenu(parent, help='', id=wx.ID_OPEN,
- 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'))
- if self.ModeSolo:
- AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
- 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'))
- if self.ModeSolo:
- AppendMenu(parent, help='', id=wx.ID_SAVEAS,
- 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'))
- parent.AppendSeparator()
- AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP,
- kind=wx.ITEM_NORMAL, text=_(u'Page Setup'))
- AppendMenu(parent, help='', id=wx.ID_PREVIEW,
- kind=wx.ITEM_NORMAL, text=_(u'Preview'))
- AppendMenu(parent, help='', id=wx.ID_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'))
- parent.AppendSeparator()
- if self.ModeSolo:
- AppendMenu(parent, help='', id=wx.ID_EXIT,
- 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'))
-
- if self.ModeSolo:
- self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
- self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
- self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
- if self.ModeSolo:
- self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
- if not self.Debug:
- self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
- if self.ModeSolo:
- self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS)
- self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu,
- id=ID_PLCOPENEDITORFILEMENUGENERATE)
- self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
- self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW)
- self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
- if not self.Debug:
- self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
- if self.ModeSolo:
- self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
- else:
- self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_STOP)
+ pass
def _init_coll_EditMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_UNDO,
@@ -421,7 +363,7 @@
def _init_coll_DisplayMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_REFRESH,
kind=wx.ITEM_NORMAL, text=_(u'Refresh\tF5'))
- if not self.Debug and not self.ModeSolo:
+ if self.EnableDebug:
AppendMenu(parent, help='', id=wx.ID_CLEAR,
kind=wx.ITEM_NORMAL, text=_(u'Clear Errors\tCTRL+K'))
parent.AppendSeparator()
@@ -433,36 +375,23 @@
kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%")
self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id)
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH)
- if not self.Debug and not self.ModeSolo:
+ if self.EnableDebug:
self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR)
def _init_coll_HelpMenu_Items(self, parent):
- AppendMenu(parent, help='', id=wx.ID_HELP,
- 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'))
- 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)
+ pass
def _init_utils(self):
self.MenuBar = wx.MenuBar()
self.FileMenu = wx.Menu(title='')
- if not self.Debug:
- self.EditMenu = wx.Menu(title='')
+ self.EditMenu = wx.Menu(title='')
self.DisplayMenu = wx.Menu(title='')
self.HelpMenu = wx.Menu(title='')
self._init_coll_MenuBar_Menus(self.MenuBar)
self._init_coll_FileMenu_Items(self.FileMenu)
- if not self.Debug:
- self._init_coll_EditMenu_Items(self.EditMenu)
+ self._init_coll_EditMenu_Items(self.EditMenu)
self._init_coll_DisplayMenu_Items(self.DisplayMenu)
self._init_coll_HelpMenu_Items(self.HelpMenu)
@@ -483,21 +412,55 @@
self.LibraryPanel.SetSizer(self.MainLibrarySizer)
def _init_ctrls(self, prnt):
- wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor',
+ wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name='IDEFrame',
parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600),
- style=wx.DEFAULT_FRAME_STYLE, title=_(u'PLCOpenEditor'))
+ style=wx.DEFAULT_FRAME_STYLE)
self._init_utils()
self.SetClientSize(wx.Size(1000, 600))
self.SetMenuBar(self.MenuBar)
- self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
+
+ self.TabsImageList = wx.ImageList(31, 16)
+ self.TabsImageListIndexes = {}
+
+ #-----------------------------------------------------------------------
+ # Creating main structure
+ #-----------------------------------------------------------------------
if USE_AUI:
self.AUIManager = wx.aui.AuiManager(self)
self.AUIManager.SetDockSizeConstraint(0.5, 0.5)
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.LeftNoteBook = wx.aui.AuiNotebook(self, ID_PLCOPENEDITORLEFTNOTEBOOK,
+ style=wx.aui.AUI_NB_TOP|wx.aui.AUI_NB_TAB_SPLIT|wx.aui.AUI_NB_TAB_MOVE|
+ wx.aui.AUI_NB_SCROLL_BUTTONS|wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)
+ self.AUIManager.AddPane(self.LeftNoteBook,
+ wx.aui.AuiPaneInfo().Caption(_("Project")).Left().Layer(1).
+ BestSize(wx.Size(300, 500)).CloseButton(False))
+
+ self.BottomNoteBook = wx.aui.AuiNotebook(self, ID_PLCOPENEDITORBOTTOMNOTEBOOK,
+ style=wx.aui.AUI_NB_TOP|wx.aui.AUI_NB_TAB_SPLIT|wx.aui.AUI_NB_TAB_MOVE|
+ wx.aui.AUI_NB_SCROLL_BUTTONS|wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)
+ self.AUIManager.AddPane(self.BottomNoteBook,
+ wx.aui.AuiPaneInfo().Bottom().Layer(0).
+ BestSize(wx.Size(800, 200)).CloseButton(False))
+
+ self.RightNoteBook = wx.aui.AuiNotebook(self, ID_PLCOPENEDITORRIGHTNOTEBOOK,
+ style=wx.aui.AUI_NB_TOP|wx.aui.AUI_NB_TAB_SPLIT|wx.aui.AUI_NB_TAB_MOVE|
+ wx.aui.AUI_NB_SCROLL_BUTTONS|wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)
+ self.AUIManager.AddPane(self.RightNoteBook,
+ wx.aui.AuiPaneInfo().Right().Layer(0).
+ BestSize(wx.Size(250, 400)).CloseButton(False))
+
+ self.TabsOpened = wx.aui.AuiNotebook(self, ID_PLCOPENEDITORTABSOPENED,
+ style=wx.aui.AUI_NB_DEFAULT_STYLE|wx.aui.AUI_NB_WINDOWLIST_BUTTON)
+ self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
+ self.OnPouSelectedChanged)
+ self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE,
+ self.OnPageClose)
+ self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_END_DRAG,
+ self.OnPageDragged)
+ self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane())
else:
self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER,
@@ -506,50 +469,86 @@
self.MainSplitter.SetNeedUpdating(True)
self.MainSplitter.SetMinimumPaneSize(1)
- self.TreeNoteBook = wx.Notebook(id=ID_PLCOPENEDITORTREENOTEBOOK,
- name='TreeNoteBook', parent=self.MainSplitter, pos=wx.Point(0,
+ self.LeftNoteBook = wx.Notebook(id=ID_PLCOPENEDITORLEFTNOTEBOOK,
+ name='LeftNoteBook', parent=self.MainSplitter, pos=wx.Point(0,
+ 0), size=wx.Size(0, 0), style=0)
+
+ self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
+ name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
+ size=wx.Size(0, 0), style=wx.SP_3D)
+ self.SecondSplitter.SetMinimumPaneSize(1)
+
+ self.MainSplitter.SplitVertically(self.LeftNoteBook, self.SecondSplitter, 200)
+
+ self.ThirdSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORTHIRDSPLITTER,
+ name='ThirdSplitter', parent=self.SecondSplitter, point=wx.Point(0, 0),
+ size=wx.Size(0, 0), style=wx.SP_3D)
+ self.ThirdSplitter.SetMinimumPaneSize(1)
+
+ self.BottomNoteBook = wx.Notebook(id=ID_PLCOPENEDITORBOTTOMNOTEBOOK,
+ name='BottomNoteBook', parent=self.SecondSplitter, pos=wx.Point(0,
0), size=wx.Size(0, 0), style=0)
- typestreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER
- if not self.Debug:
- typestreestyle |= wx.TR_EDIT_LABELS
+ self.SecondSplitter.SplitHorizontally(self.ThirdSplitter, self.BottomNoteBook, -200)
+
+ self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
+ name='TabsOpened', parent=self.ThirdSplitter, pos=wx.Point(0,
+ 0), size=wx.Size(0, 0), style=0)
+ self.TabsOpened.SetImageList(self.TabsImageList)
+ if wx.VERSION >= (2, 6, 0):
+ self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+ self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
+ else:
+ wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
+ self.OnPouSelectedChanged)
+
+ self.RightNoteBook = wx.Notebook(id=ID_PLCOPENEDITORRIGHTNOTEBOOK,
+ name='RightNoteBook', parent=self.ThirdSplitter, pos=wx.Point(0,
+ 0), size=wx.Size(0, 0), style=0)
+
+ self.ThirdSplitter.SplitVertically(self.TabsOpened, self.RightNoteBook, -250)
+
+ #-----------------------------------------------------------------------
+ # Creating PLCopen Project tree
+ #-----------------------------------------------------------------------
+
self.TypesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORTYPESTREE,
- name='TypesTree', parent=self.TreeNoteBook,
+ name='TypesTree', parent=self.LeftNoteBook,
pos=wx.Point(0, 0), size=wx.Size(0, 0),
- style=typestreestyle)
- if not self.Debug:
- if wx.Platform == '__WXMSW__':
- self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnTypesTreeRightUp,
- id=ID_PLCOPENEDITORTYPESTREE)
- self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypesTreeItemSelected,
- id=ID_PLCOPENEDITORTYPESTREE)
+ style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_EDIT_LABELS)
+ if wx.Platform == '__WXMSW__':
+ self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnTypesTreeRightUp,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypesTreeItemSelected,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ else:
+ if wx.VERSION >= (2, 6, 0):
+ self.TypesTree.Bind(wx.EVT_RIGHT_UP, self.OnTypesTreeRightUp)
+ self.TypesTree.Bind(wx.EVT_LEFT_UP, self.OnTypesTreeLeftUp)
else:
- if wx.VERSION >= (2, 6, 0):
- self.TypesTree.Bind(wx.EVT_RIGHT_UP, self.OnTypesTreeRightUp)
- self.TypesTree.Bind(wx.EVT_LEFT_UP, self.OnTypesTreeLeftUp)
- else:
- wx.EVT_RIGHT_UP(self.TypesTree, self.OnTypesTreeRightUp)
- wx.EVT_LEFT_UP(self.TypesTree, self.OnTypesTreeLeftUp)
- self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnTypesTreeItemChanging,
- id=ID_PLCOPENEDITORTYPESTREE)
- self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTypesTreeBeginDrag,
+ wx.EVT_RIGHT_UP(self.TypesTree, self.OnTypesTreeRightUp)
+ wx.EVT_LEFT_UP(self.TypesTree, self.OnTypesTreeLeftUp)
+ self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnTypesTreeItemChanging,
id=ID_PLCOPENEDITORTYPESTREE)
- self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnTypesTreeItemBeginEdit,
- id=ID_PLCOPENEDITORTYPESTREE)
- self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnTypesTreeItemEndEdit,
- id=ID_PLCOPENEDITORTYPESTREE)
- self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnTypesTreeItemActivated,
- id=ID_PLCOPENEDITORTYPESTREE)
+ self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTypesTreeBeginDrag,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnTypesTreeItemBeginEdit,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnTypesTreeItemEndEdit,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnTypesTreeItemActivated,
+ id=ID_PLCOPENEDITORTYPESTREE)
+ self.LeftNoteBook.AddPage(self.TypesTree, _("Types"))
+
+ #-----------------------------------------------------------------------
+ # Creating PLCopen Project tree
+ #-----------------------------------------------------------------------
self.InstancesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORINSTANCESTREE,
- name='InstancesTree', parent=self.TreeNoteBook,
+ name='InstancesTree', parent=self.LeftNoteBook,
pos=wx.Point(0, 0), size=wx.Size(0, 0),
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER)
-
- self.TabsImageList = wx.ImageList(31, 16)
- self.TabsImageListIndexes = {}
-
- if self.Debug:
+ if self.EnableDebug:
if wx.VERSION >= (2, 6, 0):
self.InstancesTree.Bind(wx.EVT_RIGHT_UP, self.OnInstancesTreeRightUp)
else:
@@ -558,140 +557,66 @@
id=ID_PLCOPENEDITORINSTANCESTREE)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnInstancesTreeItemActivated,
id=ID_PLCOPENEDITORINSTANCESTREE)
-
- self.TreeNoteBook.AddPage(self.InstancesTree, _("Instances"))
- self.TreeNoteBook.AddPage(self.TypesTree, _("Types"))
-
- if USE_AUI:
- self.TabsOpened = wx.aui.AuiNotebook(self)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
- self.OnPouSelectedChanged)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE,
- self.OnPageClose)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_END_DRAG,
- self.OnPageDragged)
- 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))
- else:
- self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
- name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.SP_3D)
- self.SecondSplitter.SetMinimumPaneSize(1)
-
- self.MainSplitter.SplitVertically(self.TreeNoteBook, self.SecondSplitter, 200)
-
- self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
- name='TabsOpened', parent=self.SecondSplitter, pos=wx.Point(0,
- 0), size=wx.Size(0, 0), style=0)
- if wx.VERSION >= (2, 6, 0):
- self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
- self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
- else:
- wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
- self.OnPouSelectedChanged)
-
- self.DebugVariablePanel = DebugVariablePanel(self.SecondSplitter, self.Controler)
-
- self.SecondSplitter.SplitVertically(self.TabsOpened, self.DebugVariablePanel, -250)
- else:
- 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"))
- ToolBar.Realize()
- self.Panes["ToolBar"] = ToolBar
- self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo().
- Name("ToolBar").Caption(_("Toolbar")).
- ToolbarPane().Top().
- LeftDockable(False).RightDockable(False))
- else:
- self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER,
- 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"))
- self.ToolBar.Realize()
+ self.LeftNoteBook.AddPage(self.InstancesTree, _("Instances"))
+
+ #-----------------------------------------------------------------------
+ # Creating Tool Bar
+ #-----------------------------------------------------------------------
+
+ 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"))
+ ToolBar.Realize()
+ self.Panes["ToolBar"] = ToolBar
+ self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo().
+ Name("ToolBar").Caption(_("Toolbar")).
+ ToolbarPane().Top().
+ LeftDockable(False).RightDockable(False))
+ else:
+ self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER,
+ 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"))
+ self.ToolBar.Realize()
self.Bind(wx.EVT_TOOL, self.OnSelectionTool,
id=ID_PLCOPENEDITORTOOLBARSELECTION)
-
- 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.TabsOpened = wx.aui.AuiNotebook(self)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
- self.OnPouSelectedChanged)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE,
- self.OnPageClose)
- self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_END_DRAG,
- self.OnPageDragged)
- self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane().MinSize(wx.Size(0, 0)))
-
- 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))
- else:
- self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER,
- name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.SP_3D)
- self.SecondSplitter.SetMinimumPaneSize(1)
-
- self.MainSplitter.SplitVertically(self.TreeNoteBook, self.SecondSplitter, 200)
-
- self.VariablePanelIndexer = VariablePanelIndexer(self.SecondSplitter, self, self.Controler)
-
- self.ThirdSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORTHIRDSPLITTER,
- name='ThirdSplitter', parent=self.SecondSplitter, point=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.SP_3D)
- self.ThirdSplitter.SetMinimumPaneSize(1)
-
- self.SecondSplitter.SplitHorizontally(self.ThirdSplitter, self.VariablePanelIndexer, -200)
-
- self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
- name='TabsOpened', parent=self.ThirdSplitter, pos=wx.Point(0,
- 0), size=wx.Size(0, 0), style=0)
- self.TabsOpened.SetImageList(self.TabsImageList)
- if wx.VERSION >= (2, 6, 0):
- self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
- self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
- else:
- wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
- self.OnPouSelectedChanged)
-
- self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL,
- name='LibraryPanel', parent=self.ThirdSplitter, pos=wx.Point(0,
- 0), size=wx.Size(0, 0), style=wx.SUNKEN_BORDER)
-
- self.ThirdSplitter.SplitVertically(self.TabsOpened, self.LibraryPanel, -250)
-
- if wx.Platform == '__WXMSW__':
- librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER
- else:
- librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER
- self.LibraryTree = wx.TreeCtrl(id=ID_PLCOPENEDITORLIBRARYTREE,
- name='LibraryTree', parent=self.LibraryPanel,
- pos=wx.Point(0, 0), size=wx.Size(0, 0),
- style=librarytreestyle)
- self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnLibraryTreeItemSelected,
- id=ID_PLCOPENEDITORLIBRARYTREE)
- self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnLibraryTreeBeginDrag,
- id=ID_PLCOPENEDITORLIBRARYTREE)
-
- self.LibraryComment = wx.TextCtrl(id=ID_PLCOPENEDITORLIBRARYCOMMENT,
- name='LibraryComment', parent=self.LibraryPanel,
- pos=wx.Point(0, 0), size=wx.Size(0, 60),
- style=wx.TE_READONLY|wx.TE_MULTILINE)
-
- self._init_sizers()
+
+ self.VariablePanelIndexer = VariablePanelIndexer(self.BottomNoteBook, self)
+ self.BottomNoteBook.AddPage(self.VariablePanelIndexer, _("Variables"))
+
+ self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL,
+ name='LibraryPanel', parent=self.RightNoteBook, pos=wx.Point(0,
+ 0), size=wx.Size(0, 0), style=0)
+ self.RightNoteBook.AddPage(self.LibraryPanel, _("Library"))
+
+ if wx.Platform == '__WXMSW__':
+ librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER
+ else:
+ librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER
+ self.LibraryTree = wx.TreeCtrl(id=ID_PLCOPENEDITORLIBRARYTREE,
+ name='LibraryTree', parent=self.LibraryPanel,
+ pos=wx.Point(0, 0), size=wx.Size(0, 0),
+ style=librarytreestyle)
+ self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnLibraryTreeItemSelected,
+ id=ID_PLCOPENEDITORLIBRARYTREE)
+ self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnLibraryTreeBeginDrag,
+ id=ID_PLCOPENEDITORLIBRARYTREE)
+
+ self.LibraryComment = wx.TextCtrl(id=ID_PLCOPENEDITORLIBRARYCOMMENT,
+ name='LibraryComment', parent=self.LibraryPanel,
+ pos=wx.Point(0, 0), size=wx.Size(0, 60),
+ style=wx.TE_READONLY|wx.TE_MULTILINE)
+
+ self._init_sizers()
+
+ if self.EnableDebug:
+ self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self.Controler)
+ self.RightNoteBook.AddPage(self.DebugVariablePanel, _("Debugger"))
if USE_AUI:
self.AUIManager.Update()
@@ -701,24 +626,12 @@
# @param controler The controler been used by PLCOpenEditor (default: None).
# @param fileOpen The filepath to open if no controler defined (default: None).
# @param debug The filepath to open if no controler defined (default: False).
- def __init__(self, parent, controler = None, fileOpen = None, debug = False):
- # Variable indicating that PLCOpenEditor was opened with a defined controler
- self.ModeSolo = controler == None
- self.Debug = debug
- if self.ModeSolo:
- # If no controler defined, create a new one
- self.Controler = PLCControler()
- # Open the filepath if defined
- if fileOpen is not None:
- self.Controler.OpenXMLFile(fileOpen)
- else:
- self.Controler = controler
+ def __init__(self, parent, enable_debug = False):
+ self.Controler = None
+ self.EnableDebug = enable_debug
self._init_ctrls(parent)
- # Define PLCOpenEditor icon
- self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
-
# Define Tree item icon list
self.TreeImageList = wx.ImageList(16, 16)
self.TreeImageDict = {}
@@ -778,21 +691,31 @@
self.PageSetupData.SetMarginTopLeft(wx.Point(10, 15))
self.PageSetupData.SetMarginBottomRight(wx.Point(10, 20))
- # Refresh elements that need to
- if not self.ModeSolo or fileOpen is not None:
- self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
-
+ self.SetRefreshFunctions()
+
+ self.Maximize()
#-------------------------------------------------------------------------------
# General Functions
#-------------------------------------------------------------------------------
+ def SetRefreshFunctions(self):
+ self.RefreshFunctions = {
+ TITLE : self.RefreshTitle,
+ TOOLBAR : self.RefreshToolBar,
+ FILEMENU : self.RefreshFileMenu,
+ EDITMENU : self.RefreshEditMenu,
+ DISPLAYMENU : self.RefreshDisplayMenu,
+ TYPESTREE : self.RefreshTypesTree,
+ INSTANCESTREE : self.RefreshInstancesTree,
+ LIBRARYTREE : self.RefreshLibraryTree,
+ SCALING : self.RefreshScaling}
+
## Call PLCOpenEditor refresh functions.
# @param elements List of elements to refresh.
def _Refresh(self, *elements):
for element in elements:
- self.RefreshFunctions[element](self)
+ self.RefreshFunctions[element]()
## Callback function when AUINotebook Page closed with CloseButton
# @param event AUINotebook Event.
@@ -801,16 +724,16 @@
selected = event.GetSelection()
if selected >= 0:
# Remove corresponding VariablePanel
- if not self.Debug:
- tagname = self.TabsOpened.GetPage(selected).GetTagName()
- self.VariablePanelIndexer.RemoveVariablePanel(tagname)
+ window = self.TabsOpened.GetPage(selected)
+ if not window.IsDebugging():
+ self.VariablePanelIndexer.RemoveVariablePanel(window.GetTagName())
# Refresh Tab selection
if self.TabsOpened.GetPageCount() > 0:
new_index = min(selected, self.TabsOpened.GetPageCount() - 1)
self.TabsOpened.SetSelection(new_index)
- if not self.Debug:
- tagname = self.TabsOpened.GetPage(new_index).GetTagName()
- self.VariablePanelIndexer.ChangeVariablePanel(tagname)
+ window = self.TabsOpened.GetPage(selected)
+ if not window.IsDebugging():
+ self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName())
# Refresh all window elements that have changed
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
wx.CallAfter(self.RefreshTabCtrlEvent)
@@ -839,22 +762,13 @@
def GetDrawingMode(self):
return self.DrawingMode
- def RefreshTitle(self):
- name = _("PLCOpenEditor")
- if self.Debug:
- name += _(" (Debug)")
- if self.Controler.HasOpenedProject() > 0:
- self.SetTitle("%s - %s"%(name, self.Controler.GetFilename()))
- else:
- self.SetTitle(name)
-
def RefreshScaling(self):
for i in xrange(self.TabsOpened.GetPageCount()):
editor = self.TabsOpened.GetPage(i)
editor.RefreshScaling()
def ShowProperties(self):
- old_values = self.Controler.GetProjectProperties(self.Debug)
+ old_values = self.Controler.GetProjectProperties()
dialog = ProjectDialog(self)
dialog.SetValues(old_values)
if dialog.ShowModal() == wx.ID_OK:
@@ -866,16 +780,6 @@
TYPESTREE, INSTANCESTREE, SCALING)
dialog.Destroy()
- def OnCloseFrame(self, event):
- if not self.ModeSolo and getattr(self, "_onclose", None) is not None:
- self.AUIManager.UnInit()
- self._onclose()
- event.Skip()
- elif self.CheckSaveBeforeClosing():
- event.Skip()
- else:
- event.Veto()
-
#-------------------------------------------------------------------------------
# Notebook Unified Functions
#-------------------------------------------------------------------------------
@@ -980,160 +884,23 @@
#-------------------------------------------------------------------------------
def RefreshFileMenu(self):
- if self.Controler.HasOpenedProject():
- selected = self.TabsOpened.GetSelection()
- if selected >= 0:
- graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer)
- else:
- graphic_viewer = False
- if self.TabsOpened.GetPageCount() > 0:
- self.FileMenu.Enable(wx.ID_CLOSE, True)
- if graphic_viewer:
- self.FileMenu.Enable(wx.ID_PREVIEW, True)
- self.FileMenu.Enable(wx.ID_PRINT, True)
- else:
- self.FileMenu.Enable(wx.ID_PREVIEW, False)
- self.FileMenu.Enable(wx.ID_PRINT, False)
- else:
- self.FileMenu.Enable(wx.ID_CLOSE, False)
- self.FileMenu.Enable(wx.ID_PREVIEW, False)
- self.FileMenu.Enable(wx.ID_PRINT, False)
- self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- if not self.Debug:
- self.FileMenu.Enable(wx.ID_SAVE, True)
- self.FileMenu.Enable(wx.ID_PROPERTIES, True)
- if self.ModeSolo:
- self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
- self.FileMenu.Enable(wx.ID_SAVEAS, True)
- self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True)
- else:
- self.FileMenu.Enable(wx.ID_CLOSE, False)
- self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
- self.FileMenu.Enable(wx.ID_PREVIEW, False)
- self.FileMenu.Enable(wx.ID_PRINT, False)
- if not self.Debug:
- self.FileMenu.Enable(wx.ID_SAVE, False)
- self.FileMenu.Enable(wx.ID_PROPERTIES, False)
- if self.ModeSolo:
- self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
- self.FileMenu.Enable(wx.ID_SAVEAS, False)
- self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)
-
- def OnNewProjectMenu(self, event):
- dialog = ProjectDialog(self)
- if dialog.ShowModal() == wx.ID_OK:
- properties = dialog.GetValues()
- self.Controler.CreateNewProject(properties)
- self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE,
- LIBRARYTREE)
- event.Skip()
-
- def OnOpenProjectMenu(self, event):
- if not self.CheckSaveBeforeClosing():
- return
- filepath = self.Controler.GetFilePath()
- if filepath != "":
- 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)
- if dialog.ShowModal() == wx.ID_OK:
- filepath = dialog.GetPath()
- if os.path.isfile(filepath):
- self.DeleteAllPages()
- self.VariablePanelIndexer.RemoveAllPanels()
- self.Controler.OpenXMLFile(filepath)
- self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
- dialog.Destroy()
- event.Skip()
+ pass
def OnCloseTabMenu(self, event):
selected = self.TabsOpened.GetSelection()
if selected >= 0:
- if not self.Debug:
- tagname = self.TabsOpened.GetPage(selected).GetTagName()
- self.VariablePanelIndexer.RemoveVariablePanel(tagname)
+ window = self.TabsOpened.GetPage(selected)
+ if not window.IsDebugging():
+ self.VariablePanelIndexer.RemoveVariablePanel(window.GetTagName())
self.TabsOpened.DeletePage(selected)
if self.TabsOpened.GetPageCount() > 0:
new_index = min(selected, self.TabsOpened.GetPageCount() - 1)
self.TabsOpened.SetSelection(new_index)
- if not self.Debug:
- tagname = self.TabsOpened.GetPage(new_index).GetTagName()
- self.VariablePanelIndexer.ChangeVariablePanel(tagname)
+ window = self.TabsOpened.GetPage(new_index)
+ if not window.IsDebugging():
+ self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName())
self._Refresh(TOOLBAR, FILEMENU, EDITMENU)
event.Skip()
-
- def OnCloseProjectMenu(self, event):
- if not self.CheckSaveBeforeClosing():
- return
- self.DeleteAllPages()
- self.VariablePanelIndexer.RemoveAllPanels()
- self.TypesTree.DeleteAllItems()
- self.InstancesTree.DeleteAllItems()
- self.Controler.Reset()
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
- event.Skip()
-
- def OnSaveProjectMenu(self, event):
- if not self.ModeSolo and getattr(self, "_onsave", None) != None:
- self._onsave()
- else:
- self.SaveProject()
- event.Skip()
-
- def OnSaveProjectAsMenu(self, event):
- self.SaveProjectAs()
- 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)
- if dialog.ShowModal() == wx.ID_OK:
- filepath = dialog.GetPath()
- message_text = ""
- 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])
- 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
- else:
- 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 = wx.MessageDialog(self, message_text, header, wx.OK|icon)
- message.ShowModal()
- message.Destroy()
- dialog.Destroy()
- event.Skip()
-
- def SaveProject(self):
- result = self.Controler.SaveXMLFile()
- if not result:
- self.SaveProjectAs()
- else:
- self.RefreshTitle()
-
- def SaveProjectAs(self):
- filepath = self.Controler.GetFilePath()
- if filepath != "":
- 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)
- 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)
- else:
- self.ShowErrorMessage(_("\"%s\" is not a valid folder!")%os.path.dirname(filepath))
- self.RefreshTitle()
- dialog.Destroy()
def OnPageSetupMenu(self, event):
dialog = wx.PageSetupDialog(self, self.PageSetupData)
@@ -1146,12 +913,13 @@
def OnPreviewMenu(self, event):
selected = self.TabsOpened.GetSelection()
if selected != -1:
+ window = self.TabsOpened.GetPage(selected)
data = wx.PrintDialogData(self.PrintData)
- properties = self.Controler.GetProjectProperties(self.Debug)
+ properties = self.Controler.GetProjectProperties(window.IsDebugging())
page_size = map(int, properties["pageSize"])
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight())
- printout = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins, True)
- printout2 = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins, True)
+ printout = GraphicPrintout(window, page_size, margins, True)
+ printout2 = GraphicPrintout(window, page_size, margins, True)
preview = wx.PrintPreview(printout, printout2, data)
if preview.Ok():
@@ -1165,13 +933,14 @@
def OnPrintMenu(self, event):
selected = self.TabsOpened.GetSelection()
if selected != -1:
+ window = self.TabsOpened.GetPage(selected)
dialog_data = wx.PrintDialogData(self.PrintData)
dialog_data.SetToPage(1)
- properties = self.Controler.GetProjectProperties(self.Debug)
+ properties = self.Controler.GetProjectProperties(window.IsDebugging())
page_size = map(int, properties["pageSize"])
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight())
printer = wx.Printer(dialog_data)
- printout = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins)
+ printout = GraphicPrintout(window, 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?"))
@@ -1186,53 +955,66 @@
self.Close()
event.Skip()
-
#-------------------------------------------------------------------------------
# Edit Menu Functions
#-------------------------------------------------------------------------------
def RefreshEditMenu(self):
- if not self.Debug:
+ if self.Controler is not None:
+ undo, redo = self.Controler.GetBufferState()
+ self.EditMenu.Enable(wx.ID_UNDO, undo)
+ self.EditMenu.Enable(wx.ID_REDO, redo)
+ self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, True)
self.EditMenu.Check(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO,
- self.Controler.IsProjectBufferEnabled())
- if self.Controler.HasOpenedProject():
- undo, redo = self.Controler.GetBufferState()
- self.EditMenu.Enable(wx.ID_UNDO, undo)
- self.EditMenu.Enable(wx.ID_REDO, redo)
- self.EditMenu.Enable(wx.ID_ADD, True)
- self.EditMenu.Enable(wx.ID_DELETE, True)
- if self.TabsOpened.GetPageCount() > 0:
- self.EditMenu.Enable(wx.ID_CUT, True)
- self.EditMenu.Enable(wx.ID_COPY, True)
- if self.GetCopyBuffer() is not None:
- self.EditMenu.Enable(wx.ID_PASTE, True)
- else:
- self.EditMenu.Enable(wx.ID_PASTE, False)
- self.EditMenu.Enable(wx.ID_SELECTALL, True)
+ self.Controler.IsProjectBufferEnabled())
+ self.EditMenu.Enable(wx.ID_ADD, True)
+ self.EditMenu.Enable(wx.ID_DELETE, True)
+ if self.TabsOpened.GetPageCount() > 0:
+ self.EditMenu.Enable(wx.ID_CUT, True)
+ self.EditMenu.Enable(wx.ID_COPY, True)
+ if self.GetCopyBuffer() is not None:
+ self.EditMenu.Enable(wx.ID_PASTE, True)
else:
- self.EditMenu.Enable(wx.ID_CUT, False)
- self.EditMenu.Enable(wx.ID_COPY, False)
self.EditMenu.Enable(wx.ID_PASTE, False)
- self.EditMenu.Enable(wx.ID_SELECTALL, False)
+ self.EditMenu.Enable(wx.ID_SELECTALL, True)
else:
- self.EditMenu.Enable(wx.ID_UNDO, False)
- self.EditMenu.Enable(wx.ID_REDO, False)
self.EditMenu.Enable(wx.ID_CUT, False)
self.EditMenu.Enable(wx.ID_COPY, False)
self.EditMenu.Enable(wx.ID_PASTE, False)
self.EditMenu.Enable(wx.ID_SELECTALL, False)
- self.EditMenu.Enable(wx.ID_ADD, False)
- self.EditMenu.Enable(wx.ID_DELETE, False)
+ else:
+ self.EditMenu.Enable(wx.ID_UNDO, False)
+ self.EditMenu.Enable(wx.ID_REDO, False)
+ self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, False)
+ self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, False)
+ self.EditMenu.Enable(wx.ID_CUT, False)
+ self.EditMenu.Enable(wx.ID_COPY, False)
+ self.EditMenu.Enable(wx.ID_PASTE, False)
+ self.EditMenu.Enable(wx.ID_SELECTALL, False)
+ self.EditMenu.Enable(wx.ID_ADD, False)
+ self.EditMenu.Enable(wx.ID_DELETE, False)
def CloseTabsWithoutModel(self):
idxs = range(self.TabsOpened.GetPageCount())
idxs.reverse()
for idx in idxs:
- tagname = self.TabsOpened.GetPage(idx).GetTagName()
- if self.Controler.GetEditedElement(tagname, self.Debug) is None:
- self.VariablePanelIndexer.RemoveVariablePanel(tagname)
- self.TabsOpened.DeletePage(idx)
-
+ window = self.TabsOpened.GetPage(idx)
+ if not window.IsDebugging():
+ tagname = window.GetTagName()
+ if self.Controler.GetEditedElement(tagname) is None:
+ self.VariablePanelIndexer.RemoveVariablePanel(tagname)
+ self.TabsOpened.DeletePage(idx)
+
+ def CloseDebugTabs(self):
+ if self.EnableDebug:
+ idxs = range(self.TabsOpened.GetPageCount())
+ idxs.reverse()
+ for idx in idxs:
+ window = self.TabsOpened.GetPage(idx)
+ if window.IsDebugging():
+ self.TabsOpened.DeletePage(idx)
+ self.DebugVariablePanel.ResetGrid()
+
def OnUndoMenu(self, event):
self.Controler.LoadPrevious()
self.CloseTabsWithoutModel()
@@ -1301,7 +1083,7 @@
#-------------------------------------------------------------------------------
def RefreshDisplayMenu(self):
- if self.Controler.HasOpenedProject():
+ if self.Controler is not None:
if self.TabsOpened.GetPageCount() > 0:
self.DisplayMenu.Enable(wx.ID_REFRESH, True)
selected = self.TabsOpened.GetSelection()
@@ -1319,16 +1101,16 @@
else:
self.DisplayMenu.Enable(wx.ID_REFRESH, False)
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
- if not self.Debug and not self.ModeSolo:
+ if self.EnableDebug:
self.DisplayMenu.Enable(wx.ID_CLEAR, True)
else:
self.DisplayMenu.Enable(wx.ID_REFRESH, False)
- if not self.Debug and not self.ModeSolo:
+ if self.EnableDebug:
self.DisplayMenu.Enable(wx.ID_CLEAR, False)
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
def OnRefreshMenu(self, event):
- self.RefreshEditor(not self.Debug)
+ self.RefreshEditor()
event.Skip()
def OnClearErrorsMenu(self, event):
@@ -1373,19 +1155,18 @@
def OnPouSelectedChanged(self, event):
old_selected = self.TabsOpened.GetSelection()
if old_selected >= 0:
- if self.Debug:
- pass
- else:
- self.TabsOpened.GetPage(old_selected).ResetBuffer()
+ window = self.TabsOpened.GetPage(old_selected)
+ if not window.IsDebugging():
+ window.ResetBuffer()
selected = event.GetSelection()
if selected >= 0:
window = self.TabsOpened.GetPage(selected)
- if not self.Debug:
+ if not window.IsDebugging():
self.SelectTypesTreeItem(window.GetTagName())
else:
self.SelectInstancesTreeItem(self.InstancesTree.GetRootItem(), window.GetInstancePath())
window.RefreshView()
- if not self.Debug:
+ if not window.IsDebugging():
self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName())
self._Refresh(FILEMENU, EDITMENU, DISPLAYMENU, TOOLBAR)
event.Skip()
@@ -1395,7 +1176,7 @@
if selected != -1:
window = self.TabsOpened.GetPage(selected)
window.RefreshView()
- if variablepanel:
+ if window.IsDebugging() and variablepanel:
self.RefreshVariablePanel(window.GetTagName())
def RefreshVariablePanel(self, tagname):
@@ -1417,16 +1198,17 @@
def RefreshPageTitles(self):
for idx in xrange(self.TabsOpened.GetPageCount()):
window = self.TabsOpened.GetPage(idx)
+ debug = window.IsDebugging()
words = window.GetTagName().split("::")
if words[0] == "P":
- pou_type = self.Controler.GetEditedElementType(window.GetTagName(), self.Debug)[1].upper()
- pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug)
+ pou_type = self.Controler.GetEditedElementType(window.GetTagName(), debug)[1].upper()
+ pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), debug)
self.SetPageBitmap(idx, self.GenerateBitmap(pou_type, pou_body_type))
elif words[0] == "T":
- pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug)
+ pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), debug)
self.SetPageBitmap(idx, self.GenerateBitmap("TRANSITION", pou_body_type))
elif words[0] == "A":
- pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug)
+ pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), debug)
self.SetPageBitmap(idx, self.GenerateBitmap("ACTION", pou_body_type))
elif words[0] == "C":
self.SetPageBitmap(idx, self.GenerateBitmap("CONFIGURATION"))
@@ -1434,8 +1216,11 @@
self.SetPageBitmap(idx, self.GenerateBitmap("RESOURCE"))
elif words[0] == "D":
self.SetPageBitmap(idx, self.GenerateBitmap("DATATYPE"))
- if self.Debug:
- self.TabsOpened.SetPageText(idx, window.GetInstancePath())
+ if debug:
+ text = window.GetInstancePath()
+ if len(text) > 15:
+ text = "..." + text[-12:]
+ self.TabsOpened.SetPageText(idx, text)
else:
self.TabsOpened.SetPageText(idx, "-".join(words[1:]))
@@ -1457,7 +1242,7 @@
#-------------------------------------------------------------------------------
def RefreshTypesTree(self):
- infos = self.Controler.GetProjectInfos(self.Debug)
+ infos = self.Controler.GetProjectInfos()
root = self.TypesTree.GetRootItem()
if not root.IsOk():
root = self.TypesTree.AddRoot(infos["name"])
@@ -1479,7 +1264,7 @@
self.TypesTree.SetItemBackgroundColour(root, wx.WHITE)
self.TypesTree.SetItemTextColour(root, wx.BLACK)
if infos["type"] == ITEM_POU:
- self.TypesTree.SetItemImage(root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"], self.Debug)])
+ self.TypesTree.SetItemImage(root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])])
else:
self.TypesTree.SetItemImage(root, self.TreeImageDict[infos["type"]])
@@ -1544,7 +1329,7 @@
self.SelectedItem = event.GetItem()
if self.SelectedItem is not None and self.TypesTree.GetPyData(self.SelectedItem) == ITEM_POU:
block_name = self.TypesTree.GetItemText(self.SelectedItem)
- block_type = self.Controler.GetPouType(block_name, self.Debug)
+ block_type = self.Controler.GetPouType(block_name)
if block_type != "program":
data = wx.TextDataObject(str((block_name, block_type, "")))
dragSource = wx.DropSource(self.TypesTree)
@@ -1575,7 +1360,7 @@
if itemtype == ITEM_PROJECT:
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]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]:
message = _("\"%s\" data type already exists!")%new_name
abort = True
if not abort:
@@ -1584,10 +1369,10 @@
self.Controler.ComputeDataTypeName(new_name))
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]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_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)]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]:
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
@@ -1600,9 +1385,9 @@
self.RefreshPageTitles()
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)]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]:
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]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name) if name != old_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)
@@ -1611,9 +1396,9 @@
self.RefreshPageTitles()
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)]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]:
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]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name) if name != old_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)
@@ -1621,15 +1406,15 @@
self.Controler.ComputePouActionName(pou_name, new_name))
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]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_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)]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]:
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)]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]:
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
@@ -1641,15 +1426,15 @@
self.RefreshPageTitles()
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)]:
+ if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]:
message = _("\"%s\" config already exists!")%new_name
abort = True
- elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]:
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)]:
+ elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]:
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
@@ -1754,7 +1539,7 @@
self.AddPage(new_window, "")
self.VariablePanelIndexer.AddVariablePanel(tagname, "resource")
elif elementtype in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
- bodytype = self.Controler.GetEditedElementBodyType(tagname, self.Debug)
+ bodytype = self.Controler.GetEditedElementBodyType(tagname)
if bodytype == "FBD":
new_window = Viewer(self.TabsOpened, tagname, self, self.Controler)
new_window.RefreshScaling(False)
@@ -1773,7 +1558,7 @@
new_window.SetKeywords(ST_KEYWORDS)
self.AddPage(new_window, "")
words = tagname.split("::")
- self.VariablePanelIndexer.AddVariablePanel(tagname, self.Controler.GetPouType(words[1], self.Debug))
+ self.VariablePanelIndexer.AddVariablePanel(tagname, self.Controler.GetPouType(words[1]))
elif elementtype == ITEM_DATATYPE:
new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler)
self.AddPage(new_window, "")
@@ -1800,7 +1585,7 @@
type = self.TypesTree.GetPyData(item)
if type == ITEM_POU:
menu = wx.Menu(title='')
- if self.Controler.GetPouBodyType(name, self.Debug) == "SFC":
+ if self.Controler.GetPouBodyType(name) == "SFC":
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition"))
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id)
@@ -1811,7 +1596,7 @@
new_id = wx.NewId()
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)
+ pou_type = self.Controler.GetPouType(name)
if pou_type in ["function", "functionBlock"]:
change_menu = wx.Menu(title='')
if pou_type == "function":
@@ -1905,7 +1690,7 @@
#-------------------------------------------------------------------------------
def RefreshInstancesTree(self):
- infos = self.Controler.GetProjectTopology(self.Debug)
+ infos = self.Controler.GetProjectTopology(self.EnableDebug)
root = self.InstancesTree.GetRootItem()
if not root.IsOk():
root = self.InstancesTree.AddRoot(infos["name"])
@@ -1939,72 +1724,76 @@
self.InstancesTree.Delete(item)
def OnInstancesTreeBeginDrag(self, event):
- selected_item = event.GetItem()
- selected_infos = self.InstancesTree.GetPyData(selected_item)
- if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
- var_path = self.InstancesTree.GetItemText(selected_item).split(" (")[0]
- parent_item = self.InstancesTree.GetItemParent(selected_item)
- while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
- parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
- var_path = "%s.%s"%(parent_name, var_path)
- parent_item = self.InstancesTree.GetItemParent(parent_item)
- data = wx.TextDataObject(str((var_path, "debug")))
- dragSource = wx.DropSource(self.InstancesTree)
- dragSource.SetData(data)
- dragSource.DoDragDrop()
- event.Skip()
-
- def OnInstancesTreeItemActivated(self, event):
- selected_item = event.GetItem()
- selected_infos = self.InstancesTree.GetPyData(selected_item)
- if selected_item is not None and selected_infos[0] in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM, ITEM_TRANSITION, ITEM_ACTION]:
- instance_path = self.InstancesTree.GetItemText(selected_item).split(" (")[0]
- parent_item = self.InstancesTree.GetItemParent(selected_item)
- while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
- parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
- instance_path = "%s.%s"%(parent_name, instance_path)
- parent_item = self.InstancesTree.GetItemParent(parent_item)
- openedidx = self.IsOpened(instance_path)
- if openedidx is not None:
- old_selected = self.TabsOpened.GetSelection()
- if old_selected != openedidx:
- if old_selected >= 0:
- self.TabsOpened.GetPage(old_selected).ResetBuffer()
- self.TabsOpened.SetSelection(openedidx)
- elif selected_infos[1] is not None:
- bodytype = self.Controler.GetEditedElementBodyType(selected_infos[1], self.Debug)
- if bodytype == "FBD":
- new_window = Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
- new_window.RefreshScaling(False)
- elif bodytype == "LD":
- new_window = LD_Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
- new_window.RefreshScaling(False)
- elif bodytype == "SFC":
- new_window = SFC_Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
- new_window.RefreshScaling(False)
- else:
- new_window = TextViewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
- new_window.SetTextSyntax(bodytype)
- if bodytype == "IL":
- new_window.SetKeywords(IL_KEYWORDS)
- else:
- new_window.SetKeywords(ST_KEYWORDS)
- self.AddPage(new_window, "")
- new_window.SetFocus()
- self.RefreshPageTitles()
- if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
- var_path, var_type = self.InstancesTree.GetItemText(selected_item).split(" (")
- var_type = var_type.split(")")[0]
-
- if self.Controler.IsOfType(var_type, "ANY_NUM", self.Debug) or\
- self.Controler.IsOfType(var_type, "ANY_BIT", self.Debug):
+ if self.Controler.DebugAvailable():
+ selected_item = event.GetItem()
+ selected_infos = self.InstancesTree.GetPyData(selected_item)
+ if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
+ var_path = self.InstancesTree.GetItemText(selected_item).split(" (")[0]
parent_item = self.InstancesTree.GetItemParent(selected_item)
while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
var_path = "%s.%s"%(parent_name, var_path)
parent_item = self.InstancesTree.GetItemParent(parent_item)
+ data = wx.TextDataObject(str((var_path, "debug")))
+ dragSource = wx.DropSource(self.InstancesTree)
+ dragSource.SetData(data)
+ dragSource.DoDragDrop()
+ event.Skip()
+ else:
+ event.Veto()
+
+ def OnInstancesTreeItemActivated(self, event):
+ if self.Controler.DebugAvailable():
+ selected_item = event.GetItem()
+ selected_infos = self.InstancesTree.GetPyData(selected_item)
+ if selected_item is not None and selected_infos[0] in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM, ITEM_TRANSITION, ITEM_ACTION]:
+ instance_path = self.InstancesTree.GetItemText(selected_item).split(" (")[0]
+ parent_item = self.InstancesTree.GetItemParent(selected_item)
+ while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
+ parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
+ instance_path = "%s.%s"%(parent_name, instance_path)
+ parent_item = self.InstancesTree.GetItemParent(parent_item)
+ openedidx = self.IsOpened(instance_path)
+ if openedidx is not None:
+ old_selected = self.TabsOpened.GetSelection()
+ if old_selected != openedidx:
+ if old_selected >= 0:
+ self.TabsOpened.GetPage(old_selected).ResetBuffer()
+ self.TabsOpened.SetSelection(openedidx)
+ elif selected_infos[1] is not None:
+ bodytype = self.Controler.GetEditedElementBodyType(selected_infos[1], True)
+ if bodytype == "FBD":
+ new_window = Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
+ new_window.RefreshScaling(False)
+ elif bodytype == "LD":
+ new_window = LD_Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
+ new_window.RefreshScaling(False)
+ elif bodytype == "SFC":
+ new_window = SFC_Viewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
+ new_window.RefreshScaling(False)
+ else:
+ new_window = TextViewer(self.TabsOpened, selected_infos[1], self, self.Controler, True, instance_path)
+ new_window.SetTextSyntax(bodytype)
+ if bodytype == "IL":
+ new_window.SetKeywords(IL_KEYWORDS)
+ else:
+ new_window.SetKeywords(ST_KEYWORDS)
+ self.AddPage(new_window, "")
+ new_window.SetFocus()
+ self.RefreshPageTitles()
+ if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
+ var_path, var_type = self.InstancesTree.GetItemText(selected_item).split(" (")
+ var_type = var_type.split(")")[0]
- self.OpenGraphicViewer(var_path)
+ if self.Controler.IsOfType(var_type, "ANY_NUM", True) or\
+ self.Controler.IsOfType(var_type, "ANY_BIT", True):
+ parent_item = self.InstancesTree.GetItemParent(selected_item)
+ while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
+ parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
+ var_path = "%s.%s"%(parent_name, var_path)
+ parent_item = self.InstancesTree.GetItemParent(parent_item)
+
+ self.OpenGraphicViewer(var_path)
event.Skip()
def OpenGraphicViewer(self, var_path):
@@ -2014,30 +1803,31 @@
self.RefreshPageTitles()
def OnInstancesTreeRightUp(self, event):
- if wx.Platform == '__WXMSW__':
- selected_item = event.GetItem()
- else:
- selected_item = self.InstancesTree.GetSelection()
- selected_infos = self.InstancesTree.GetPyData(selected_item)
- if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
- var_path, var_type = self.InstancesTree.GetItemText(selected_item).split(" (")
- var_type = var_type.split(")")[0]
-
- if self.Controler.IsOfType(var_type, "ANY_NUM", self.Debug) or\
- self.Controler.IsOfType(var_type, "ANY_BIT", self.Debug):
- parent_item = self.InstancesTree.GetItemParent(selected_item)
- while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
- parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
- var_path = "%s.%s"%(parent_name, var_path)
- parent_item = self.InstancesTree.GetItemParent(parent_item)
+ if self.Controler.DebugAvailable():
+ if wx.Platform == '__WXMSW__':
+ selected_item = event.GetItem()
+ else:
+ selected_item = self.InstancesTree.GetSelection()
+ selected_infos = self.InstancesTree.GetPyData(selected_item)
+ if selected_item is not None and selected_infos[0] in ITEMS_VARIABLE:
+ var_path, var_type = self.InstancesTree.GetItemText(selected_item).split(" (")
+ var_type = var_type.split(")")[0]
- menu = wx.Menu(title='')
- new_id = wx.NewId()
- 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"))
- self.PopupMenu(menu)
+ if self.Controler.IsOfType(var_type, "ANY_NUM", True) or\
+ self.Controler.IsOfType(var_type, "ANY_BIT", True):
+ parent_item = self.InstancesTree.GetItemParent(selected_item)
+ while self.InstancesTree.GetPyData(parent_item)[0] != ITEM_PROJECT:
+ parent_name = self.InstancesTree.GetItemText(parent_item).split(" (")[0]
+ var_path = "%s.%s"%(parent_name, var_path)
+ parent_item = self.InstancesTree.GetItemParent(parent_item)
+
+ menu = wx.Menu(title='')
+ new_id = wx.NewId()
+ 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"))
+ self.PopupMenu(menu)
event.Skip()
def AddVariableGraphicFunction(self, iec_path):
@@ -2076,59 +1866,58 @@
#-------------------------------------------------------------------------------
def RefreshLibraryTree(self):
- if not self.Debug:
- to_delete = []
- blocktypes = self.Controler.GetBlockTypes(debug = self.Debug)
- root = self.LibraryTree.GetRootItem()
- if not root.IsOk():
- if wx.Platform == '__WXMSW__':
- root = self.LibraryTree.AddRoot(_("Block Types"))
- self.LibraryTree.SetPyData(root, {"type" : CATEGORY})
+ to_delete = []
+ blocktypes = self.Controler.GetBlockTypes()
+ root = self.LibraryTree.GetRootItem()
+ if not root.IsOk():
+ if wx.Platform == '__WXMSW__':
+ root = self.LibraryTree.AddRoot(_("Block Types"))
+ self.LibraryTree.SetPyData(root, {"type" : CATEGORY})
+ else:
+ root = self.LibraryTree.AddRoot("")
+ if wx.VERSION >= (2, 6, 0):
+ category_item, root_cookie = self.LibraryTree.GetFirstChild(root)
+ 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))
+ if wx.Platform != '__WXMSW__':
+ category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
+ else:
+ 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)
+ else:
+ blocktype_item, category_cookie = self.LibraryTree.GetFirstChild(category_item, 0)
+ for blocktype in category["list"]:
+ if not blocktype_item.IsOk():
+ blocktype_item = self.LibraryTree.AppendItem(category_item, blocktype["name"])
+ if wx.Platform != '__WXMSW__':
+ blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
else:
- root = self.LibraryTree.AddRoot("")
- if wx.VERSION >= (2, 6, 0):
- category_item, root_cookie = self.LibraryTree.GetFirstChild(root)
- 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))
- if wx.Platform != '__WXMSW__':
- category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
- else:
- 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)
- else:
- blocktype_item, category_cookie = self.LibraryTree.GetFirstChild(category_item, 0)
- for blocktype in category["list"]:
- if not blocktype_item.IsOk():
- blocktype_item = self.LibraryTree.AppendItem(category_item, blocktype["name"])
- if wx.Platform != '__WXMSW__':
- blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
- else:
- self.LibraryTree.SetItemText(blocktype_item, blocktype["name"])
- self.LibraryTree.SetPyData(blocktype_item, {"type" : BLOCK, "block_type" : blocktype["type"], "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])})
- blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
- while blocktype_item.IsOk():
- to_delete.append(blocktype_item)
- blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
- category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
- while category_item.IsOk():
- to_delete.append(category_item)
- category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
- for item in to_delete:
- self.LibraryTree.Delete(item)
- if wx.Platform == '__WXMSW__':
- self.LibraryTree.Expand(root)
+ self.LibraryTree.SetItemText(blocktype_item, blocktype["name"])
+ self.LibraryTree.SetPyData(blocktype_item, {"type" : BLOCK, "block_type" : blocktype["type"], "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])})
+ blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
+ while blocktype_item.IsOk():
+ to_delete.append(blocktype_item)
+ blocktype_item, category_cookie = self.LibraryTree.GetNextChild(category_item, category_cookie)
+ category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
+ while category_item.IsOk():
+ to_delete.append(category_item)
+ category_item, root_cookie = self.LibraryTree.GetNextChild(root, root_cookie)
+ for item in to_delete:
+ self.LibraryTree.Delete(item)
+ if wx.Platform == '__WXMSW__':
+ self.LibraryTree.Expand(root)
def OnLibraryTreeItemSelected(self, event):
selected = event.GetItem()
pydata = self.LibraryTree.GetPyData(selected)
if pydata is not None and pydata["type"] != CATEGORY:
- blocktype = self.Controler.GetBlockType(self.LibraryTree.GetItemText(selected), pydata["inputs"], debug = self.Debug)
+ blocktype = self.Controler.GetBlockType(self.LibraryTree.GetItemText(selected), pydata["inputs"])
if blocktype:
comment = blocktype["comment"]
self.LibraryComment.SetValue(_(comment) + blocktype.get("usage", ""))
@@ -2153,56 +1942,55 @@
#-------------------------------------------------------------------------------
def ResetToolBar(self):
- if not self.Debug:
- for item in self.CurrentToolBar:
- if wx.VERSION >= (2, 6, 0):
- self.Unbind(wx.EVT_MENU, id=item)
- else:
- self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED)
-
+ for item in self.CurrentToolBar:
+ if wx.VERSION >= (2, 6, 0):
+ self.Unbind(wx.EVT_MENU, id=item)
+ else:
+ self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED)
+
+ if USE_AUI:
+ ToolBar = self.Panes["ToolBar"]
+ else:
+ ToolBar = self.ToolBar
+ if ToolBar:
+ ToolBar.DeleteTool(item)
+ ToolBar.Realize()
if USE_AUI:
- ToolBar = self.Panes["ToolBar"]
- else:
- ToolBar = self.ToolBar
- if ToolBar:
- ToolBar.DeleteTool(item)
- ToolBar.Realize()
- if USE_AUI:
- self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
- self.AUIManager.Update()
+ self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+ self.AUIManager.Update()
def RefreshToolBar(self):
- if not self.Debug:
- selected = self.TabsOpened.GetSelection()
- if selected != -1:
- language = self.Controler.GetEditedElementBodyType(self.TabsOpened.GetPage(selected).GetTagName(), self.Debug)
+ selected = self.TabsOpened.GetSelection()
+ language = None
+ if selected != -1:
+ window = self.TabsOpened.GetPage(selected)
+ if not window.IsDebugging():
+ language = self.Controler.GetEditedElementBodyType(window.GetTagName())
+ if language is not None and language != self.CurrentLanguage:
+ self.ResetToolBar()
+ self.CurrentLanguage = language
+ self.CurrentToolBar = []
+ if USE_AUI:
+ ToolBar = self.Panes["ToolBar"]
else:
- language = None
- if language is not None and language != self.CurrentLanguage:
- self.ResetToolBar()
- self.CurrentLanguage = language
- self.CurrentToolBar = []
+ ToolBar = self.ToolBar
+ if ToolBar:
+ for radio, modes, id, method, picture, help in ToolBarItems[language]:
+ if modes & self.DrawingMode:
+ if radio or self.DrawingMode == FREEDRAWING_MODE:
+ ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
+ else:
+ ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
+ self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
+ self.CurrentToolBar.append(id)
+ ToolBar.Realize()
if USE_AUI:
- ToolBar = self.Panes["ToolBar"]
- else:
- ToolBar = self.ToolBar
- if ToolBar:
- for radio, modes, id, method, picture, help in ToolBarItems[language]:
- if modes & self.DrawingMode:
- if radio or self.DrawingMode == FREEDRAWING_MODE:
- ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
- else:
- ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
- self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
- self.CurrentToolBar.append(id)
- ToolBar.Realize()
- if USE_AUI:
- self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
- self.AUIManager.Update()
- elif not language:
- self.ResetToolBar()
- self.CurrentLanguage = language
- self.ResetCurrentMode()
+ self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+ self.AUIManager.Update()
+ elif not language:
+ self.ResetToolBar()
+ self.CurrentLanguage = language
+ self.ResetCurrentMode()
#-------------------------------------------------------------------------------
@@ -2365,27 +2153,22 @@
def OnAddDataTypeMenu(self, event):
dialog = DataTypeDialog(self, _("Add a new data type"), _("Please enter data type name"), "", wx.OK|wx.CANCEL)
- dialog.SetDataTypeNames(self.Controler.GetProjectDataTypeNames(self.Debug))
+ dialog.SetDataTypeNames(self.Controler.GetProjectDataTypeNames())
if dialog.ShowModal() == wx.ID_OK:
self.Controler.ProjectAddDataType(dialog.GetValue())
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE)
dialog.Destroy()
event.Skip()
def GenerateAddPouFunction(self, pou_type):
def OnAddPouMenu(event):
dialog = PouDialog(self, pou_type)
- dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
- dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(debug = self.Debug))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"])
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshLibraryTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE, LIBRARYTREE)
dialog.Destroy()
event.Skip()
return OnAddPouMenu
@@ -2393,14 +2176,12 @@
def GenerateAddTransitionFunction(self, pou_name):
def OnAddTransitionMenu(event):
dialog = PouTransitionDialog(self)
- dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
- dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name, self.Debug))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name))
if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"])
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE)
dialog.Destroy()
event.Skip()
return OnAddTransitionMenu
@@ -2408,44 +2189,36 @@
def GenerateAddActionFunction(self, pou_name):
def OnAddActionMenu(event):
dialog = PouActionDialog(self)
- dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
- dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name, self.Debug))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name))
if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"])
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE)
dialog.Destroy()
event.Skip()
return OnAddActionMenu
def OnAddConfigurationMenu(self, event):
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))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetValue()
self.Controler.ProjectAddConfiguration(value)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshInstancesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE, INSTANCESTREE)
dialog.Destroy()
event.Skip()
def GenerateAddResourceFunction(self, config_name):
def OnAddResourceMenu(event):
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))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetValue()
self.Controler.ProjectAddConfigurationResource(config_name, value)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshInstancesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE, INSTANCESTREE)
dialog.Destroy()
event.Skip()
return OnAddResourceMenu
@@ -2455,11 +2228,7 @@
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_POU:
self.Controler.ProjectChangePouType(name, new_type)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshLibraryTree()
- self.RefreshToolBar()
+ self._Refresh(TITLE, TOOLBAR, EDITMENU, TYPESTREE, LIBRARYTREE)
event.Skip()
return OnChangePouTypeMenu
@@ -2467,14 +2236,10 @@
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.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
if dialog.ShowModal() == wx.ID_OK:
self.Controler.ProjectCreatePouFrom(dialog.GetValue(), self.TypesTree.GetItemText(selected))
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshLibraryTree()
- self.RefreshToolBar()
+ self._Refresh(TITLE, TOOLBAR, EDITMENU, TYPESTREE, LIBRARYTREE)
event.Skip()
#-------------------------------------------------------------------------------
@@ -2485,20 +2250,15 @@
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_DATATYPE:
name = self.TypesTree.GetItemText(selected)
- if not self.Controler.DataTypeIsUsed(name, self.Debug):
+ if not self.Controler.DataTypeIsUsed(name):
self.Controler.ProjectRemoveDataType(name)
tagname = self.Controler.ComputeDataTypeName(name)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshToolBar()
+ self._Refresh(TITLE, TOOLBAR, EDITMENU, TYPESTREE)
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.ShowModal()
- message.Destroy()
+ self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!"))
event.Skip()
def OnRenamePouMenu(self, event):
@@ -2511,23 +2271,16 @@
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_POU:
name = self.TypesTree.GetItemText(selected)
- if not self.Controler.PouIsUsed(name, self.Debug):
+ if not self.Controler.PouIsUsed(name):
self.Controler.ProjectRemovePou(name)
tagname = self.Controler.ComputePouName(name)
idx = self.IsOpened(tagname)
if idx is not None:
self.VariablePanelIndexer.RemoveVariablePanel(tagname)
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshInstancesTree()
- self.RefreshLibraryTree()
- self.RefreshToolBar()
+ self._Refresh(TITLE, TOOLBAR, EDITMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE)
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.ShowModal()
- message.Destroy()
+ self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!"))
event.Skip()
def OnRemoveTransitionMenu(self, event):
@@ -2546,9 +2299,7 @@
if idx is not None:
self.VariablePanelIndexer.RemoveVariablePanel(tagname)
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE)
event.Skip()
def OnRemoveActionMenu(self, event):
@@ -2567,9 +2318,7 @@
if idx is not None:
self.VariablePanelIndexer.RemoveVariablePanel(tagname)
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE)
event.Skip()
def OnRemoveConfigurationMenu(self, event):
@@ -2582,10 +2331,7 @@
if idx is not None:
self.VariablePanelIndexer.RemoveVariablePanel(tagname)
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshInstancesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE, INSTANCESTREE)
event.Skip()
def OnRemoveResourceMenu(self, event):
@@ -2604,10 +2350,7 @@
if idx is not None:
self.VariablePanelIndexer.RemoveVariablePanel(tagname)
self.TabsOpened.DeletePage(idx)
- self.RefreshTitle()
- self.RefreshEditMenu()
- self.RefreshTypesTree()
- self.RefreshInstancesTree()
+ self._Refresh(TITLE, EDITMENU, TYPESTREE, INSTANCESTREE)
event.Skip()
def OnPLCOpenEditorMenu(self, event):
@@ -2651,22 +2394,256 @@
viewer = self.TabsOpened.GetPage(i)
viewer.ClearErrors()
- RefreshFunctions = {
- TITLE : RefreshTitle,
- TOOLBAR : RefreshToolBar,
- FILEMENU : RefreshFileMenu,
- EDITMENU : RefreshEditMenu,
- DISPLAYMENU : RefreshDisplayMenu,
- TYPESTREE : RefreshTypesTree,
- INSTANCESTREE : RefreshInstancesTree,
- LIBRARYTREE : RefreshLibraryTree,
- SCALING : RefreshScaling}
-
-current_num = 0
-def GetNewNum():
- global current_num
- current_num += 1
- return current_num
+#-------------------------------------------------------------------------------
+# PLCOpenEditor Main Class
+#-------------------------------------------------------------------------------
+
+class PLCOpenEditor(IDEFrame):
+
+ # Compatibility function for wx versions < 2.6
+ if wx.VERSION < (2, 6, 0):
+ def Bind(self, event, function, id = None):
+ if id is not None:
+ event(self, id, function)
+ else:
+ event(self, function)
+
+ def _init_coll_FileMenu_Items(self, parent):
+ AppendMenu(parent, help='', id=wx.ID_NEW,
+ 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'))
+ AppendMenu(parent, help='', id=wx.ID_CLOSE,
+ kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W'))
+ AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
+ kind=wx.ITEM_NORMAL, text=_(u'Close Project'))
+ parent.AppendSeparator()
+ AppendMenu(parent, help='', id=wx.ID_SAVE,
+ kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S'))
+ AppendMenu(parent, help='', id=wx.ID_SAVEAS,
+ 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'))
+ parent.AppendSeparator()
+ AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP,
+ kind=wx.ITEM_NORMAL, text=_(u'Page Setup'))
+ AppendMenu(parent, help='', id=wx.ID_PREVIEW,
+ kind=wx.ITEM_NORMAL, text=_(u'Preview'))
+ AppendMenu(parent, help='', id=wx.ID_PRINT,
+ kind=wx.ITEM_NORMAL, text=_(u'Print'))
+ parent.AppendSeparator()
+ AppendMenu(parent, help='', id=wx.ID_PROPERTIES,
+ kind=wx.ITEM_NORMAL, text=_(u'Properties'))
+ parent.AppendSeparator()
+ AppendMenu(parent, help='', id=wx.ID_EXIT,
+ kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q'))
+
+ self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
+ self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
+ self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
+ self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
+ self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
+ self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS)
+ self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu,
+ id=ID_PLCOPENEDITORFILEMENUGENERATE)
+ self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
+ self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW)
+ self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
+ self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
+ self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
+
+ def _init_coll_HelpMenu_Items(self, parent):
+ AppendMenu(parent, help='', id=wx.ID_HELP,
+ 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')
+ AppendMenu(parent, help='', id=wx.ID_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)
+
+ ## Constructor of the PLCOpenEditor class.
+ # @param parent The parent window.
+ # @param controler The controler been used by PLCOpenEditor (default: None).
+ # @param fileOpen The filepath to open if no controler defined (default: None).
+ # @param debug The filepath to open if no controler defined (default: False).
+ def __init__(self, parent, fileOpen = None):
+ IDEFrame.__init__(self, parent)
+
+ # Open the filepath if defined
+ if fileOpen is not None:
+ # Create a new controller
+ self.Controler = PLCControler()
+ self.Controler.OpenXMLFile(fileOpen)
+
+ # Define PLCOpenEditor icon
+ self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
+
+ self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
+
+ self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+
+ def OnCloseFrame(self, event):
+ if self.Controler is None or self.CheckSaveBeforeClosing():
+ if USE_AUI:
+ self.AUIManager.UnInit()
+ event.Skip()
+ else:
+ event.Veto()
+
+ def RefreshTitle(self):
+ name = _("PLCOpenEditor")
+ if self.Controler is not None:
+ self.SetTitle("%s - %s"%(name, self.Controler.GetFilename()))
+ else:
+ self.SetTitle(name)
+
+#-------------------------------------------------------------------------------
+# File Menu Functions
+#-------------------------------------------------------------------------------
+
+ def RefreshFileMenu(self):
+ if self.Controler is not None:
+ selected = self.TabsOpened.GetSelection()
+ if selected >= 0:
+ graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer)
+ else:
+ graphic_viewer = False
+ if self.TabsOpened.GetPageCount() > 0:
+ self.FileMenu.Enable(wx.ID_CLOSE, True)
+ if graphic_viewer:
+ self.FileMenu.Enable(wx.ID_PREVIEW, True)
+ self.FileMenu.Enable(wx.ID_PRINT, True)
+ else:
+ self.FileMenu.Enable(wx.ID_PREVIEW, False)
+ self.FileMenu.Enable(wx.ID_PRINT, False)
+ else:
+ self.FileMenu.Enable(wx.ID_CLOSE, False)
+ self.FileMenu.Enable(wx.ID_PREVIEW, False)
+ self.FileMenu.Enable(wx.ID_PRINT, False)
+ self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
+ self.FileMenu.Enable(wx.ID_SAVE, True)
+ self.FileMenu.Enable(wx.ID_PROPERTIES, True)
+ self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
+ self.FileMenu.Enable(wx.ID_SAVEAS, True)
+ self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True)
+ else:
+ self.FileMenu.Enable(wx.ID_CLOSE, False)
+ self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
+ self.FileMenu.Enable(wx.ID_PREVIEW, False)
+ self.FileMenu.Enable(wx.ID_PRINT, False)
+ self.FileMenu.Enable(wx.ID_SAVE, False)
+ self.FileMenu.Enable(wx.ID_PROPERTIES, False)
+ self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
+ self.FileMenu.Enable(wx.ID_SAVEAS, False)
+ self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)
+
+ def OnNewProjectMenu(self, event):
+ if self.Controler is not None and not self.CheckSaveBeforeClosing():
+ return
+ dialog = ProjectDialog(self)
+ if dialog.ShowModal() == wx.ID_OK:
+ properties = dialog.GetValues()
+ self.Controler = PLCControler()
+ self.Controler.CreateNewProject(properties)
+ self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE,
+ LIBRARYTREE)
+ event.Skip()
+
+ def OnOpenProjectMenu(self, event):
+ if self.Controler is not None and not self.CheckSaveBeforeClosing():
+ return
+ filepath = ""
+ if self.Controler is not None:
+ filepath = self.Controler.GetFilePath()
+ if filepath != "":
+ 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)
+ if dialog.ShowModal() == wx.ID_OK:
+ filepath = dialog.GetPath()
+ if os.path.isfile(filepath):
+ self.DeleteAllPages()
+ self.VariablePanelIndexer.RemoveAllPanels()
+ self.Controler = PLCControler()
+ self.Controler.OpenXMLFile(filepath)
+ self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+ self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ dialog.Destroy()
+ event.Skip()
+
+ def OnCloseProjectMenu(self, event):
+ if not self.CheckSaveBeforeClosing():
+ return
+ self.DeleteAllPages()
+ self.VariablePanelIndexer.RemoveAllPanels()
+ self.TypesTree.DeleteAllItems()
+ self.InstancesTree.DeleteAllItems()
+ self.LibraryTree.DeleteAllItems()
+ self.Controler = None
+ self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ event.Skip()
+
+ def OnSaveProjectMenu(self, event):
+ self.SaveProject()
+ event.Skip()
+
+ def OnSaveProjectAsMenu(self, event):
+ self.SaveProjectAs()
+ 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)
+ if dialog.ShowModal() == wx.ID_OK:
+ filepath = dialog.GetPath()
+ message_text = ""
+ 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])
+ 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
+ else:
+ 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 = wx.MessageDialog(self, message_text, header, wx.OK|icon)
+ message.ShowModal()
+ message.Destroy()
+ dialog.Destroy()
+ event.Skip()
+
+ def SaveProject(self):
+ result = self.Controler.SaveXMLFile()
+ if not result:
+ self.SaveProjectAs()
+ else:
+ self.RefreshTitle()
+
+ def SaveProjectAs(self):
+ filepath = self.Controler.GetFilePath()
+ if filepath != "":
+ directory, filename = os.path.split(filepath)
+ else:
+ directory, filename = os.getcwd(), "%(projectName)s.xml"%self.Controler.GetProjectProperties()
+ 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)
+ else:
+ self.ShowErrorMessage(_("\"%s\" is not a valid folder!")%os.path.dirname(filepath))
+ self.RefreshTitle()
+ dialog.Destroy()
#-------------------------------------------------------------------------------
# Create Project Dialog
@@ -3783,17 +3760,16 @@
self._init_sizers()
- def __init__(self, parent, window, controler):
+ def __init__(self, parent, window):
self._init_ctrls(parent)
self.ParentWindow = window
- self.Controler = controler
self.VariablePanelList = {}
self.CurrentPanel = None
def AddVariablePanel(self, tagname, element_type):
- new_panel = VariablePanel(self, self.ParentWindow, self.Controler, element_type)
+ new_panel = VariablePanel(self, self.ParentWindow, self.ParentWindow.Controler, element_type)
new_panel.SetTagName(tagname)
new_panel.Hide()
new_panel.RefreshView()
@@ -3978,6 +3954,8 @@
"""
for row in range(self.GetNumberRows()):
+ grid.SetRowMinimalHeight(row, 28)
+ grid.AutoSizeRow(row, False)
for col in range(self.GetNumberCols()):
editor = None
renderer = None
@@ -4335,29 +4313,29 @@
self.TagName = tagname
def IsFunctionBlockType(self, name):
- bodytype = self.Controler.GetEditedElementBodyType(self.TagName, self.ParentWindow.Debug)
- pouname, poutype = self.Controler.GetEditedElementType(self.TagName, self.ParentWindow.Debug)
+ bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
+ pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
if poutype != "function" and bodytype in ["ST", "IL"]:
return False
else:
- return name in self.Controler.GetFunctionBlockTypes(self.TagName, self.ParentWindow.Debug)
+ return name in self.Controler.GetFunctionBlockTypes(self.TagName)
def RefreshView(self):
- self.PouNames = self.Controler.GetProjectPouNames(self.ParentWindow.Debug)
+ self.PouNames = self.Controler.GetProjectPouNames()
words = self.TagName.split("::")
if self.ElementType == "config":
self.PouIsUsed = False
returnType = None
- self.Values = self.Controler.GetConfigurationGlobalVars(words[1], self.ParentWindow.Debug)
+ self.Values = self.Controler.GetConfigurationGlobalVars(words[1])
elif self.ElementType == "resource":
self.PouIsUsed = False
returnType = None
- self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2], self.ParentWindow.Debug)
- else:
- self.PouIsUsed = self.Controler.PouIsUsed(words[1], self.ParentWindow.Debug)
- returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, self.ParentWindow.Debug)
- self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.ParentWindow.Debug)
+ self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2])
+ else:
+ self.PouIsUsed = self.Controler.PouIsUsed(words[1])
+ returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
+ self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName)
if returnType and self.ReturnType.IsEnabled():
self.ReturnType.SetStringSelection(returnType)
@@ -4370,10 +4348,7 @@
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection())
self.Controler.BufferProject()
self.ParentWindow.RefreshEditor(variablepanel = False)
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshInstancesTree()
- self.ParentWindow.RefreshLibraryTree()
+ self.ParentWindow._Refresh(TITLE, EDITMENU, INSTANCESTREE, LIBRARYTREE)
event.Skip()
def OnClassFilter(self, event):
@@ -4445,7 +4420,7 @@
def OnVariablesGridCellChange(self, event):
row, col = event.GetRow(), event.GetCol()
- colname = self.Table.GetColLabelValue(col)
+ colname = self.Table.GetColLabelValue(col, False)
value = self.Table.GetValue(row, col)
if colname == "Name" and value != "":
if not TestIdentifier(value):
@@ -4475,10 +4450,7 @@
self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value)
self.Controler.BufferProject()
self.ParentWindow.RefreshEditor(variablepanel = False)
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshInstancesTree()
- self.ParentWindow.RefreshLibraryTree()
+ self.ParentWindow._Refresh(TITLE, EDITMENU, INSTANCESTREE, LIBRARYTREE)
event.Skip()
else:
self.SaveValues()
@@ -4498,16 +4470,16 @@
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)
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):
+ for datatype in self.Controler.GetDataTypes(basetypes = False):
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)
functionblock_menu = wx.Menu(title='')
- bodytype = self.Controler.GetEditedElementBodyType(self.TagName, self.ParentWindow.Debug)
- pouname, poutype = self.Controler.GetEditedElementType(self.TagName, self.ParentWindow.Debug)
+ bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
+ pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
if classtype in ["Input","Output","InOut","External","Global"] or poutype != "function" and bodytype in ["ST", "IL"]:
- for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName, self.ParentWindow.Debug):
+ for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName):
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)
@@ -4526,10 +4498,7 @@
self.SaveValues(False)
self.ParentWindow.RefreshEditor(variablepanel = False)
self.Controler.BufferProject()
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshInstancesTree()
- self.ParentWindow.RefreshLibraryTree()
+ self.ParentWindow._Refresh(TITLE, EDITMENU, INSTANCESTREE, LIBRARYTREE)
event.Skip()
return VariableTypeFunction
@@ -4596,10 +4565,7 @@
self.Controler.SetPouInterfaceVars(words[1], self.Values)
if buffer:
self.Controler.BufferProject()
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshInstancesTree()
- self.ParentWindow.RefreshLibraryTree()
+ self.ParentWindow._Refresh(TITLE, EDITMENU, INSTANCESTREE, LIBRARYTREE)
def AddVariableError(self, infos):
if isinstance(infos[0], TupleType):
@@ -4869,7 +4835,7 @@
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)
+ size=wx.DefaultSize, style=0)
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DEBUGVARIABLEPANELDELETEBUTTON)
self._init_sizers()
@@ -4903,6 +4869,13 @@
self.Table.ResetView(self.VariablesGrid)
self.Thaw()
+ def ResetGrid(self):
+ self.DeleteDataConsumers()
+ self.Table.Empty()
+ self.Freeze()
+ self.Table.ResetView(self.VariablesGrid)
+ self.Thaw()
+
def OnDeleteButton(self, event):
idx = self.VariablesGrid.GetGridCursorRow()
item = self.Table.GetItem(idx)