以编程方式从 MATLAB 获取 GUI 数据(无 GUIDE)
Get GUI data from MATLAB programmatically (without GUIDE)
如果不使用 GUIDE,我如何在按下按钮后获得编辑 uicontrol 的值?
示例:
fig = figure;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input');
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', @obj.test);
然后在我的class
methods
function testing(src, event, handles)
msgbox(get(handles.input, 'string'));
end
end
GUI 代码:
function gui_test
fig = figure;
obj= testclass;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input','Position',[10 70 100 20]);
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', {@obj.testing,input});
end
Class定义:
classdef testclass
methods
function testing(obj,src, event, handles)
msgbox(get(handles, 'string'));
end
end
end
如果不使用 GUIDE,我如何在按下按钮后获得编辑 uicontrol 的值?
示例:
fig = figure;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input');
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', @obj.test);
然后在我的class
methods
function testing(src, event, handles)
msgbox(get(handles.input, 'string'));
end
end
GUI 代码:
function gui_test
fig = figure;
obj= testclass;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input','Position',[10 70 100 20]);
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', {@obj.testing,input});
end
Class定义:
classdef testclass
methods
function testing(obj,src, event, handles)
msgbox(get(handles, 'string'));
end
end
end