--- a/PLCOpenEditor.py Fri May 18 18:49:49 2012 +0200
+++ b/PLCOpenEditor.py Sat May 19 11:19:54 2012 +0200
@@ -24,13 +24,7 @@
from datetime import datetime
import wx, wx.grid
-
-if wx.VERSION >= (2, 8, 0):
- import wx.aui
- USE_AUI = True
-else:
- USE_AUI = False
-
+import wx.aui
import os, re, platform, sys, time, traceback, getopt
import cPickle
@@ -495,11 +489,10 @@
kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%")
self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id)
- if USE_AUI:
- parent.AppendSeparator()
- AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE,
- kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective'))
- self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE)
+ parent.AppendSeparator()
+ AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE,
+ kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective'))
+ self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE)
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH)
if self.EnableDebug:
@@ -537,103 +530,52 @@
# Creating main structure
#-----------------------------------------------------------------------
- if USE_AUI:
- self.AUIManager = wx.aui.AuiManager(self)
- self.AUIManager.SetDockSizeConstraint(0.5, 0.5)
- self.Panes = {}
-
- 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.LeftNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
- self.OnAllowNotebookDnD)
- self.AUIManager.AddPane(self.LeftNoteBook,
- wx.aui.AuiPaneInfo().Name("ProjectPane").
- 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.BottomNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
- self.OnAllowNotebookDnD)
- self.AUIManager.AddPane(self.BottomNoteBook,
- wx.aui.AuiPaneInfo().Name("ResultPane").
- Bottom().Layer(0).
- BestSize(wx.Size(800, 300)).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.RightNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
- self.OnAllowNotebookDnD)
- self.AUIManager.AddPane(self.RightNoteBook,
- wx.aui.AuiPaneInfo().Name("LibraryPane").
- 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_CHANGING,
- self.OnPouSelectedChanging)
- 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().Name("TabsPane"))
-
- else:
- self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER,
- name='MainSplitter', parent=self, point=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.SP_3D)
- self.MainSplitter.SetNeedUpdating(True)
- self.MainSplitter.SetMinimumPaneSize(1)
-
- 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)
-
- 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_CHANGING,
- self.OnPouSelectedChanging, id=ID_PLCOPENEDITORTABSOPENED)
- self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
- self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
- else:
- wx.EVT_NOTEBOOK_PAGE_CHANGING(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED,
- self.OnPouSelectedChanging)
- 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)
+ self.AUIManager = wx.aui.AuiManager(self)
+ self.AUIManager.SetDockSizeConstraint(0.5, 0.5)
+ self.Panes = {}
+
+ 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.LeftNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
+ self.OnAllowNotebookDnD)
+ self.AUIManager.AddPane(self.LeftNoteBook,
+ wx.aui.AuiPaneInfo().Name("ProjectPane").
+ 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.BottomNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
+ self.OnAllowNotebookDnD)
+ self.AUIManager.AddPane(self.BottomNoteBook,
+ wx.aui.AuiPaneInfo().Name("ResultPane").
+ Bottom().Layer(0).
+ BestSize(wx.Size(800, 300)).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.RightNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND,
+ self.OnAllowNotebookDnD)
+ self.AUIManager.AddPane(self.RightNoteBook,
+ wx.aui.AuiPaneInfo().Name("LibraryPane").
+ 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_CHANGING,
+ self.OnPouSelectedChanging)
+ 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().Name("TabsPane"))
#-----------------------------------------------------------------------
# Creating PLCopen Project Types Tree
@@ -692,36 +634,27 @@
# Creating Tool Bar
#-----------------------------------------------------------------------
- if USE_AUI:
- MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
- wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
- MenuToolBar.SetToolBitmapSize(wx.Size(25, 25))
- MenuToolBar.Realize()
- self.Panes["MenuToolBar"] = MenuToolBar
- self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo().
- Name("MenuToolBar").Caption(_("Menu ToolBar")).
- ToolbarPane().Top().
- LeftDockable(False).RightDockable(False))
-
- EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
- wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
- EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
- EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
- wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
- EditorToolBar.Realize()
- self.Panes["EditorToolBar"] = EditorToolBar
- self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo().
- Name("EditorToolBar").Caption(_("Editor ToolBar")).
- ToolbarPane().Top().Position(1).
- LeftDockable(False).RightDockable(False))
-
- else:
- self.EditorToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER,
- ID_PLCOPENEDITOREDITORTOOLBAR, 'EditorToolBar')
- self.EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
- self.EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
- wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
- self.EditorToolBar.Realize()
+ MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
+ wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
+ MenuToolBar.SetToolBitmapSize(wx.Size(25, 25))
+ MenuToolBar.Realize()
+ self.Panes["MenuToolBar"] = MenuToolBar
+ self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo().
+ Name("MenuToolBar").Caption(_("Menu ToolBar")).
+ ToolbarPane().Top().
+ LeftDockable(False).RightDockable(False))
+
+ EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
+ wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
+ EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
+ EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
+ wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
+ EditorToolBar.Realize()
+ self.Panes["EditorToolBar"] = EditorToolBar
+ self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo().
+ Name("EditorToolBar").Caption(_("Editor ToolBar")).
+ ToolbarPane().Top().Position(1).
+ LeftDockable(False).RightDockable(False))
self.Bind(wx.EVT_MENU, self.OnSelectionTool,
id=ID_PLCOPENEDITOREDITORTOOLBARSELECTION)
@@ -750,8 +683,7 @@
self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger"))
self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"])
- if USE_AUI:
- self.AUIManager.Update()
+ self.AUIManager.Update()
## Constructor of the PLCOpenEditor class.
# @param parent The parent window.
@@ -813,8 +745,7 @@
self.Highlights = {}
self.DrawingMode = FREEDRAWING_MODE
#self.DrawingMode = DRIVENDRAWING_MODE
- if USE_AUI:
- self.AuiTabCtrl = []
+ self.AuiTabCtrl = []
self.DefaultPerspective = None
# Initialize Printing configuring elements
@@ -962,7 +893,7 @@
wx.CallAfter(notebook.SetSelection, selected)
def ResetPerspective(self):
- if USE_AUI and self.DefaultPerspective is not None:
+ if self.DefaultPerspective is not None:
self.AUIManager.LoadPerspective(self.DefaultPerspective["perspective"])
for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]:
@@ -987,36 +918,35 @@
self.SetClientSize(frame_size)
def RestoreLastOrganization(self):
- if USE_AUI:
- notebooks = {}
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- notebooks[entry_name] = self.SaveTabOrganization(notebook)
- self.DefaultPerspective = {
- "perspective": self.AUIManager.SavePerspective(),
- "notebooks": notebooks,
- }
-
- try:
- if self.Config.HasEntry("perspective"):
- self.AUIManager.LoadPerspective(str(self.Config.Read("perspective")))
-
- if self.Config.HasEntry("notebooks"):
- notebooks = cPickle.loads(str(self.Config.Read("notebooks")))
-
- for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]:
- for idx in xrange(notebook.GetPageCount()):
- notebook.RemovePage(0)
-
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- self.LoadTabOrganization(notebook, notebooks.get(entry_name))
- except:
- self.ResetPerspective()
-
- self.LoadProjectOrganization()
+ notebooks = {}
+ for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
+ (self.BottomNoteBook, "bottomnotebook"),
+ (self.RightNoteBook, "rightnotebook")]:
+ notebooks[entry_name] = self.SaveTabOrganization(notebook)
+ self.DefaultPerspective = {
+ "perspective": self.AUIManager.SavePerspective(),
+ "notebooks": notebooks,
+ }
+
+ try:
+ if self.Config.HasEntry("perspective"):
+ self.AUIManager.LoadPerspective(str(self.Config.Read("perspective")))
+
+ if self.Config.HasEntry("notebooks"):
+ notebooks = cPickle.loads(str(self.Config.Read("notebooks")))
+
+ for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]:
+ for idx in xrange(notebook.GetPageCount()):
+ notebook.RemovePage(0)
+
+ for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
+ (self.BottomNoteBook, "bottomnotebook"),
+ (self.RightNoteBook, "rightnotebook")]:
+ self.LoadTabOrganization(notebook, notebooks.get(entry_name))
+ except:
+ self.ResetPerspective()
+
+ self.LoadProjectOrganization()
def SaveLastState(self):
if not self.IsMaximized():
@@ -1024,17 +954,16 @@
elif self.Config.HasEntry("framesize"):
self.Config.DeleteEntry("framesize")
- if USE_AUI:
- notebooks = {}
- for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
- (self.BottomNoteBook, "bottomnotebook"),
- (self.RightNoteBook, "rightnotebook")]:
- notebooks[entry_name] = self.SaveTabOrganization(notebook)
- self.Config.Write("notebooks", cPickle.dumps(notebooks))
-
- self.Config.Write("perspective", self.AUIManager.SavePerspective())
-
- self.SaveProjectOrganization()
+ notebooks = {}
+ for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"),
+ (self.BottomNoteBook, "bottomnotebook"),
+ (self.RightNoteBook, "rightnotebook")]:
+ notebooks[entry_name] = self.SaveTabOrganization(notebook)
+ self.Config.Write("notebooks", cPickle.dumps(notebooks))
+
+ self.Config.Write("perspective", self.AUIManager.SavePerspective())
+
+ self.SaveProjectOrganization()
for i in xrange(self.TabsOpened.GetPageCount()):
self.SavePageState(self.TabsOpened.GetPage(i))
@@ -1042,7 +971,7 @@
self.Config.Flush()
def SaveProjectOrganization(self):
- if USE_AUI and self.Controler is not None:
+ if self.Controler is not None:
tabs = []
projects = {}
@@ -1061,7 +990,7 @@
self.Config.Flush()
def LoadProjectOrganization(self):
- if USE_AUI and self.Controler is not None:
+ if self.Controler is not None:
project = self.GetProjectConfiguration()
try:
@@ -1170,10 +1099,7 @@
index = self.TabsImageListIndexes.get((icon1_name, icon2_name), None)
# Return index or bitmap if found
if index is not None:
- if USE_AUI:
- return self.TabsImageList.GetBitmap(index)
- else:
- return index
+ return self.TabsImageList.GetBitmap(index)
if icon2_name is None:
# Bitmap with only one icon
bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
@@ -1198,10 +1124,7 @@
index = self.TabsImageList.Add(bitmap)
# Save bitmap index in ImageList in dictionary
self.TabsImageListIndexes[(icon1_name, icon2_name)] = index
- if USE_AUI:
- return bitmap
- else:
- return index
+ return bitmap
## Function that add a tab in Notebook, calling refresh for tab DClick event
# for wx.aui.AUINotebook.
@@ -1225,11 +1148,8 @@
## Function that fix difference in deleting all tabs between
# wx.Notebook and wx.aui.AUINotebook.
def DeleteAllPages(self):
- if USE_AUI:
- for idx in xrange(self.TabsOpened.GetPageCount()):
- self.TabsOpened.DeletePage(0)
- else:
- self.TabsOpened.DeleteAllPages()
+ for idx in xrange(self.TabsOpened.GetPageCount()):
+ self.TabsOpened.DeletePage(0)
self.RefreshTabCtrlEvent()
## Function that fix difference in setting picture on tab between
@@ -1238,10 +1158,7 @@
# @param bitmap wx.Bitmap to define on tab.
# @return True if operation succeeded
def SetPageBitmap(self, idx, bitmap):
- if USE_AUI:
- return self.TabsOpened.SetPageBitmap(idx, bitmap)
- else:
- return self.TabsOpened.SetPageImage(idx, bitmap)
+ return self.TabsOpened.SetPageBitmap(idx, bitmap)
#-------------------------------------------------------------------------------
# Dialog Message Functions
@@ -1554,19 +1471,18 @@
event.Allow()
def RefreshTabCtrlEvent(self):
- if USE_AUI:
- auitabctrl = []
- for child in self.TabsOpened.GetChildren():
- if isinstance(child, wx.aui.AuiTabCtrl):
- auitabctrl.append(child)
- if child not in self.AuiTabCtrl:
- child.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(child))
- self.AuiTabCtrl = auitabctrl
- if self.TabsOpened.GetPageCount() == 0:
- pane = self.AUIManager.GetPane(self.TabsOpened)
- if pane.IsMaximized():
- self.AUIManager.RestorePane(pane)
- self.AUIManager.Update()
+ auitabctrl = []
+ for child in self.TabsOpened.GetChildren():
+ if isinstance(child, wx.aui.AuiTabCtrl):
+ auitabctrl.append(child)
+ if child not in self.AuiTabCtrl:
+ child.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(child))
+ self.AuiTabCtrl = auitabctrl
+ if self.TabsOpened.GetPageCount() == 0:
+ pane = self.AUIManager.GetPane(self.TabsOpened)
+ if pane.IsMaximized():
+ self.AUIManager.RestorePane(pane)
+ self.AUIManager.Update()
def OnPouSelectedChanging(self, event):
if not self.Starting:
@@ -1601,15 +1517,12 @@
self.SelectProjectTreeItem(window.GetTagName())
else:
self.PouInstanceVariablesPanel.SetPouType(window.GetTagName(), window.GetInstancePath())
- if USE_AUI:
- for child in self.TabsOpened.GetChildren():
- if isinstance(child, wx.aui.AuiTabCtrl):
- active_page = child.GetActivePage()
- if active_page >= 0:
- window = child.GetWindowFromIdx(active_page)
- window.RefreshView()
- else:
- window.RefreshView()
+ for child in self.TabsOpened.GetChildren():
+ if isinstance(child, wx.aui.AuiTabCtrl):
+ active_page = child.GetActivePage()
+ if active_page >= 0:
+ window = child.GetWindowFromIdx(active_page)
+ window.RefreshView()
self._Refresh(FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR)
def RefreshEditorNames(self, old_tagname, new_tagname):
@@ -2253,14 +2166,10 @@
if callback is not None:
self.Bind(wx.EVT_TOOL, callback, id=id)
MenuToolBar.Realize()
- if USE_AUI:
- self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize())
+ self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize())
def ResetEditorToolBar(self):
- if USE_AUI:
- EditorToolBar = self.Panes["EditorToolBar"]
- else:
- EditorToolBar = self.EditorToolBar
+ EditorToolBar = self.Panes["EditorToolBar"]
for item in self.CurrentEditorToolBar:
if wx.VERSION >= (2, 6, 0):
@@ -2273,9 +2182,8 @@
if EditorToolBar:
EditorToolBar.Realize()
- if USE_AUI:
- self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
- self.AUIManager.Update()
+ self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
+ self.AUIManager.Update()
def RefreshEditorToolBar(self):
selected = self.TabsOpened.GetSelection()
@@ -2290,10 +2198,7 @@
self.ResetEditorToolBar()
self.CurrentMenu = menu
self.CurrentEditorToolBar = []
- if USE_AUI:
- EditorToolBar = self.Panes["EditorToolBar"]
- else:
- EditorToolBar = self.EditorToolBar
+ EditorToolBar = self.Panes["EditorToolBar"]
if EditorToolBar:
for radio, modes, id, method, picture, help in EditorToolBarItems[menu]:
if modes & self.DrawingMode:
@@ -2304,9 +2209,8 @@
self.Bind(wx.EVT_MENU, getattr(self, method), id=id)
self.CurrentEditorToolBar.append(id)
EditorToolBar.Realize()
- if USE_AUI:
- self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
- self.AUIManager.Update()
+ self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
+ self.AUIManager.Update()
elif not menu:
self.ResetEditorToolBar()
self.CurrentMenu = menu
@@ -2322,19 +2226,13 @@
if selected != -1:
window = self.TabsOpened.GetPage(selected)
window.SetMode(MODE_SELECTION)
- if USE_AUI:
- EditorToolBar = self.Panes["EditorToolBar"]
- else:
- EditorToolBar = self.EditorToolBar
+ EditorToolBar = self.Panes["EditorToolBar"]
if EditorToolBar:
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, False)
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, True)
def ResetToolToggle(self, id):
- if USE_AUI:
- tool = self.Panes["EditorToolBar"].FindById(id)
- else:
- tool = self.EditorToolBar.FindById(id)
+ tool = self.Panes["EditorToolBar"].FindById(id)
tool.SetToggle(False)
def OnSelectionTool(self, event):
@@ -2832,8 +2730,7 @@
def OnCloseFrame(self, event):
if self.Controler is None or self.CheckSaveBeforeClosing(_("Close Application")):
- if USE_AUI:
- self.AUIManager.UnInit()
+ self.AUIManager.UnInit()
self.SaveLastState()