How do you access the string of an edit box from one gui, in a callback associated with another gui?

2 次查看(过去 30 天)
In my GUI once I click the button "start" an "m-file" is loaded up (FVBExample2) which takes the information I have entered into my GUI to run tests on a camera. One of the tests is named "KineticSeries" and to tidy things up a bit, the parameters associated with this are entered into a separate GUI which launches when I click the button "Kinetic Series Settings".
I receive this error when I try to run my program...
Reference to non-existent field 'editboxkinserlen'.
Error in FVBExample2 (line 169)
KinSeriesLength=str2num(get(handles.editboxkinserlen,'String'));
Error in CamTestGUIbackupbeforeimage>previmage_Callback (line 1572)
FVBExample2
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in CamTestGUIbackupbeforeimage (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)CamTestGUIbackupbeforeimage('previmage_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
This edit box is located in the second GUI, is there something I should have in front of my code to tell Matlab to look for this box within the second GUI?
Thanks

采纳的回答

Geoff Hayes
Geoff Hayes 2014-10-8
Jonathan - there are a couple ways of doing this. See Sharing between multiple GUIs or how to pass data between guis for examples on how to do this.
In the second link, if the HandleVisibility property for both GUIs are set to on, then you can use findobj function to find the other GUI using its tag. So, in your second GUI (or even from the Command Window), you may look for the first GUI as
hGui = findobj('Type','figure','Tag','GUI1');
where 'GUI1' is the value of the Tag property of the first GUI (typically, the default is figure1).
Then
if ~isempty(hGui)
% GUI has been found
% get widget handles for this GUI
handlesGui1 = guidata(hGui);
% now read the data from that GUI widgets
KinSeriesLength=str2num(get(handlesGui1.editboxkinserlen,'String'));
% etc.
end
Try the above and see what happens!
  10 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by