フィルターのクリア

Selecting radio button resets GUI [GUIDE, R2017b]

5 ビュー (過去 30 日間)
TJ
TJ 2018 年 1 月 4 日
コメント済み: Image Analyst 2018 年 8 月 3 日
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

採用された回答

Jan
Jan 2018 年 1 月 4 日
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 件のコメント
Jan
Jan 2018 年 8 月 3 日
@Duijnhouwer: Please post some code which reproduces the behavior you observe.
Image Analyst
Image Analyst 2018 年 8 月 3 日
Sounds like user error to me. Why would you remove the callback that runs when you click on a radio button???

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 1 月 5 日
Put the function call in the OutputFcn() rather than the OpeningFcn() and see if that helps.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by