matlab - 在 Matlab GUI GUIDE 中更改工具栏图标

标签 matlab user-interface icons toolbar matlab-guide

我正在尝试将图标放入按钮中,并且正在使用 GUI GUIDE。

iconeditor 中,我尝试从 Matlab 图标路径导入文件,但它不起作用。

然后我尝试像这样对按钮进行编程

function toolbar_OPT_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to toolbar_Print (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

  % Use a MATLAB icon for the tool
  [X, map] = imread(fullfile(matlabroot,'toolbox','matlab','icons','matlabicon.gif'));

  % Convert indexed image and colormap to truecolor
  icon = ind2rgb(X,map);

  % Create a uipushtool in the toolbar
  hpt = uipushtool('CData',icon)

但它还没有工作。有什么建议吗?

最佳答案

正如我所见,你必须转换它,而你正在这样做......

但是缺少一个参数:

您需要添加工具栏的句柄作为第一个参数:

hpt = uipushtool(ht,'CData',icon,...

在您的情况下,您必须在句柄结构中查找它。如果您不知道如何获取它,请告诉我!

编辑

用于修改工具栏的更多高级功能可以在 Yair 的博客“undocumented Matlab”中找到:

figure-toolbar-components

特别是对于您的问题,这可能很有趣:

figure-toolbar-customizations

我强烈推荐 Yair Altman 的博客!!

编辑#2

使用 GUIDE 时,工具栏是自动创建的,并且似乎很难访问其参数。我无法完全测试它,我只是尝试通过以下方式识别工具栏句柄:

hToolbarTogg = findall(gcf,'tag','uitoggletool1');
set(hToolbarTogg,'CData',icon)

你必须找出你的工具栏切换的标签是什么,它应该是相同的,当使用 GUIDE 创建时......

关于matlab - 在 Matlab GUI GUIDE 中更改工具栏图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18138500/

相关文章:

matlab - matlab中 "out of memory"错误的解决方法

image - 需要自动消除图像和物体外边界的噪声

c++ - 在 GUI 中创建非常大的 TreeView (超过 100 万个项目)

iphone - 我的 iPhone 应用程序图标应该采用什么分辨率?

matlab - Logistic回归中的成本函数得出NaN作为结果

image-processing - 如何在matlab中对RGB矩阵执行power()函数

c++ - 仅使用标准 C++ 的图形?

user-interface - 我从哪里开始学习 GUI 编程?

ruby-on-rails-3 - Twitter Bootstrap 图标不适用于 Amazon S3 和 Heroku(使用 asset_sync gem)

html - 带列表的数据图标