user-interface - Matlab TabPanel的使用

标签 user-interface matlab tabpanel handles

我正在尝试使用应用程序 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 文件,它们不会出现,所以我不知道如何解决这个问题。

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

最佳答案

您不需要选项卡面板句柄,而是需要图形句柄。

默认情况下,GUIDE 创建的图窗句柄是隐藏的。它的可见性由figure property控制。 HandleVisibility,设置为 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 并使用属性检查器检查选项卡面板属性,则可以找到它。这看起来像 TBP_myTab

顺便说一句,如果您确实需要选项卡面板句柄,您也可以使用 FINDALL 获取它们:

htab = findall(fh,'tag','TBP_myTab');

关于user-interface - Matlab TabPanel的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9400560/

相关文章:

javascript - 在 React 中切换 css 类

java - 在 BorderLayout 中换出中心 JPanel

java - 如何制作AWT Button()并使用ImageIcon()、Icon()?

matlab - 为什么 MATLAB 删除了我的小数?

plot - Matlab contourf() 在全局 map 上绘制数据

web-services - 在线图形用户界面设计工具

java - Java 中的 Levenberg-Marquardt 最小化

tabs - 更改 ExtJS 4 选项卡的高度

R Shiny - 动态添加 tabPanel 到 tabsetPanel (使用 renderUI)