Corrections for wx version 2.8.4
authorlbessard
Tue, 18 Sep 2007 18:04:54 +0200
changeset 276 eada6c6c2e87
parent 275 7d5130f2f8ab
child 277 426552c56a5a
Corrections for wx version 2.8.4
objdictgen/commondialogs.py
objdictgen/networkedit.py
objdictgen/objdictedit.py
--- a/objdictgen/commondialogs.py	Tue Sep 18 09:02:38 2007 +0200
+++ b/objdictgen/commondialogs.py	Tue Sep 18 18:04:54 2007 +0200
@@ -572,7 +572,6 @@
             message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR)
             message.ShowModal()
             message.Destroy()
-            self.Name.SetFocus()
         else:
             self.EndModal(wx.ID_OK)
 
@@ -660,7 +659,7 @@
 
     def _init_coll_MainSizer_Items(self, parent):
         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
+        parent.AddWindow(self.NodeName, 0, border=0, flag=wx.GROW)
         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
         parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW)
         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
@@ -693,7 +692,7 @@
               label='Name:', name='staticText1', parent=self,
               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
 
-        self.Name = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='Name',
+        self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName',
               parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
               style=0, value='')
 
@@ -733,7 +732,7 @@
         self.Type.Append("slave")
 
     def OnOK(self, event):
-        name = self.Name.GetValue()
+        name = self.NodeName.GetValue()
         message = ""
         if name != "":
             good = not name[0].isdigit()
@@ -750,18 +749,18 @@
             message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR)
             message.ShowModal()
             message.Destroy()
-            self.Name.SetFocus()
+            self.NodeName.SetFocus()
         else:
             self.EndModal(wx.ID_OK)
     
     def SetValues(self, name, id, type, description):
-        self.Name.SetValue(name)
+        self.NodeName.SetValue(name)
         self.NodeID.SetValue("0x%02X"%id)
         self.Type.SetStringSelection(type)
         self.Description.SetValue(description)
 
     def GetValues(self):
-        name = self.Name.GetValue()
+        name = self.NodeName.GetValue()
         nodeid = int(self.NodeID.GetValue(), 16)
         type = self.Type.GetStringSelection()
         description = self.Description.GetValue()
@@ -813,7 +812,7 @@
         parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM)
         parent.AddWindow(self.Type, 0, border=10, flag=wx.GROW|wx.BOTTOM)
         parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM)
-        parent.AddWindow(self.Name, 0, border=10, flag=wx.GROW|wx.BOTTOM)
+        parent.AddWindow(self.NodeName, 0, border=10, flag=wx.GROW|wx.BOTTOM)
         parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM)
         parent.AddWindow(self.NodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM)
         parent.AddWindow(self.staticText4, 0, border=5, flag=wx.GROW|wx.BOTTOM)
@@ -899,7 +898,7 @@
               name='Type', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(0, 25), style=0)
 
-        self.Name = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='Name',
+        self.NodeName = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='NodeName',
               parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
               style=0, value='')
 
@@ -1002,10 +1001,10 @@
                 self.Profile.Append(name)
         self.Profile.Append("Other")
         self.Profile.SetStringSelection("None")
-        self.Name.SetFocus()
+        self.NodeName.SetFocus()
         
     def OnOK(self, event):
-        name = self.Name.GetValue()
+        name = self.NodeName.GetValue()
         message = ""
         if name != "":
             good = not name[0].isdigit()
@@ -1022,12 +1021,12 @@
             message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR)
             message.ShowModal()
             message.Destroy()
-            self.Name.SetFocus()
+            self.NodeName.SetFocus()
         else:
             self.EndModal(wx.ID_OK)
 
     def GetValues(self):
-        name = self.Name.GetValue()
+        name = self.NodeName.GetValue()
         nodeid = 0
         if self.NodeID.GetValue() != "":
             nodeid = int(self.NodeID.GetValue(), 16)
--- a/objdictgen/networkedit.py	Tue Sep 18 09:02:38 2007 +0200
+++ b/objdictgen/networkedit.py	Tue Sep 18 18:04:54 2007 +0200
@@ -35,32 +35,6 @@
 from commondialogs import *
 from doc_index.DS301_index import *
 
-def create(parent):
-    return networkedit(parent)
-
-def usage():
-    print "\nUsage of networkedit.py :"
-    print "\n   %s [Projectpath]\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()
-
-if len(args) == 0:
-    projectOpen = None 
-elif len(args) == 1:
-    projectOpen = args[0]
-else:
-    usage()
-    sys.exit(2)
 ScriptDirectory = os.path.split(__file__)[0]
 
 try:
@@ -336,7 +310,7 @@
         self._init_coll_HelpBar_Fields(self.HelpBar)
         self.SetStatusBar(self.HelpBar)
 
-    def __init__(self, parent, nodelist = None):
+    def __init__(self, parent, nodelist = None, projectOpen = None):
         self.ModeSolo = nodelist == None
         self._init_ctrls(parent)
         self.HtmlFrameOpened = []
@@ -430,7 +404,7 @@
     def OnNodeSelectedChanged(self, event):
         selected = event.GetSelection()
         # At init selected = -1
-        if selected > 0:
+        if selected >= 0:
             window = self.NetworkNodes.GetPage(selected)
             self.NodeList.SetCurrentSelected(window.GetIndex())
         self.RefreshMainMenu()
@@ -614,8 +588,9 @@
                 self.NetworkNodes.AddPage(new_editingpanel, "")
 
     def RefreshStatusBar(self):
-        if self.HelpBar:
-            window = self.NetworkNodes.GetPage(self.NetworkNodes.GetSelection())
+        selected = self.NetworkNodes.GetSelection()
+        if self.HelpBar and selected >= 0:
+            window = self.NetworkNodes.GetPage(selected)
             selection = window.GetSelection()
             if selection:
                 index, subIndex = selection
@@ -987,13 +962,37 @@
     sys.excepthook = handle_exception
 
 if __name__ == '__main__':
+    def usage():
+        print "\nUsage of networkedit.py :"
+        print "\n   %s [Projectpath]\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()
+
+    if len(args) == 0:
+        projectOpen = None 
+    elif len(args) == 1:
+        projectOpen = args[0]
+    else:
+        usage()
+        sys.exit(2)
+    
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     
     # Install a exception handle for bug reports
     AddExceptHook(os.getcwd(),__version__)
     
-    frame = networkedit(None)
+    frame = networkedit(None, projectOpen=projectOpen)
 
     frame.Show()
     app.MainLoop()
--- a/objdictgen/objdictedit.py	Tue Sep 18 09:02:38 2007 +0200
+++ b/objdictgen/objdictedit.py	Tue Sep 18 18:04:54 2007 +0200
@@ -105,29 +105,8 @@
 except:
     Html_Window = False
 
-def create(parent):
-    return objdictedit(parent)
-
-def usage():
-    print "\nUsage of objdictedit.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()
-
-filesOpen = args
 ScriptDirectory = os.path.split(__file__)[0]
 
-
 [ID_OBJDICTEDIT, ID_OBJDICTEDITFILEOPENED, 
  ID_OBJDICTEDITHELPBAR,
 ] = [wx.NewId() for _init_ctrls in range(3)]
@@ -318,7 +297,7 @@
         self._init_coll_HelpBar_Fields(self.HelpBar)
         self.SetStatusBar(self.HelpBar)
 
-    def __init__(self, parent):
+    def __init__(self, parent, filesOpen = []):
         self._init_ctrls(parent)
         self.HtmlFrameOpened = []
         self.ModeSolo = True
@@ -1009,13 +988,29 @@
     sys.excepthook = handle_exception
 
 if __name__ == '__main__':
+    def usage():
+        print "\nUsage of objdictedit.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()
+    
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     
     # Install a exception handle for bug reports
     AddExceptHook(os.getcwd(),__version__)
     
-    frame = objdictedit(None)
+    frame = objdictedit(None, args)
 
     frame.Show()
     app.MainLoop()