How to write data to listbox from another GUI
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, I would like to ask you for help. I have two GUIs. First one calling function from second one GUI and this function writes data to listbox (second gui). I know situation is little bit complicated. How I do that is outlined bellow. Problem is that the data are not writen to listbox after calling this function from first GUI. For data transfer between GUIs I use commands setappdata and getappdata. I dont know where is the problem because i have verified that the data has been transfered and I think the handle of the listbox is also right.
Important parts of program from second GUI
% --- Executes just before ReseltFigure is made visible.
function ReseltFigure_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to ReseltFigure (see VARARGIN)
% Choose default command line output for ReseltFigure
handles.output = hObject;
setappdata(0,'hReseltGUI',gcf);
setappdata(gcf,'fhWriteData2listbox',@WriteData2listbox);
setappdata(gcf,'hListbox',handles.result_listbox);
% Update handles structure
guidata(hObject, handles);
The function which is placed in m-file of the second GUI.
function WriteData2listbox
figure(getappdata(0,'hReseltGUI'));
hReseltGUI=getappdata(0,'hReseltGUI');
hListbox=findobj(hReseltGUI,'type','listbox');
g=getappdata(gcf,'hListbox');
a=getappdata(0,'Data');
celldisp(a);
set(g,'String',a);
Calling the function which is covered above. This part of code is written in first GUI.
ReseltFigure; # Calling second GUI
setappdata(0,'Data',SelectedLines)
hResultGUI=getappdata(0,'hReseltGUI');
fhWriteData=getappdata(hResultGUI,'fhWriteData2listbox');
feval(fhWriteData);
Thank you for all your advice Jirka
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!