popupmenu and pushbutton work

hi, if the figure has two uicontrol,"popupmenu and pushbutton.
The popupmenu has four kinds ,"watch","phone","book","can".
there are four kinds videos.
I hope that
step1, choose the play video
step2, push pushbutton for play vidoe.
I don't how to contiune popupmenu and pushbutton.
could you help me ,thanks.

5 comentarios

Oleg Komarov
Oleg Komarov el 14 de Ag. de 2012
And your code is...
Matt Fig
Matt Fig el 14 de Ag. de 2012
Pan, when you post code, please remember these steps:
  1. Paste the code.
  2. Highlight the code only.
  3. Press the button that looks like this: {} Code.
Thanks.
Pan
Pan el 14 de Ag. de 2012
Editada: Pan el 15 de Ag. de 2012
function f4()
clear all;
obj1 = mmreader('keybook.avi');
obj2 = mmreader('keywatch.avi');
obj3 = mmreader('keycan.avi');
obj4 = mmreader('keyphone.avi');
obj5 = mmreader('keyglasses.avi');
vid1 = read(obj1);
vid2 = read(obj2);
vid3 = read(obj3);
vid4 = read(obj4);
vid5 = read(obj5);
frame1 = 1;
frame2 = 1;
frame3 = 1;
frame4 = 1;
frame5 = 1;
f4 = 1;
stopwhile=1;
hst1=0;
hst2=0;
hst3=0;
hst4=0;
hst5=0;
h4 = figure('Name','four', 'NumberTitle','off','Color',[1,1,1],'Toolbar','none','Visible','on', 'Position',[10 40 1350 700],...
'Resize','off','menu','none');
hpop1 = uicontrol('unit','pixel','style','popupmenu','position',[33,600,80,50],'string','book|watch|can|phone|glasses','value',1,'callback',{@pop1_callback});%'UserData',vid1,vid2
hstat1 = uicontrol('unit','pixel','style','checkbox','value',0,'Visible','off','position',...
[33 445 25 25],'units','normalized');
hstat2 = uicontrol('unit','pixel','style','checkbox','value',0,'Visible','off','position',...
[653 445 25 25],'units','normalized');
hstat3 = uicontrol('unit','pixel','style','checkbox','value',0,'Visible','off','position',...
[33 95 25 25],'units','normalized');
hstat4 = uicontrol('unit','pixel','style','checkbox','value',0,'Visible','off','position',...
[653 95 25 25],'units','normalized');
hstat5 = uicontrol('unit','pixel','style','checkbox','value',0,'Visible','off','position',...
[583 95 25 25],'units','normalized');
hplay1 = uicontrol('unit','pixel','style','pushbutton','string','book-play',...
'position',[33 445 70 40],'backgroundColor',[0.3,0.8,1],'units','normalized','callback',{@play1_callback});
hplay2 = uicontrol('unit','pixel','style','pushbutton','string','watch-play',...
'position',[653 445 70 40],'backgroundColor',[0.3,0.8,1],'units','normalized','callback',{@play2_callback});
hplay3 = uicontrol('unit','pixel','style','pushbutton','string','can-play',...
'position',[33 95 70 40],'backgroundColor',[0.3,0.8,1],'units','normalized','callback',{@play3_callback});
hplay4 = uicontrol('unit','pixel','style','pushbutton','string','phone-play',...
'position',[653 95 70 40],'backgroundColor',[0.3,0.8,1],'units','normalized','callback',{@play4_callback});
hplay5 = uicontrol('unit','pixel','style','pushbutton','string','glasses-play',...
'position',[583 95 70 40],'backgroundColor',[0.3,0.8,1],'units','normalized','callback',{@play5_callback});
hstop1 = uicontrol('unit','pixel','style','pushbutton','string','book-stop',...
'position',[33 405 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop1_callback);
hstop2 = uicontrol('unit','pixel','style','pushbutton','string','watch-stop',...
'position',[653 405 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop2_callback);
hstop3 = uicontrol('unit','pixel','style','pushbutton','string','can-stop',...
'position',[33 55 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop3_callback);
hstop4 = uicontrol('unit','pixel','style','pushbutton','string','phone-stop',...
'position',[653 55 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop4_callback);
hstop5 = uicontrol('unit','pixel','style','pushbutton','string','glasses-stop',...
'position',[583 55 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop5_callback);
hori1 = uicontrol('unit','pixel','style','pushbutton','string','book-ori',...
'position',[33 365 70 40],'backgroundColor',[1,0.1,0.5],'units','normalized','callback',@ori1_callback);
hori2 = uicontrol('unit','pixel','style','pushbutton','string','watch-ori',...
'position',[653 365 70 40],'backgroundColor',[1,0.1,0.5],'units','normalized','callback',@ori2_callback);
hori3 = uicontrol('unit','pixel','style','pushbutton','string','can-ori',...
'position',[33 15 70 40],'backgroundColor',[1,0.1,0.50],'units','normalized','callback',@ori3_callback);
hori4 = uicontrol('unit','pixel','style','pushbutton','string','phone-ori',...
'position',[653 15 70 40],'backgroundColor',[1,0.1,0.5],'units','normalized','callback',@ori4_callback);
hori5 = uicontrol('unit','pixel','style','pushbutton','string','glasses-ori',...
'position',[583 15 70 40],'backgroundColor',[1,0.1,0.5],'units','normalized','callback',@ori5_callback);
hchoose = uicontrol('unit','pixel','style','pushbutton','string','back',...
'position',[1250 60 85 50],'backgroundColor',[1,0.1,0],'units','normalized','fontsize',12,'callback',@choose_callback);
hexit = uicontrol('unit','pixel','style','pushbutton','string','exit',...
'position',[1250 10 85 50],'backgroundColor',[1,0.1,0],'units','normalized','fontsize',12,'callback',@exit_callback);
* while (1)
if stopwhile==100
break;
end
if hst1==1
%subplot(2,2,1);
subplot('position',[0 0.52 0.46 0.43]);
imshow(vid1(:,:,:,frame1));
title('key','Fontsize',14);
if frame1 < size(vid1,4)
pause(1);
frame1 = frame1+1;
else
pause(1);
frame1 = 1;
end
end
if hst2==1
% subplot(2,2,2);
subplot('position',[0.46 0.52 0.46 0.43]);
imshow(vid2(:,:,:,frame2));
title('key','Fontsize',14);
if frame2 < size(vid2,4)
pause(1);
frame2 = frame2+1;
else
pause(1);
frame2 = 1;
end
end
if hst3==1
%subplot(2,2,3);
subplot('position',[0 0.02 0.46 0.43]);
imshow(vid3(:,:,:,frame3));
title('key','Fontsize',14);
if frame3 < size(vid3,4)
pause(1);
frame3 = frame3+1;
else
pause(1);
frame3 = 1;
end
end
if hst4==1
%subplot(2,2,4);
subplot('position',[0.46 0.02 0.46 0.43]);
imshow(vid4(:,:,:,frame4));
title('key','Fontsize',14);
if frame4 < size(vid4,4)
pause(1);
frame4 = frame4+1;
else
pause(1);
frame4 = 1;
end
end
if hst5==1
%subplot(2,2,4);
subplot('position',[0.46 0.02 0.46 0.43]);
imshow(vid5(:,:,:,frame5));
title('key','Fontsize',14);
if frame5 < size(vid5,4)
pause(1);
frame5 = frame5+1;
else
pause(1);
frame5 = 1;
end
end
% else
% subplot(2,2,4); imshow(vid2(:,:,:,1));
drawnow;
if f4 ==20
break;
% else f4 = f4+1;
end
end
function play1_callback(hObject1,eventdata1)
% set(hstat1,'value',1);
% hst1=1;
% set(hplay1 ,'backgroundColor',[1,1,0],'string','book-playing');
set(hpop1,'callback','str(val)');
end
function play2_callback(hObject2,eventdata2)
set(hstat2,'value',1);
hst2=1;
set(hplay2 ,'backgroundColor',[1,1,0],'string','watch-playing');
end
function play3_callback(hObject3,eventdata3)
set(hstat3,'value',1);
hst3=1;
set(hplay3 ,'backgroundColor',[1,1,0],'string','can-playing');
end
function play4_callback(hObject4,eventdata4)
set(hstat4,'value',1);
hst4=1;
set(hplay4 ,'backgroundColor',[1,1,0],'string','phone-playing');
end
function play5_callback(hObject5,eventdata5)
set(hstat5,'value',1);
hst5=1;
set(hplay5 ,'backgroundColor',[1,1,0],'string','glasses-playing');
end
function pop1_callback(hObject1,eventdata1)
val=get(hObject1,'Value');
str=get(hObject1,'String');
switch str(val)
case 'book'
set(hstat1,'value',1);
hst1=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','book-playing');
case 'watch'
set(hstat2,'value',1);
hst2=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','watch-playing');
case 'can'
set(hstat3,'value',1);
hst3=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','can-playing');
case 'phone'
set(hstat3,'value',1);
hst3=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','phone-playing');
case 'glasses'
set(hstat5,'value',1);
hst5=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','glasses-playing');
end
end *
function stop1_callback(hObject1,eventdata1)
set(hstat1,'value',0);
hst1=0;
set(hplay1 ,'backgroundColor',[0.3,0.7,1],'string','book-play');
frame1
end
function stop2_callback(hObject2,eventdata2)
set(hstat2,'value',0);
hst2=0;
set(hplay2 ,'backgroundColor',[0.3,0.7,1],'string','watch-play');
frame2
end
function stop3_callback(hObject3,eventdata3)
set(hstat3,'value',0);
hst3=0;
set(hplay3 ,'backgroundColor',[0.3,0.7,1],'string','can-play');
frame3
end
function stop4_callback(hObject4,eventdata4)
set(hstat4,'value',0);
hst4=0;
set(hplay4 ,'backgroundColor',[0.3,0.7,1],'string','phone-play');
frame4
end
function stop5_callback(hObject5,eventdata5)
set(hstat5,'value',0);
hst5=0;
set(hplay5 ,'backgroundColor',[0.3,0.7,1],'string','glasses-play');
frame5
end
function ori1_callback(hObject1,eventdata1)
set(hori1 ,'backgroundColor',[0.8,0.1,0.8],'callback','bookindex');
stopwhile=100;
close(h4);
bookindex(frame1);
end
function ori2_callback(hObject2,eventdata2)
set(hori2 ,'backgroundColor',[0.8,0.1,0.8],'callback','watchindex');
stopwhile=100;
close(h4);
watchindex(frame1);
end
function ori3_callback(hObject3,eventdata3)
set(hori3 ,'backgroundColor',[0.8,0.1,0.8],'callback','canindex');
stopwhile=100;
close(h4);
canindex(frame1);
end
function ori4_callback(hObject4,eventdata4)
set(hori4 ,'backgroundColor',[0.8,0.1,0.8],'callback','phoneindex');
stopwhile=100;
close(h4);
phoneindex(frame1);
end
function ori5_callback(hObject5,eventdata5)
set(hori5 ,'backgroundColor',[0.8,0.1,0.8],'callback','watchindex');
stopwhile=100;
close(h4);
phoneindex(frame1);
end
function exit_callback(hObject,eventdata)
f4=20;
% stop1_callback;
close gcf;
end
function choose_callback(hObject,eventdata)
set(hchoose ,'callback','fig');
stopwhile=100;
close(h4);
end
end
Pan
Pan el 14 de Ag. de 2012
OK? please help me, thanks!!
Jan
Jan el 18 de Ag. de 2012
Help with what? I do not understand the message "I don't how to contiune popupmenu and pushbutton". Posting a lot of code does not help also. I suggest to ask a clear question.
And of course I recommend to omit the absolutely useless "clear all" on top of the function. Why wasting processing time for reloading all M-functions?!

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

Pan
el 14 de Ag. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by