beremiz

Parents 9d20df7c144a
Children d376a8b0b602
Fix wrong panel size making strange background in topology plugin element
  • +4 -4
    Beremiz.py
  • +10 -6
    plugger.py
  • --- a/Beremiz.py Sat Feb 11 00:02:02 2012 +0100
    +++ b/Beremiz.py Wed Feb 15 00:32:01 2012 +0100
    @@ -880,7 +880,7 @@
    msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER)
    return msizer
    - def GenerateParamsPanel(self, plugin, bkgdclr):
    + def GenerateParamsPanel(self, plugin, bkgdclr, top_offset=0):
    rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
    rightwindow.SetBackgroundColour(bkgdclr)
    @@ -893,7 +893,7 @@
    rightwindowmainsizer.AddSizer(rightwindowsizer, 0, border=0, flag=wx.GROW)
    msizer = self.GenerateMethodButtonSizer(plugin, rightwindow, not self.PluginInfos[plugin]["right_visible"])
    - rightwindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
    + rightwindowsizer.AddSizer(msizer, 0, border=top_offset, flag=wx.TOP|wx.GROW)
    rightparamssizer = wx.BoxSizer(wx.HORIZONTAL)
    rightwindowsizer.AddSizer(rightparamssizer, 0, border=0, flag=wx.ALIGN_RIGHT)
    @@ -1168,8 +1168,8 @@
    tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id)
    iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
    - rightwindow = self.GenerateParamsPanel(plugin, bkgdclr)
    - self.PluginTreeSizer.AddWindow(rightwindow, 0, border=8, flag=wx.TOP|wx.GROW)
    + rightwindow = self.GenerateParamsPanel(plugin, bkgdclr, 8)
    + self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
    self.PluginInfos[plugin]["left"] = leftwindow
    self.PluginInfos[plugin]["right"] = rightwindow
    --- a/plugger.py Sat Feb 11 00:02:02 2012 +0100
    +++ b/plugger.py Wed Feb 15 00:32:01 2012 +0100
    @@ -466,6 +466,14 @@
    self.GetPlugRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res))
    return res
    + def GetAllChannels(self):
    + AllChannels=[]
    + for PlugInstance in self.PlugParent.IterChilds():
    + if PlugInstance != self:
    + AllChannels.append(PlugInstance.BaseParams.getIEC_Channel())
    + AllChannels.sort()
    + return AllChannels
    +
    def FindNewIEC_Channel(self, DesiredChannel):
    """
    Changes IEC Channel number to DesiredChannel if available, nearest available if not.
    @@ -476,12 +484,8 @@
    # Do nothing if no change
    #if CurrentChannel == DesiredChannel: return CurrentChannel
    # Build a list of used Channels out of parent's PluggedChilds
    - AllChannels=[]
    - for PlugInstance in self.PlugParent.IterChilds():
    - if PlugInstance != self:
    - AllChannels.append(PlugInstance.BaseParams.getIEC_Channel())
    - AllChannels.sort()
    -
    + AllChannels = self.GetAllChannels()
    +
    # Now, try to guess the nearest available channel
    res = DesiredChannel
    while res in AllChannels: # While channel not free