For set a "value" for multiple UIcontrol when some toggle button is push.
Show older comments
Hi, all. I try to change for multiple UIcontrol 'value' when i press a different UIcontrol, but i only can change this last UIcontrol not the others.
clear all; close all; f=figure; clc;
pc = uipanel ( "title" , "Paquetes Community." , "position" , [ 0.0025 0.5450 0.455 0.455 ]);
pe = uipanel ( "title" , "Paquetes External. " , "position" , [ 0.0025 0.0825 0.455 0.455 ]);
%%% Row Length %%%
row_l=15;
%%%
%%% The "octave_community.txt" and "octave_external.txt" just contain package names per line.
%%% Community File Lines %%%
cc=0; f_c = fopen("octave_community.txt"); numC = fgetl(f_c);
while(numC != -1)
cc++; numC = fgetl(f_c);
endwhile
fclose(f_c);
%%% Community Rows Number %%%
if (rem(cc,15) > 0)
rows_c = floor(cc/row_l) +1;
else
rows_c = floor(cc/row_l);
endif
rest_c= ( cc - (row_l)*(rows_c))/factorial(rows_c -1);
%%% External File Lines %%%
ee=0; f_e = fopen("octave_external.txt"); num_E = fgetl(f_e);l=0;
while(num_E != -1)
ee++; num_E = fgetl(f_e);
endwhile
fclose(f_e);
%%% External Rows Number %%%
if (rem(ee,row_l) > 0)
rows_e = floor(ee/row_l) +1;
else
rows_e = floor(ee/row_l);
endif
rest_e= ( ee - (row_l)*(rows_e))/factorial(rows_e -1);
%%% Community Togglebuttons %%%
fid = fopen("octave_full.txt");
txtread = fgetl(fid); fila=1; nuller_c=0;
for m = 1:rows_c
if(m == rows_c)
nuller_c=1;
endif
tope=(row_l)*m+nuller_c*(rest_c)*factorial(rows_c -1);
while (fila <= tope)
C( fila , m ) = uicontrol ( "parent" , pc , "style" , "togglebutton" , "string" , txtread , "value" , 0 , "callback", @pkg_install, "position" , [ 20+180*(m-1), 20*(15*m - (fila+1)), 140, 20]);
txtread = fgetl(fid); fila++;
endwhile
endfor
%%% External Togglebuttons %%%
nuller_e=0;
for m = 1:rows_e
if(m == rows_e)
nuller_e=1;
endif
tope=cc +(row_l)*m+nuller_e*(rest_e)*factorial(rows_e -1);
while (fila <= tope)
C( fila , m ) = uicontrol ( "parent" , pe , "style" , "togglebutton" , "string" , txtread , "value" , 0 , "callback", @pkg_install, "position" , [ 20+180*(m-1), 20*(15*m - (fila-cc+1)), 140, 20]);
txtread = fgetl(fid); fila++;
endwhile
endfor
fclose(fid);
%%% Ejecution Togglebuttons %%%
buttom = uicontrol ( f , "string" , "Install" , "position" ,[ 200 20 120 27 ],"callback",@pkg_install);
buttom = uicontrol ( f , "string" , "Cancell" , "position" ,[ 416 20 120 27 ],"callback",'close');
In the pkg_install i update those UIcontrol 'value', but some need enable others UIcontrol as dependencies but i can't change these dependencies 'value'.
Some help with this?
1 Comment
Rik
on 13 Apr 2021
Maybe you can use the gcbo function to get the handle of the object that triggered the callback. Otherwise I don't fully understand what you want to do.
Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!