marrcandre / eagle-py

Automatically exported from code.google.com/p/eagle-py
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Cannot modify data inside a inside a data_changed_callback #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a table with 3 data interdependent data items.  If 2 are set, I can
calculate the 3rd.  However, if I try to set the calculated value back into
the table in the data_changed_callback, it recurses until the stack blows
up.  It would be useful if the data_changed_callback suppressed the event
being fired during execution

e.g 

def data_changed( app, widget, data ):
    print "changed:", app, widget, data
    idx=data[0]
    value=data[1]
    when = value[0]
    where = value[1]
    mileage = value[2]
    price = value[3]
    cost=value[4]
    volume=value[5]
    mpg=value[6]
    print cost
    if cost == 0:
        cost = volume * price / 100
    print cost
    widget[idx][4]=cost

Original issue reported on code.google.com by dave.g.s...@gmail.com on 12 Sep 2007 at 8:00

GoogleCodeExporter commented 9 years ago
This is not a defect, but a good enhancement proposal ;-)

Solution so far: app.idle_add(f) where f() is the function to set your value. 
It will
avoid infinite recursion, however it will still loop forever, you'll need to 
set some
instance attribute to stop it and unset it when data_changed detects it. 
(humm...
maybe this also work with recursive version too)

Original comment by barbi...@gmail.com on 12 Sep 2007 at 9:26

GoogleCodeExporter commented 9 years ago

Original comment by barbi...@gmail.com on 12 Sep 2007 at 9:26

GoogleCodeExporter commented 9 years ago
Fixed by commit r183.

Original comment by barbi...@gmail.com on 17 Sep 2007 at 1:03