Beremiz.py
changeset 129 ec54cd416528
parent 127 36bb6be88a3b
child 133 d85b937cdac3
equal deleted inserted replaced
128:3db703a78e9c 129:ec54cd416528
   449             plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
   449             plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
   450             if self.PluginRoot.PlugTestModified():
   450             if self.PluginRoot.PlugTestModified():
   451                 bkgdclr = CHANGED_TITLE_COLOUR
   451                 bkgdclr = CHANGED_TITLE_COLOUR
   452             else:
   452             else:
   453                 bkgdclr = TITLE_COLOUR
   453                 bkgdclr = TITLE_COLOUR
       
   454                 
       
   455             if self.PluginRoot not in self.PluginInfos:
       
   456                 self.PluginInfos[self.PluginRoot] = {"middle_visible" : False}
       
   457             
   454             plcwindow.SetBackgroundColour(TITLE_COLOUR)
   458             plcwindow.SetBackgroundColour(TITLE_COLOUR)
   455             self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW)
   459             self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW)
   456             
   460             
   457             plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
   461             plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
   458             plcwindow.SetSizer(plcwindowsizer)
   462             plcwindow.SetSizer(plcwindowsizer)
   474             plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL)
   478             plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL)
   475             
   479             
   476             plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
   480             plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
   477             plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
   481             plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
   478             
   482             
   479             msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow)
   483             msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["middle_visible"])
   480             plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
   484             plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
   481             
   485             
   482             paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1))
   486             paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1))
   483             paramswindow.SetBackgroundColour(TITLE_COLOUR)
   487             paramswindow.SetBackgroundColour(TITLE_COLOUR)
   484             plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0)
   488             plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0)
   487             paramswindow.SetSizer(psizer)
   491             paramswindow.SetSizer(psizer)
   488             
   492             
   489             plugin_infos = self.PluginRoot.GetParamsAttributes()
   493             plugin_infos = self.PluginRoot.GetParamsAttributes()
   490             self.RefreshSizerElement(paramswindow, psizer, self.PluginRoot, plugin_infos, None, False)
   494             self.RefreshSizerElement(paramswindow, psizer, self.PluginRoot, plugin_infos, None, False)
   491             
   495             
   492             paramswindow.Hide()
   496             if not self.PluginInfos[self.PluginRoot]["middle_visible"]:
       
   497                 paramswindow.Hide()
   493             
   498             
   494             minimizebutton_id = wx.NewId()
   499             minimizebutton_id = wx.NewId()
   495             minimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=minimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Maximize.png')),
   500             minimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=minimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Maximize.png')),
   496                   name='MinimizeButton', parent=plcwindow, pos=wx.Point(0, 0),
   501                   name='MinimizeButton', parent=plcwindow, pos=wx.Point(0, 0),
   497                   size=wx.Size(24, 24), style=wx.NO_BORDER)
   502                   size=wx.Size(24, 24), style=wx.NO_BORDER)
   514                 else:
   519                 else:
   515                     paramswindow.Hide()
   520                     paramswindow.Hide()
   516                     msizer.SetCols(len(self.PluginRoot.PluginMethods))
   521                     msizer.SetCols(len(self.PluginRoot.PluginMethods))
   517 #                    if addsizer is not None:
   522 #                    if addsizer is not None:
   518 #                        addsizer.SetCols(len(self.PluginRoot.PlugChildsTypes))
   523 #                        addsizer.SetCols(len(self.PluginRoot.PlugChildsTypes))
       
   524                 self.PluginInfos[self.PluginRoot]["middle_visible"] = minimizebutton.GetToggle()
   519                 self.PLCConfigMainSizer.Layout()
   525                 self.PLCConfigMainSizer.Layout()
   520                 self.RefreshScrollBars()
   526                 self.RefreshScrollBars()
   521                 event.Skip()
   527                 event.Skip()
   522             minimizebutton.Bind(wx.EVT_BUTTON, togglewindow, id=minimizebutton_id)
   528             minimizebutton.Bind(wx.EVT_BUTTON, togglewindow, id=minimizebutton_id)
   523         
   529         
   524             self.PluginInfos[self.PluginRoot] = {"main" : plcwindow, "params" : paramswindow}
   530             self.PluginInfos[self.PluginRoot]["main"] = plcwindow
       
   531             self.PluginInfos[self.PluginRoot]["params"] = paramswindow
   525             
   532             
   526         self.PLCConfigMainSizer.Layout()
   533         self.PLCConfigMainSizer.Layout()
   527         self.RefreshScrollBars()
   534         self.RefreshScrollBars()
   528         self.Thaw()
   535         self.Thaw()
   529 
   536 
   918         return OnChoiceChanged
   925         return OnChoiceChanged
   919     
   926     
   920     def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, plugin, path):
   927     def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, plugin, path):
   921         def OnChoiceContentChanged(event):
   928         def OnChoiceContentChanged(event):
   922             res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection(), self.Log)
   929             res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection(), self.Log)
   923             choicectrl.SetStringSelection(res)
       
   924             infos = self.PluginRoot.GetParamsAttributes(path)
       
   925             staticbox = staticboxsizer.GetStaticBox()
       
   926             staticbox.SetLabel("%(name)s - %(value)s"%infos)
       
   927             if wx.VERSION < (2, 8, 0):
   930             if wx.VERSION < (2, 8, 0):
   928                 self.ParamsPanel.Freeze()
   931                 self.ParamsPanel.Freeze()
       
   932                 choicectrl.SetStringSelection(res)
       
   933                 infos = self.PluginRoot.GetParamsAttributes(path)
       
   934                 staticbox = staticboxsizer.GetStaticBox()
       
   935                 staticbox.SetLabel("%(name)s - %(value)s"%infos)
   929                 self.RefreshSizerElement(self.ParamsPanel, staticboxsizer, infos["children"], "%s.%s"%(path, infos["name"]), selected=selected)
   936                 self.RefreshSizerElement(self.ParamsPanel, staticboxsizer, infos["children"], "%s.%s"%(path, infos["name"]), selected=selected)
   930                 self.ParamsPanelMainSizer.Layout()
   937                 self.ParamsPanelMainSizer.Layout()
   931                 self.ParamsPanel.Thaw()
   938                 self.ParamsPanel.Thaw()
   932                 self.ParamsPanel.Refresh()
   939                 self.ParamsPanel.Refresh()
   933             else:
   940             else:
   934                 wx.CallAfter(self.RefreshPluginTree)
   941                 wx.CallAfter(self.RefreshAll)
   935             event.Skip()
   942             event.Skip()
   936         return OnChoiceContentChanged
   943         return OnChoiceContentChanged
   937     
   944     
   938     def GetTextCtrlCallBackFunction(self, textctrl, plugin, path):
   945     def GetTextCtrlCallBackFunction(self, textctrl, plugin, path):
   939         def OnTextCtrlChanged(event):
   946         def OnTextCtrlChanged(event):