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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by