1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| function affichage
Session_larg=300;
Session_haut=300;
set(0,'Units','pixels')
scrsz = get(0,'ScreenSize');
% Création de la fenêtre
fenetre=figure('Name','Affichage','NumberTitle','off',...
'Menubar','none','Name','Nom',...
'NumberTitle','off',...
'Position',[200 200 Session_larg Session_haut]);
axis('off');
u0={'Option1';'Option2';'Option3';'Option4';'Autre'};
u1={'Option1';'Option2';'Option3'};
marque = uicontrol('Style','text',...
'tag','resultat',...
'pos',[10 50 100 30]);
uicontrol('Style','popup','string',u0,...
'pos',[10 250 100 30],...
'tag','popup_A',...
'callback',@autre);
uicontrol('Style','popup','String',u1,...
'pos',[10 200 100 30],...
'tag','popup_B');
uicontrol('Style', 'pushbutton', 'String', 'OK',...
'Position', [150 220 50 50],...
'tag','bouton',...
'callback',@ok)
uicontrol('Style', 'edit',...
'Position', [10 100 100 30],...
'tag','autre',...
'visible','off')
handles=guihandles(gcf);
function ok(obj,event)
handles=guihandles(gcf);
str=get(handles.popup_A,'string');
val=get(handles.popup_A,'value');
choix{1}=str{val};
str=get(handles.popup_B,'string');
val=get(handles.popup_B,'value');
choix{2}=str{val};
choix{3}=get(handles.autre,'string');
if ~isempty(choix{3})
set(handles.resultat,'string',sprintf('%s & %s',choix{[3 2]}))
else set(handles.resultat,'string',sprintf('%s & %s',choix{1:2}))
end
function autre(obj,event)
handles=guihandles(gcf);
str=get(obj,'string');
val=get(obj,'value');
if strcmpi(str{val},'autre')
set(handles.autre,'visible','on')
else set(handles.autre,'visible','off','string','')
end |
Partager