Selecting radio button resets GUI [GUIDE, R2017b]
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have a GUI with several edit boxes which sow the names of files which have been selected by the user. I aso have some radio buttons which dictate what operation to complete on the data which is loaded vvia the GUI.
When I have loaded the data and then click a radio button which was not the default, all the edit boxes clear and it seems as though the GUI is reinitialised. I have not used the radio button group call back for selectionChanged. All I do is check which radio button has been clicked when it comes to performing the calculations. Does anyone know why the radio button keeps reinitialising the GUI?
The code for initialising the GUI objects I have written is:
function defaultVals(hObject, handles)
%
% This function takes the handle to the GUI figure, and structure with
% handles and user data and sets the values of the various
% objects on the GUI.
% Call this function in the Openingfunction of the GUI to set initial
% values for the GUI objects.
set(handles.textPath,'string','No file loaded.'); % sets default value of textFile
set(handles.textFile,'string','No file loaded.'); % sets default value of textData
set(handles.checkbox1 , 'Enable','off'); % disable checkbox1;
I placed this function in the OpeningFcn. After using the dbstack (Thanks to Jan Simon's suggestion) I found the following call stack was produced when I placed 'dbstack' in my defaultVals function:
In VoltageResonance>defaultVals (line 272)
In VoltageResonance>VoltageResonance_OpeningFcn (line 58)
In gui_mainfcn (line 220)
In VoltageResonance (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)VoltageResonance('trainConfigGroup_SelectionChangedFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))
It appears that the function matlab.graphics.internal.figfile.FigFile/read causes the GUI to be run again but I am not sure where that function arises from by changing a radio button. Kind regards, TJ
0 commentaires
Réponse acceptée
Jan
le 4 Jan 2018
Then the callback of the radio button contains some code, which initializes the contents of the GUI. Without seeing the code, we cannot guess, which command it is. But you can find this out easily using the debugger: https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html Set a breakpoint in the callback and step through the code line by line. You will find, which command causes the reset. Finally remove this command.
9 commentaires
Image Analyst
le 3 Août 2018
Sounds like user error to me. Why would you remove the callback that runs when you click on a radio button???
Plus de réponses (1)
Image Analyst
le 5 Jan 2018
Put the function call in the OutputFcn() rather than the OpeningFcn() and see if that helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!