Discussion:
guidata updating DataItems from callback functions
alfred.mechsner-gM/Ye1E23mwN+
2013-04-28 21:08:33 UTC
Permalink
Hello,

I have trouble with updating DataItems from callbacks from a different
Group or DataSetGroup.

In the example the callback function "test_callback" in "TestGD" is called
from the test_button, which is in Group "B". When the DataItem x, which is
in group "A" is updated (self.x+=1) it will be printed correctly, but the
value in the widget is not updated.

The same happens, when the callback is issued from inside another DataSet.
(AnotherGD).

Is there a way to force the display of the value ot the DataSet?

Thank you

Alfred


*Example:*

# -*- coding: utf-8 -*-
from guidata.dataset.datatypes import (DataSet, BeginTabGroup, EndTabGroup,
BeginGroup, EndGroup, ObjectItem,
DataSetGroup)
from guidata.dataset.dataitems import ( IntItem, ButtonItem, FirstChoice)

class TestGD(DataSet):
def test_callback(self, item, value, parent):
self.x+=1
self.y+=1
print self.x, self.y

bg=BeginGroup("A")
x=IntItem("X", default=0)
eg=EndGroup("A")

bg1=BeginGroup("B")
y=IntItem("Y", default=0)
test_button=ButtonItem("Test", test_callback)
eg1=EndGroup("B")

class AnotherGD(DataSet):
def test_callback(self, item, value, parent):
self.reference_to_testGD.x+=1
self.reference_to_testGD.y+=1
print "reference_to_testGD", self.reference_to_testGD.x,
self.reference_to_testGD.y

bg=BeginGroup("C")
x=IntItem("X", default=0)
eg=EndGroup("C")

bg1=BeginGroup("D")
y=IntItem("Y", default=0)
test_button=ButtonItem("Test", test_callback)
eg1=EndGroup("D")

if __name__ == "__main__":
import guidata
_app = guidata.qapplication()

testGD=TestGD()
anotherGD=AnotherGD()
anotherGD.reference_to_testGD=testGD

set=DataSetGroup([testGD, anotherGD])
while set.edit():
pass
--
You received this message because you are subscribed to the Google Groups "guidata/guiqwt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guidata_guiqwt+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...