How do I create a button that switches to another tab of a GUI?
14 次查看(过去 30 天)
显示 更早的评论
Here is my current code:
fig = uifigure('Name', 'Diabetes Diagnosis');
tabGroup = uitabgroup(fig);
sympTab = uitab(tabGroup,'Title','Symptoms');
famHistTab = uitab(tabGroup,'Title', 'Family History');
nextCtrl = uicontrol(sympTab, 'ButtonPushedFcn', {@buttonPushed,tabGroup,famHistTab});
function buttonPushed(uiTabGroup, uiFamHistTab)
uiTabGroup.SelectedTab = uiFamHistTab
end
The control is meant to switch from sympTab to famHistTab. I think the biggest problem is that I don't have any idea how to format a callback function. It outputs a figure, but the button doesn't have any apparent effect.
0 个评论
回答(1 个)
Sreelakshmi S.B
2019-3-8
You can try the code below. I’ve used uibutton in place of uicontrol since there is no 'ButtonPushedFcn' property on the UIControl class.
As for callback, assign a function handle that references the callback function to the ButtonDownFcn property of the button and mention the arguments you're passing when doing this,as shown below:
fig = uifigure('Name', 'Diabetes Diagnosis');
tabGroup = uitabgroup(fig);
sympTab = uitab(tabGroup,'Title','Symptoms');
famHistTab = uitab(tabGroup,'Title', 'Family History');
btn = uibutton(sympTab,'ButtonPushedFcn', @(arg1,arg2) buttonPushed(tabGroup,famHistTab));
% Create the function for the ButtonPushedFcn callback
function buttonPushed(uitabGroup,uiFamHistTab)
uitabGroup.SelectedTab = uiFamHistTab;
end
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!