--- a/PLCOpenEditor.py Thu Sep 13 09:46:51 2007 +0200
+++ b/PLCOpenEditor.py Mon Sep 17 10:13:56 2007 +0200
@@ -39,31 +39,6 @@
__version__ = "$Revision$"
-def create(parent):
- return PLCOpenEditor(parent)
-
-def usage():
- print "\nUsage of PLCOpenEditor.py :"
- print "\n %s [Filepath]\n"%sys.argv[0]
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
-except getopt.GetoptError:
- # print help information and exit:
- usage()
- sys.exit(2)
-
-for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
-
-fileOpen = None
-if len(args) > 1:
- usage()
- sys.exit()
-elif len(args) == 1:
- fileOpen = args[0]
CWD = os.path.split(__file__)[0]
[ID_PLCOPENEDITOR, ID_PLCOPENEDITORPROJECTTREE,
@@ -345,18 +320,19 @@
self._init_utils()
self.SetClientSize(wx.Size(1000, 600))
self.SetMenuBar(self.menuBar1)
- self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_PLCOPENEDITOR)
+ self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
if not self.ModeSolo:
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=ID_PLCOPENEDITORFILEMENUITEMS5)
accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, ID_PLCOPENEDITORFILEMENUITEMS5)])
self.SetAcceleratorTable(accel)
+ self.Bind(wx.EVT_ACTIVATE, self.OnFrameActivated)
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.EditorPanel = wx.Panel(id=ID_PLCOPENEDITOREDITORPANEL,
name='TabPanel', parent=self.MainSplitter, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
@@ -395,7 +371,7 @@
self._init_sizers()
- def __init__(self, parent, controler = None):
+ def __init__(self, parent, controler = None, fileOpen = None):
self.ModeSolo = controler == None
self._init_ctrls(parent)
@@ -406,13 +382,12 @@
if self.ModeSolo:
self.Controler = PLCControler()
+ if fileOpen:
+ self.Controler.OpenXMLFile(fileOpen)
+ self.RefreshProjectTree()
else:
self.Controler = controler
- if self.ModeSolo and fileOpen:
- self.Controler.OpenXMLFile(fileOpen)
- self.RefreshProjectTree()
-
self.CurrentToolBar = []
self.CurrentLanguage = ""
self.DrawingMode = FREEDRAWING_MODE
@@ -499,6 +474,14 @@
self.RefreshProjectTree()
dialog.Destroy()
+ def OnFrameActivated(self, event):
+ if not self.ModeSolo and event.GetActive():
+ self.Controler.RefreshPluginsBlockLists()
+ selected = self.TabsOpened.GetSelection()
+ if selected >= 0:
+ self.TabsOpened.GetPage(selected).RefreshView()
+ event.Skip()
+
def OnCloseFrame(self, event):
if not self.ModeSolo and getattr(self, "_onclose", None) != None:
self._onclose()
@@ -2806,13 +2789,36 @@
sys.excepthook = handle_exception
if __name__ == '__main__':
+ def usage():
+ print "\nUsage of PLCOpenEditor.py :"
+ print "\n %s [Filepath]\n"%sys.argv[0]
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
+ except getopt.GetoptError:
+ # print help information and exit:
+ usage()
+ sys.exit(2)
+
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+
+ fileOpen = None
+ if len(args) > 1:
+ usage()
+ sys.exit()
+ elif len(args) == 1:
+ fileOpen = args[0]
+
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
# Install a exception handle for bug reports
AddExceptHook(os.getcwd(),__version__)
- frame = PLCOpenEditor(None)
+ frame = PLCOpenEditor(None, fileOpen=fileOpen)
frame.Show()
app.MainLoop()