2

我正在尝试使用应用程序TabPanel Constructor v2.8。我已按照它给出的说明进行操作。在我的gui的openingfcn中,我需要选择一个选项卡。为此,我应该使用与上述应用程序相关的 tabselectionfcn。此函数具有以下签名:

TABSELECTIONFCN(<hFig>,<TabTag>,<tabnumber>)
%     <hFig>      the handle(!) of the Figure (which contains the tabpanel)
%                 and not the name of the figure file.
%     <TabTag>    the Tag name of the tabpanel
%     <tabnumber> The number of the tabpanel or the tab string

当我研究我的 gui 的变量句柄以找到标签面板的句柄时,我没有看到它们。如果我打开我的 gui 的 .fig 文件,它们不会出现,所以我不知道如何解决这个问题。

PD 我向该应用程序的作者发送了一封电子邮件,但没有得到答复。

4

1 回答 1

2

您不需要标签面板句柄,而是图形句柄。

GUIDE 创建的图形句柄默认隐藏。它的可见性由图形属性 HandleVisibility控制,该属性设置callback为 GUI 以保护它们免受命令行用户的影响。从回调函数内部可以看到句柄,例如

yourgui_OpeningFcn(hObject, eventdata, handles, varargin)

hObject你需要的把手在哪里。您可以在与 fig 文件关联的 m 文件中找到所有回调函数。

您还可以从 GUI 外部获取句柄,打开 FIG 文件为

fh = openfig('yourgui.fig');

或者,您可以使用FINDALL通过其属性查找对象(包括隐藏的):

fh = findall(0,'type','figure'); %# all open figures including GUIs
fh = findall(0,'name','yourgui'); %# find by name

然后您可以使用 TABSELECTIONFCN 控制选项卡:

tabselectionfcn(fh,'myTab') %# get the tab status
tabselectionfcn(fh,'myTab',2) %# activate the 2nd tab
tabselectionfcn(fh,'myTab',1,'off') %# disable the 1nd tab (if not active)

选项卡面板标签名称是Tag您在创建选项卡面板时用作占位符的静态文本对象的属性。如果您在 GUIDE 中打开 GUI 并使用 Property Inspector 检查选项卡面板属性,您可以找到它。那看起来像TBP_myTab

顺便说一句,如果您确实需要 tabpanels 句柄,您也可以使用 FINDALL 获得它们:

htab = findall(fh,'tag','TBP_myTab');
于 2012-02-22T19:29:07.653 回答