Beremiz.py
changeset 46 6f2689a2438b
parent 42 2bff00eb6cd0
child 48 6b30cfee163e
equal deleted inserted replaced
45:00acf2162135 46:6f2689a2438b
    63     def isatty(self):
    63     def isatty(self):
    64         return false
    64         return false
    65 
    65 
    66     def LogCommand(self, Command, sz_limit = 100):
    66     def LogCommand(self, Command, sz_limit = 100):
    67 
    67 
    68         import os, popen2, fcntl, select, signal
    68         import os, popen2, select, signal
    69         
    69         
    70         child = popen2.Popen3(Command, 1) # capture stdout and stderr from command
    70         child = popen2.Popen3(Command, 1) # capture stdout and stderr from command
    71         child.tochild.close()             # don't need to talk to child
    71         child.tochild.close()             # don't need to talk to child
    72         outfile = child.fromchild 
    72         outfile = child.fromchild 
    73         outfd = outfile.fileno()
    73         outfd = outfile.fileno()
   321         self.PluginRoot = PluginsRoot(self)
   321         self.PluginRoot = PluginsRoot(self)
   322         
   322         
   323         if projectOpen:
   323         if projectOpen:
   324             self.PluginRoot.LoadProject(projectOpen, self.Log)
   324             self.PluginRoot.LoadProject(projectOpen, self.Log)
   325             self.RefreshPluginTree()
   325             self.RefreshPluginTree()
       
   326             self.PluginTree.SelectItem(self.PluginTree.GetRoot())
   326         
   327         
   327         self.RefreshPluginParams()
   328         self.RefreshPluginParams()
   328         self.RefreshButtons()
   329         self.RefreshButtons()
   329         self.RefreshMainMenu()
   330         self.RefreshMainMenu()
   330         
   331         
   359         if not root.IsOk():
   360         if not root.IsOk():
   360             root = self.PluginTree.AddRoot(infos["name"])
   361             root = self.PluginTree.AddRoot(infos["name"])
   361         last_selected = self.GetSelectedPluginName()
   362         last_selected = self.GetSelectedPluginName()
   362         self.GenerateTreeBranch(root, infos, True)
   363         self.GenerateTreeBranch(root, infos, True)
   363         self.PluginTree.Expand(self.PluginTree.GetRootItem())
   364         self.PluginTree.Expand(self.PluginTree.GetRootItem())
   364         self.SelectedPluginByName(root,last_selected)
   365         self.SelectedPluginByName(root, last_selected)
   365         self.RefreshPluginParams()
   366         self.RefreshPluginParams()
   366 
   367 
   367     def SelectedPluginByName(self, root, name):
   368     def SelectedPluginByName(self, root, name):
   368         toks = name.split('.',1)
   369         if name:
   369         item, root_cookie = self.PluginTree.GetFirstChild(root)
   370             toks = name.split('.',1)
   370         while item.IsOk():
   371             item, root_cookie = self.PluginTree.GetFirstChild(root)
   371             if self.PluginTree.GetPyData(item) == toks[0]:
   372             while item.IsOk():
   372                 if len(toks)>1:
   373                 if self.PluginTree.GetPyData(item) == toks[0]:
   373                     return self.SelectedPluginByName(item, toks[1])
   374                     if len(toks)>1:
   374                 else:
   375                         return self.SelectedPluginByName(item, toks[1])
   375                     self.PluginTree.SelectItem(item, True)
   376                     else:
   376                     return True
   377                         self.PluginTree.SelectItem(item, True)
   377             item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   378                         return True
       
   379                 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   378         return False
   380         return False
   379 
   381 
   380     def GenerateTreeBranch(self, root, infos, first = False):
   382     def GenerateTreeBranch(self, root, infos, first = False):
   381         to_delete = []
   383         to_delete = []
   382         self.PluginTree.SetItemText(root, infos["name"])
   384         self.PluginTree.SetItemText(root, infos["name"])
   710             projectpath = dialog.GetPath()
   712             projectpath = dialog.GetPath()
   711             if os.path.isdir(projectpath):
   713             if os.path.isdir(projectpath):
   712                 result = self.PluginRoot.LoadProject(projectpath, self.Log)
   714                 result = self.PluginRoot.LoadProject(projectpath, self.Log)
   713                 if not result:
   715                 if not result:
   714                     self.RefreshPluginTree()
   716                     self.RefreshPluginTree()
       
   717                     self.PluginTree.SelectItem(self.PluginTree.GetRootItem())
   715                     self.RefreshButtons()
   718                     self.RefreshButtons()
   716                     self.RefreshMainMenu()
   719                     self.RefreshMainMenu()
   717                 else:
   720                 else:
   718                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   721                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   719                     message.ShowModal()
   722                     message.ShowModal()