IDEFrame.py
changeset 1781 b112bfdde5cc
parent 1775 b45f2768fab1
child 1782 5b6ad7a7fd9d
equal deleted inserted replaced
1780:c52d1460cea8 1781:b112bfdde5cc
   680             self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger"))
   680             self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger"))
   681             self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"])
   681             self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"])
   682 
   682 
   683         self.AUIManager.Update()
   683         self.AUIManager.Update()
   684 
   684 
   685     ## Constructor of the PLCOpenEditor class.
       
   686     #  @param parent The parent window.
       
   687     #  @param controler The controler been used by PLCOpenEditor (default: None).
       
   688     #  @param fileOpen The filepath to open if no controler defined (default: None).
       
   689     #  @param debug The filepath to open if no controler defined (default: False).
       
   690     def __init__(self, parent, enable_debug=False):
   685     def __init__(self, parent, enable_debug=False):
   691         self.Controler = None
   686         self.Controler = None
   692         self.Config = wx.ConfigBase.Get()
   687         self.Config = wx.ConfigBase.Get()
   693         self.EnableDebug = enable_debug
   688         self.EnableDebug = enable_debug
   694 
   689 
   921             POUINSTANCEVARIABLESPANEL: self.RefreshPouInstanceVariablesPanel,
   916             POUINSTANCEVARIABLESPANEL: self.RefreshPouInstanceVariablesPanel,
   922             LIBRARYTREE: self.RefreshLibraryPanel,
   917             LIBRARYTREE: self.RefreshLibraryPanel,
   923             SCALING: self.RefreshScaling,
   918             SCALING: self.RefreshScaling,
   924             PAGETITLES: self.RefreshPageTitles}
   919             PAGETITLES: self.RefreshPageTitles}
   925 
   920 
   926     ## Call PLCOpenEditor refresh functions.
       
   927     #  @param elements List of elements to refresh.
       
   928     def _Refresh(self, *elements):
   921     def _Refresh(self, *elements):
       
   922         """Call Editor refresh functions.
       
   923 
       
   924         :param elements: List of elements to refresh.
       
   925         """
   929         try:
   926         try:
   930             for element in elements:
   927             for element in elements:
   931                 self.RefreshFunctions[element]()
   928                 self.RefreshFunctions[element]()
   932         except wx.PyDeadObjectError:
   929         except wx.PyDeadObjectError:
   933             # ignore exceptions caused by refresh while quitting
   930             # ignore exceptions caused by refresh while quitting
   934             pass
   931             pass
   935 
   932 
   936     ## Callback function when AUINotebook Page closed with CloseButton
       
   937     #  @param event AUINotebook Event.
       
   938     def OnPageClose(self, event):
   933     def OnPageClose(self, event):
       
   934         """Callback function when AUINotebook Page closed with CloseButton
       
   935 
       
   936         :param event: AUINotebook Event.
       
   937         """
   939         selected = self.TabsOpened.GetSelection()
   938         selected = self.TabsOpened.GetSelection()
   940         if selected > -1:
   939         if selected > -1:
   941             window = self.TabsOpened.GetPage(selected)
   940             window = self.TabsOpened.GetPage(selected)
   942 
   941 
   943             if window.CheckSaveBeforeClosing():
   942             if window.CheckSaveBeforeClosing():
   999 
   998 
  1000 #-------------------------------------------------------------------------------
   999 #-------------------------------------------------------------------------------
  1001 #                            Notebook Unified Functions
  1000 #                            Notebook Unified Functions
  1002 #-------------------------------------------------------------------------------
  1001 #-------------------------------------------------------------------------------
  1003 
  1002 
  1004     ## Function that add a tab in Notebook, calling refresh for tab DClick event
       
  1005     # for wx.aui.AUINotebook.
       
  1006     #  @param window Panel to display in tab.
       
  1007     #  @param text title for the tab ctrl.
       
  1008     def AddPage(self, window, text):
  1003     def AddPage(self, window, text):
       
  1004         """Function that add a tab in Notebook, calling refresh for tab DClick event
       
  1005         for wx.aui.AUINotebook.
       
  1006 
       
  1007         :param window: Panel to display in tab.
       
  1008         :param text: title for the tab ctrl.
       
  1009         """
  1009         self.TabsOpened.AddPage(window, text)
  1010         self.TabsOpened.AddPage(window, text)
  1010         self.RefreshTabCtrlEvent()
  1011         self.RefreshTabCtrlEvent()
  1011 
  1012 
  1012     ## Function that add a tab in Notebook, calling refresh for tab DClick event
       
  1013     # for wx.aui.AUINotebook.
       
  1014     #  @param window Panel to display in tab.
       
  1015     #  @param text title for the tab ctrl.
       
  1016     def DeletePage(self, window):
  1013     def DeletePage(self, window):
  1017         for idx in xrange(self.TabsOpened.GetPageCount()):
  1014         for idx in xrange(self.TabsOpened.GetPageCount()):
  1018             if self.TabsOpened.GetPage(idx) == window:
  1015             if self.TabsOpened.GetPage(idx) == window:
  1019                 self.TabsOpened.DeletePage(idx)
  1016                 self.TabsOpened.DeletePage(idx)
  1020                 self.RefreshTabCtrlEvent()
  1017                 self.RefreshTabCtrlEvent()
  1021                 return
  1018                 return
  1022 
  1019 
  1023     ## Function that fix difference in deleting all tabs between
       
  1024     # wx.Notebook and wx.aui.AUINotebook.
       
  1025     def DeleteAllPages(self):
  1020     def DeleteAllPages(self):
       
  1021         """Function that fix difference in deleting all tabs between
       
  1022         wx.Notebook and wx.aui.AUINotebook.
       
  1023         """
  1026         for idx in xrange(self.TabsOpened.GetPageCount()):
  1024         for idx in xrange(self.TabsOpened.GetPageCount()):
  1027             self.TabsOpened.DeletePage(0)
  1025             self.TabsOpened.DeletePage(0)
  1028         self.RefreshTabCtrlEvent()
  1026         self.RefreshTabCtrlEvent()
  1029 
  1027 
  1030     ## Function that fix difference in setting picture on tab between
       
  1031     # wx.Notebook and wx.aui.AUINotebook.
       
  1032     #  @param idx Tab index.
       
  1033     #  @param bitmap wx.Bitmap to define on tab.
       
  1034     #  @return True if operation succeeded
       
  1035     def SetPageBitmap(self, idx, bitmap):
  1028     def SetPageBitmap(self, idx, bitmap):
       
  1029         """Function that fix difference in setting picture on tab between
       
  1030         wx.Notebook and wx.aui.AUINotebook.
       
  1031 
       
  1032         :param idx: Tab index.
       
  1033         :param bitmap: wx.Bitmap to define on tab.
       
  1034         :returns: True if operation succeeded
       
  1035         """
  1036         return self.TabsOpened.SetPageBitmap(idx, bitmap)
  1036         return self.TabsOpened.SetPageBitmap(idx, bitmap)
  1037 
  1037 
  1038 #-------------------------------------------------------------------------------
  1038 #-------------------------------------------------------------------------------
  1039 #                         Dialog Message Functions
  1039 #                         Dialog Message Functions
  1040 #-------------------------------------------------------------------------------
  1040 #-------------------------------------------------------------------------------
  1041 
  1041 
  1042     ## Function displaying an Error dialog in PLCOpenEditor.
       
  1043     #  @param message The message to display.
       
  1044     def ShowErrorMessage(self, message):
  1042     def ShowErrorMessage(self, message):
       
  1043         """Function displaying an Error dialog in editor.
       
  1044 
       
  1045         :param message: The message to display.
       
  1046         """
  1045         dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
  1047         dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
  1046         dialog.ShowModal()
  1048         dialog.ShowModal()
  1047         dialog.Destroy()
  1049         dialog.Destroy()
  1048 
  1050 
  1049     ## Function displaying an Error dialog in PLCOpenEditor.
       
  1050     #  @return False if closing cancelled.
       
  1051     def CheckSaveBeforeClosing(self, title=_("Close Project")):
  1051     def CheckSaveBeforeClosing(self, title=_("Close Project")):
       
  1052         """Function displaying an question dialog if project is not saved"
       
  1053 
       
  1054         :returns: False if closing cancelled.
       
  1055         """
  1052         if not self.Controler.ProjectIsSaved():
  1056         if not self.Controler.ProjectIsSaved():
  1053             dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
  1057             dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
  1054             answer = dialog.ShowModal()
  1058             answer = dialog.ShowModal()
  1055             dialog.Destroy()
  1059             dialog.Destroy()
  1056             if answer == wx.ID_YES:
  1060             if answer == wx.ID_YES: