[Scilab-users] uicontrol in a function
Serge Steer
Serge.Steer at inria.fr
Wed Jan 2 14:29:43 CET 2013
You must modify your test function as given below, because the test
function creates the widgets and then exits, so when you click on the ok
button the text variable is no more defined.
The solution below saves the texte handle into the userdata field of the
control bouton data structure so it can be retreived by gcbo.userdata by
the callback.
function []=test(h)
text = uicontrol(h, "style", "edit", ...
"string", "foo",...
"position", [50 100 100 20]);
bouton = uicontrol(h, "string", "OK",...
"position", [50 50 50 20], ...
"userdata",text,...
"callback", "gcbo.userdata.string = string(0);");
endfunction
fig = figure(0);
test(fig);
Serge Steer
Le 02/01/2013 10:48, Dang, Christophe a écrit :
> Hello,
>
> I'm starting with my first graphical user interfaces.
> It seems OK until I try to encapsulate it into a function.
>
> Here is a minimal complete example:
>
> // **********
> function []=test(h)
> text = uicontrol(h, "style", "edit", ...
> "string", "foo",...
> "position", [50 100 100 20]);
> bouton = uicontrol(h, "string", "OK",...
> "position", [50 50 50 20], ...
> "callback", "text.string = string(0);");
> endfunction
>
> fig = figure(0);
> test(fig);
> // **********
>
> When I run the script, nothing happens.
>
> And if I first run execute the script without encapsulation
> then the script with encapsulation (without clear() inbetween),
> I get
> !--error 999
> set : The handle is no more valid.
> at line 4 of function generic_i_h called by :
> at line 2 of function %c_i_h called by :
> bject(251);text.string = string(0);;if exists("%oldgcbo") then gcbo
> while executing a callback
>
> So, I can I encapsulate?
>
More information about the users
mailing list