Beremiz.py
changeset 25 fa7503684c28
parent 24 585d5b387b6a
child 28 848ce4b1f9e4
equal deleted inserted replaced
24:585d5b387b6a 25:fa7503684c28
    29 import types
    29 import types
    30 
    30 
    31 import os, re, platform, sys, time, traceback, getopt, commands
    31 import os, re, platform, sys, time, traceback, getopt, commands
    32 
    32 
    33 from plugger import PluginsRoot
    33 from plugger import PluginsRoot
    34 
       
    35 def CHECK_WX_VERSION(major, minor, release):
       
    36     return not (wx.MAJOR_VERSION < major or wx.MINOR_VERSION < minor or wx.RELEASE_NUMBER < release)
       
    37 
    34 
    38 class LogPseudoFile:
    35 class LogPseudoFile:
    39     """ Base class for file like objects to facilitate StdOut for the Shell."""
    36     """ Base class for file like objects to facilitate StdOut for the Shell."""
    40     def __init__(self, output = None):
    37     def __init__(self, output = None):
    41         self.red_white = wx.TextAttr("RED", "WHITE")
    38         self.red_white = wx.TextAttr("RED", "WHITE")
   253         self.ParamsPanel.SetSizer(self.ParamsPanelMainSizer)
   250         self.ParamsPanel.SetSizer(self.ParamsPanelMainSizer)
   254     
   251     
   255     def _init_ctrls(self, prnt):
   252     def _init_ctrls(self, prnt):
   256         wx.Frame.__init__(self, id=ID_BEREMIZ, name=u'Beremiz',
   253         wx.Frame.__init__(self, id=ID_BEREMIZ, name=u'Beremiz',
   257               parent=prnt, pos=wx.Point(0, 0), size=wx.Size(1000, 600),
   254               parent=prnt, pos=wx.Point(0, 0), size=wx.Size(1000, 600),
   258               style=wx.DEFAULT_FRAME_STYLE, title=u'Beremiz')
   255               style=wx.DEFAULT_FRAME_STYLE|wx.CLIP_CHILDREN, title=u'Beremiz')
   259         self._init_utils()
   256         self._init_utils()
   260         self.SetClientSize(wx.Size(1000, 600))
   257         self.SetClientSize(wx.Size(1000, 600))
   261         self.SetMenuBar(self.menuBar1)
   258         self.SetMenuBar(self.menuBar1)
   262         
   259         
   263         self.MainSplitter = wx.SplitterWindow(id=ID_BEREMIZMAINSPLITTER,
   260         self.MainSplitter = wx.SplitterWindow(id=ID_BEREMIZMAINSPLITTER,
   438             self.DeleteButton.Enable(False)
   435             self.DeleteButton.Enable(False)
   439         else:
   436         else:
   440             # Refresh ParamsPanel
   437             # Refresh ParamsPanel
   441             self.ParamsPanel.Show()
   438             self.ParamsPanel.Show()
   442             infos = plugin.GetParamsAttributes()
   439             infos = plugin.GetParamsAttributes()
   443             self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None)
   440             if wx.VERSION >= (2, 7, 0):
   444             if len(plugin.PluginMethods) > 0:
   441                 self.ParamsPanelMainSizer.Clear(True)
       
   442             else:
       
   443                 self.ClearSizer(self.ParamsPanelMainSizer)
       
   444             if len(self.PluginRoot.PluginMethods) > 0:
       
   445                 boxsizer = wx.BoxSizer(wx.HORIZONTAL)
       
   446                 self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
       
   447                 for name, method in self.PluginRoot.PluginMethods:
       
   448                     if method:
       
   449                         id = wx.NewId()
       
   450                         button = wx.Button(id=id, label=name, name=name, parent=self.ParamsPanel, 
       
   451                             pos=wx.Point(0, 0), style=wx.BU_EXACTFIT)
       
   452                         button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, method), id=id)
       
   453                         boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT)
       
   454             self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None, False)
       
   455             if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0:
   445                 boxsizer = wx.BoxSizer(wx.HORIZONTAL)
   456                 boxsizer = wx.BoxSizer(wx.HORIZONTAL)
   446                 self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
   457                 self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
   447                 for name, method in plugin.PluginMethods:
   458                 for name, method in plugin.PluginMethods:
   448                     if method:
   459                     if method:
   449                         id = wx.NewId()
   460                         id = wx.NewId()
   522                     staticboxes.append(item_sizer.GetStaticBox())
   533                     staticboxes.append(item_sizer.GetStaticBox())
   523         sizer.Clear(True)
   534         sizer.Clear(True)
   524         for staticbox in staticboxes:
   535         for staticbox in staticboxes:
   525             staticbox.Destroy()
   536             staticbox.Destroy()
   526                 
   537                 
   527     def RefreshSizerElement(self, sizer, elements, path):
   538     def RefreshSizerElement(self, sizer, elements, path, clean = True):
   528         if wx.VERSION >= (2, 7, 0):
   539         if clean:
   529             sizer.Clear(True)
   540             if wx.VERSION >= (2, 7, 0):
   530         else:
   541                 sizer.Clear(True)
   531             self.ClearSizer(sizer)
   542             else:
       
   543                 self.ClearSizer(sizer)
   532         first = True
   544         first = True
   533         for element_infos in elements:
   545         for element_infos in elements:
   534             if path:
   546             if path:
   535                 element_path = "%s.%s"%(path, element_infos["name"])
   547                 element_path = "%s.%s"%(path, element_infos["name"])
   536             else:
   548             else: