Corrections for Windows
authorlbessard
Tue, 18 Sep 2007 18:04:07 +0200
changeset 46 6f2689a2438b
parent 45 00acf2162135
child 47 fd45c291fed0
Corrections for Windows
Beremiz.py
--- a/Beremiz.py	Mon Sep 17 18:04:13 2007 +0200
+++ b/Beremiz.py	Tue Sep 18 18:04:07 2007 +0200
@@ -65,7 +65,7 @@
 
     def LogCommand(self, Command, sz_limit = 100):
 
-        import os, popen2, fcntl, select, signal
+        import os, popen2, select, signal
         
         child = popen2.Popen3(Command, 1) # capture stdout and stderr from command
         child.tochild.close()             # don't need to talk to child
@@ -323,6 +323,7 @@
         if projectOpen:
             self.PluginRoot.LoadProject(projectOpen, self.Log)
             self.RefreshPluginTree()
+            self.PluginTree.SelectItem(self.PluginTree.GetRoot())
         
         self.RefreshPluginParams()
         self.RefreshButtons()
@@ -361,20 +362,21 @@
         last_selected = self.GetSelectedPluginName()
         self.GenerateTreeBranch(root, infos, True)
         self.PluginTree.Expand(self.PluginTree.GetRootItem())
-        self.SelectedPluginByName(root,last_selected)
+        self.SelectedPluginByName(root, last_selected)
         self.RefreshPluginParams()
 
     def SelectedPluginByName(self, root, name):
-        toks = name.split('.',1)
-        item, root_cookie = self.PluginTree.GetFirstChild(root)
-        while item.IsOk():
-            if self.PluginTree.GetPyData(item) == toks[0]:
-                if len(toks)>1:
-                    return self.SelectedPluginByName(item, toks[1])
-                else:
-                    self.PluginTree.SelectItem(item, True)
-                    return True
-            item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
+        if name:
+            toks = name.split('.',1)
+            item, root_cookie = self.PluginTree.GetFirstChild(root)
+            while item.IsOk():
+                if self.PluginTree.GetPyData(item) == toks[0]:
+                    if len(toks)>1:
+                        return self.SelectedPluginByName(item, toks[1])
+                    else:
+                        self.PluginTree.SelectItem(item, True)
+                        return True
+                item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
         return False
 
     def GenerateTreeBranch(self, root, infos, first = False):
@@ -712,6 +714,7 @@
                 result = self.PluginRoot.LoadProject(projectpath, self.Log)
                 if not result:
                     self.RefreshPluginTree()
+                    self.PluginTree.SelectItem(self.PluginTree.GetRootItem())
                     self.RefreshButtons()
                     self.RefreshMainMenu()
                 else: