Beremiz.py
changeset 90 f3205d5acdf4
parent 89 0ab2868c6aa6
child 93 d53a02609e5f
equal deleted inserted replaced
89:0ab2868c6aa6 90:f3205d5acdf4
   517                 psizer = wx.BoxSizer(wx.HORIZONTAL)
   517                 psizer = wx.BoxSizer(wx.HORIZONTAL)
   518                 self.RefreshSizerElement(window, psizer, plugin_infos, None, True, root)
   518                 self.RefreshSizerElement(window, psizer, plugin_infos, None, True, root)
   519 
   519 
   520                 msizer = wx.BoxSizer(wx.VERTICAL)
   520                 msizer = wx.BoxSizer(wx.VERTICAL)
   521                 msizer.AddSizer(bsizer, 0, border=0, flag=wx.GROW)
   521                 msizer.AddSizer(bsizer, 0, border=0, flag=wx.GROW)
   522                 if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0:
   522                 if len(plugin.PluginMethods) > 0: #and plugin != self.PluginRoot 
   523                     for plugin_method in plugin.PluginMethods:
   523                     for plugin_method in plugin.PluginMethods:
   524                         if "method" in plugin_method:
   524                         if "method" in plugin_method:
   525                             id = wx.NewId()
   525                             id = wx.NewId()
   526                             button = wx.lib.buttons.GenBitmapTextButton(id=id, parent=window, 
   526                             button = wx.lib.buttons.GenBitmapTextButton(id=id, parent=window,
   527                                 bitmap=wx.Bitmap(os.path.join(CWD, "%s24x24.png"%plugin_method.get("bitmap", os.path.join("images", "RunMethod")))), label=plugin_method["name"], 
   527                                 bitmap=wx.Bitmap(os.path.join(CWD, "%s24x24.png"%plugin_method.get("bitmap", os.path.join("images", "RunMethod")))), label=plugin_method["name"], 
   528                                 name=plugin_method["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER)
   528                                 name=plugin_method["name"], pos=wx.DefaultPosition, style=wx.NO_BORDER)
   529                             button.SetToolTipString(plugin_method["tooltip"])
   529                             button.SetToolTipString(plugin_method["tooltip"])
   530                             button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id)
   530                             button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id)
   531                             msizer.AddWindow(button, 0, border=5, flag=wx.RIGHT)
   531                             #hack to force size to mini
       
   532                             gen_mini_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenBitmapTextButton._GetLabelSize(obj)[:-1] + (False,))
       
   533                             button._GetLabelSize = gen_mini_GetLabelSize(button)  
       
   534                             #button._GetLabelSize = lambda :(-1,-1,False)
       
   535                             msizer.AddWindow(button, 0, border=5, flag=0)
   532                 tcsizer.AddSizer(msizer, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
   536                 tcsizer.AddSizer(msizer, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
   533                 tcsizer.AddSizer(psizer, 0, border=0, flag=wx.GROW)
   537                 tcsizer.AddSizer(psizer, 0, border=0, flag=wx.GROW)
   534                 if plugin == self.PluginRoot:
   538                 if plugin == self.PluginRoot:
   535                     tcsizer.AddGrowableCol(0)
   539                     tcsizer.AddGrowableCol(0)
   536                 else:
   540                 else:
   542             if "enabled" in infos:
   546             if "enabled" in infos:
   543                 self.PluginTree.CheckItem(root, infos["enabled"])
   547                 self.PluginTree.CheckItem(root, infos["enabled"])
   544                 self.PluginTree.SetItemWindowEnabled(root, infos["enabled"])
   548                 self.PluginTree.SetItemWindowEnabled(root, infos["enabled"])
   545 
   549 
   546         item, root_cookie = self.PluginTree.GetFirstChild(root)
   550         item, root_cookie = self.PluginTree.GetFirstChild(root)
   547         for values in infos["values"]:
   551         for values in infos["values"]:    
   548             if item is None or not item.IsOk():
   552             if item is None or not item.IsOk():
   549                 item = self.PluginTree.AppendItem(root, "")
   553                 item = self.PluginTree.AppendItem(root, "")
   550                 # 2.6.x returns bad item on gtk
   554                 # 2.6.x returns bad item on gtk
   551                 if wx.Platform != '__WXMSW__' or wx.VERSION >= (2, 8, 0):
   555                 if wx.Platform != '__WXMSW__' or wx.VERSION >= (2, 8, 0):
   552                     item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   556                     item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   571 
   575 
   572     def ResizePluginTreeWindow(self):
   576     def ResizePluginTreeWindow(self):
   573         if getattr(self, "PluginRoot", None):
   577         if getattr(self, "PluginRoot", None):
   574             root = self.PluginTree.GetRootItem()
   578             root = self.PluginTree.GetRootItem()
   575             if root is not None and root.IsOk():
   579             if root is not None and root.IsOk():
   576                 self.ResizePluginTreeWindow_r(root)
   580                 #sz = self.PluginTree.GetClientSize()
       
   581                 #sz = self.PluginTree.GetBestSize()
       
   582                 minimalsz = wx.Size(-1,-1)
       
   583                 itemswindows = self.ResizePluginTreeWindow_r(root, minimalsz)
       
   584                 for window, posx in itemswindows:
       
   585                     window.SetSize(wx.Size(minimalsz.x - posx, -1))
       
   586                     
   577             self.MustRecalTreeSizes = False
   587             self.MustRecalTreeSizes = False
   578 
   588 
   579     def ResizePluginTreeWindow_r(self, root):
   589     def ResizePluginTreeWindow_r(self, root, sz):
   580         window = self.PluginTree.GetItemWindow(root)
   590         window = self.PluginTree.GetItemWindow(root)
   581         pos = window.GetPosition()
   591         posx = window.GetPosition().x
   582         sz = self.PluginTree.GetClientSize()
   592         res = [(window,posx)]
   583         window.SetSize(wx.Size(sz.width - pos.x, -1))
   593         bestsz = window.GetBestSize()
       
   594         sz.x = max(sz.x, bestsz.x + posx)
   584         item, root_cookie = self.PluginTree.GetFirstChild(root)
   595         item, root_cookie = self.PluginTree.GetFirstChild(root)
   585         while item is not None and item.IsOk():
   596         while item is not None and item.IsOk():
   586             self.ResizePluginTreeWindow_r(item)
   597             res.extend(self.ResizePluginTreeWindow_r(item, sz))
   587             item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   598             item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie)
   588         
   599         return res
   589 
   600 
   590 
   601 
   591     def GetSelectedPluginName(self, selected = None):
   602     def GetSelectedPluginName(self, selected = None):
   592         if selected is None:
   603         if selected is None:
   593             selected = self.PluginTree.GetSelection()
   604             selected = self.PluginTree.GetSelection()
   699     
   710     
   700     def RefreshPluginToolBar(self):
   711     def RefreshPluginToolBar(self):
   701         if wx.VERSION < (2, 8, 0):
   712         if wx.VERSION < (2, 8, 0):
   702             self.ClearSizer(self.MenuSizer)
   713             self.ClearSizer(self.MenuSizer)
   703         else:
   714         else:
       
   715             # toolbar temporarely disabled.
       
   716             return
   704             if "ToolBar" in self.Panes:
   717             if "ToolBar" in self.Panes:
   705                 self.AUIManager.DetachPane(self.Panes["ToolBar"])
   718                 self.AUIManager.DetachPane(self.Panes["ToolBar"])
   706                 self.Panes["ToolBar"].Destroy()
   719                 self.Panes["ToolBar"].Destroy()
   707         if self.PluginRoot.HasOpenedProject() and len(self.PluginRoot.PluginMethods) > 0:
   720         if self.PluginRoot.HasOpenedProject() and len(self.PluginRoot.PluginMethods) > 0:
   708             if wx.VERSION > (2, 8, 0):
   721             if wx.VERSION > (2, 8, 0):