Can I display a text from a textbox into the command window?

조회 수: 1 (최근 30일)
Galit Moshkovitz
Galit Moshkovitz 2018년 7월 19일
댓글: Galit Moshkovitz 2018년 7월 23일
Hi,
I have a gui with a textbox that is showing the frames of a movie while is playing. When i press pause, everything pauses. Is there any way to copy or print the 'Current frame' showed in the text box while the movie is in pause??

답변 (1개)

Jason Whitfield
Jason Whitfield 2018년 7월 19일
If you have a handle to the textbox, you can access its text through its "String" property. You can get a handle to it with the "findobj" or "findall" functions. For example, if there is only one textbox in the image, you could do the following.
textbox = findall(gcf, 'Type', 'textboxshape');
disp(textbox.String);
  댓글 수: 1
Galit Moshkovitz
Galit Moshkovitz 2018년 7월 23일
Hi Mr.Whitfield,
thanks for your answer.
But is not working. Maybe I did not explain well.
I have a gui with a text, which is changing when the video is playing because is showing the frame numbers. I want to display the current frame number when I pause the video on the gui.
I tried your answer but did not work or maybe I put it in the wrong place.
Here is a screenshot of the gui and a part of my code.
if true
% code
end
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
videoObject = handles.videoObject;
set(handles.pushbutton4,'Enable','on');
set(handles.pushbutton3,'Enable','off');
axes(handles.axes3);
for frameCount = 2:videoObject.NumberOfFrames
% Display frames
set(handles.text3,'String',num2str(frameCount));
frame = read(videoObject,frameCount);
imshow(frame);
drawnow;
end
set(handles.pushbutton5,'Enable','on');
set(handles.pushbutton4,'Enable','off');
%----PAUSE/PLAY---
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(strcmp(get(handles.pushbutton4,'String'),'Pause'))
set(handles.pushbutton4,'String','Play')
uiwait();
else
set(handles.pushbutton4,'String','Pause');
uiresume();
end
I also have tried to put global variables, but I am a little new to Matlab.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by