GUI stops working after pushbutton function has completed
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have created a GUI (called GNgui) using GUIDE that runs a function when a 'Scan' button is pressed. It disables all the other buttons/fields in the GUI until it stops running, where it enables all the buttons again.
After the function runs (successfully), I'd like to be able to hit the 'Scan' button again to repeat the process, but every time I do, I get the following error message:
Undefined function 'GNgui' for input arguments of type 'struct'.
Error in
@(hObject,eventdata)GNgui('fileName_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
This isn't mutually exclusive to that push button either. When I try to press any other button (or even try to close the GUI window), I get a very similar error.
Any ideas? I've attached my .m file.
PS: I realise the code is a little messy, I'm trying to update and improve on some code someone else wrote.
2 Kommentare
Antworten (1)
Meade
am 20 Apr. 2016
I believe that the call back is written incorrectly. Your anonymous function syntax is telling the callback function that the second input is "evt" which is a struct by default. However, you're passing "hObj" as the second input.
try this:
@(hObject,eventdata)GNgui(hObject,eventdata,guidata(hObject))
7 Kommentare
Meade
am 21 Apr. 2016
Ok, so the problem seems to be that the 'handles' argument that is being passed to ALL your callbacks is empty.
I can't run the full gui since it's looking for some sort of COM connection, but you need to get all the handles for all the things you created in the GUIDE creator.
As a start, swap lines 41:45 with these
hFig = ancestor(hObject,'figure');
handles = guihandles(hFig);
% Choose default command line output for GNgui
handles.output = hObject;
% Update handles structure
guidata(hFig, handles);
This adds the structure 'handles' as guidata to the figure. Then, whenever a callback has the 'handles' arument, it should get this list of items.
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!