How do you access the string of an edit box from one gui, in a callback associated with another gui?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan O'Neill
am 8 Okt. 2014
Kommentiert: Jonathan O'Neill
am 10 Okt. 2014
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
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 8 Okt. 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!