title: pyqt: dynamically update properties for dynamically created widgets
body: <p>I'm trying to find a way to update labels which are within dynamically created widgets (that can be deleted), according to properties dynamically set in the preceding widgets.</p>
  
  <p>Is there a way to automatically and dynamically link a pyqt object to a property of other widgets, so that when I change a value anywhere, that object updates itself?</p>
  
  <p>Example: object 'a' has property <code>start</code>, <code>bars</code> and <code>end</code>; <code>bars</code> is given, <code>start</code> is taken by the previous object (or 1 if None), <code>end</code> is calculated. object 'b' takes its <code>start</code> from <code>a.end</code> and so on.</p>
  
  <pre><code>class myclass(object):
    def __init__(self, referrer=None, value=1):
      self.referrer=referrer
      self.value=value
  
    def _get_start(self):
      if not self.referrer:
        return 1
      else:
        return self.referrer.end+1
  
    def _get_end(self):
      return self.start+self.value-1
  
    start=property(_get_start)
    end=property(_get_end)
  
  def create(value=1):
    if not vList:
      ref=None
    else:
      ref=vList[-1]
    val=myclass(ref, value)
    vList.append(val)
  
  def showList():
    for i in vList:
      print 'item: %d\tstart: %d\tend: %d' % (vList.index(i),i.start, i.end)
  
  vList=[]
  </code></pre>
  
  <p>If I call create() 3 times, showList() will show:</p>
  
  <pre><code>item: 0 start: 1        end: 1
  item: 1 start: 2        end: 2
  item: 2 start: 3        end: 3
  </code></pre>
  
  <p>if I change vList[0].value to 3:</p>
  
  <pre><code>item: 0 start: 1        end: 3
  item: 1 start: 4        end: 4
  item: 2 start: 5        end: 5
  </code></pre>
  
  <p>The problem raises when I need to keep those values updated in the gui (<a href="http://i.imgur.com/8742B5a.png" rel="nofollow">think to it as an interface like this</a>): every horizontal widget has a label showing the property of <code>start</code>, a spinbox for <code>bars</code>,  and a label for <code>end</code>, and as soon as <strong>any</strong> spinbox value changes, every subsequent widget should update its <code>start</code> and <code>end</code> properties according to its previous widget and show them in the relative labels.
  Moreover, when any widget is deleted, all the subsequent widget should recompute every property.</p>
  
  <p>Using getter/setter to set the values in the labels of the widgets' next instancies doesn't obviously work as I need, because when I change any <code>x.value</code>, the following instancies' <code>start</code> and <code>end</code> will be actually updated only when recalled, AFAIU.
  I could connect every new widget to its previous (with <code>valueChanged()</code>) or create a function which finds the subsequent widget and update their properties, but that's not a good solution.</p>
  
  <p>Since I am almost new to python (most important: I'm not a programmer) I think that I am ignoring something about "connecting" variables in a better and cleanest way (maybe related to signals or threading?).</p>
  
  <p>Consider that those widgets will actually be children widgets of another "main" widget, which will have similar properties: <code>start</code> taken from its previous main widget (if any), <code>bars</code> which is the sum of all <code>bars</code> in every children widget, <code>end</code> which will be again <code>start+bars-a</code>.</p>
  
  <p>Thanks!</p>
  
  <p>(I hope you will understand what I meant, my english is not perfect and, since I'm not a programmer, my terminology is not always correct)</p>