From: Steven_Lord on 20 Jul 2010 10:07 "Marco " <fake.marco.fake.minini(a)treuropa.com> wrote in message news:i249m4$kit$1(a)fred.mathworks.com... > it would be nice, wouldn't it? ;) > > the problem is that the load of the new data must be done in the invoking > function, not in the gui itself! So the calling function has "access" to the guts of your GUI directly, not through some callback function that could validate the data that function is stuffing into the GUI? That seems like a bit of a bad design; what's to prevent the function (or the user of that function) from making a mistake and putting your GUI into a bad state? Anyway, there must be SOMETHING that loads the new data in the GUI. Have that SOMETHING call a function (be it a regular function or a callback function) that updates the GUI. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Marco on 20 Jul 2010 10:23 ok, seems like i'm reaching the point... i was thinking about loading the data with a simple: set(gui_handle,'userdata',data) which i can understand is a poor example of designing.. could you please suggest me where i can find some documentation on how to better structure my code? thank you very much Steve for your help so far! "Steven_Lord" <slord(a)mathworks.com> wrote in message <i24aib$ilb$1(a)fred.mathworks.com>... > > > "Marco " <fake.marco.fake.minini(a)treuropa.com> wrote in message > news:i249m4$kit$1(a)fred.mathworks.com... > > it would be nice, wouldn't it? ;) > > > > the problem is that the load of the new data must be done in the invoking > > function, not in the gui itself! > > So the calling function has "access" to the guts of your GUI directly, not > through some callback function that could validate the data that function is > stuffing into the GUI? That seems like a bit of a bad design; what's to > prevent the function (or the user of that function) from making a mistake > and putting your GUI into a bad state? > > Anyway, there must be SOMETHING that loads the new data in the GUI. Have > that SOMETHING call a function (be it a regular function or a callback > function) that updates the GUI. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com
From: Steven_Lord on 20 Jul 2010 12:03 "Marco " <fake.marco.fake.minini(a)treuropa.com> wrote in message news:i24bg9$mhg$1(a)fred.mathworks.com... > ok, seems like i'm reaching the point... > > i was thinking about loading the data with a simple: > > set(gui_handle,'userdata',data) > > which i can understand is a poor example of designing.. In particular, it requires each and every location in your function that wants to update the data to know which component in your GUI actually stores the data, and that the components stores it in its UserData property. While these aren't unusual bits of knowledge, I'd generally prefer to encapsulate that into one function, let's call it updateDataForGui, that your main function would call. This way you've got one place that has to know about the internal "guts" of your GUI, and what updateDataForGui actually does to store the data can change if necessary while _users_ of updateDataForGui do not need to change their code at all. Then updateDataForGui can change the data in the GUI and do whatever is necessary to refresh the GUI. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Marco on 21 Jul 2010 03:43
right, i see: this really clears out my problem! thank you so much for your help!! "Steven_Lord" <slord(a)mathworks.com> wrote in message <i24hd4$pa8$1(a)fred.mathworks.com>... > > > "Marco " <fake.marco.fake.minini(a)treuropa.com> wrote in message > news:i24bg9$mhg$1(a)fred.mathworks.com... > > ok, seems like i'm reaching the point... > > > > i was thinking about loading the data with a simple: > > > > set(gui_handle,'userdata',data) > > > > which i can understand is a poor example of designing.. > > In particular, it requires each and every location in your function that > wants to update the data to know which component in your GUI actually stores > the data, and that the components stores it in its UserData property. While > these aren't unusual bits of knowledge, I'd generally prefer to encapsulate > that into one function, let's call it updateDataForGui, that your main > function would call. This way you've got one place that has to know about > the internal "guts" of your GUI, and what updateDataForGui actually does to > store the data can change if necessary while _users_ of updateDataForGui do > not need to change their code at all. > > Then updateDataForGui can change the data in the GUI and do whatever is > necessary to refresh the GUI. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com |