필터 지우기
필터 지우기

Create a PushButton with text

조회 수: 2 (최근 30일)
Armindo
Armindo 2016년 1월 12일
댓글: Adam Danz 2020년 4월 28일
Hi,
I can add an image to a PushButton and some text (which overlap the image). However I need to have text next to the Image in the same PushButton. In the past in c# I created a button with text and an image I was onder how can I do this in matlab. Using OOP we should be able to inherit from handle graphic objects but this dont seems the case. How can I produce a button like this?
  댓글 수: 1
Adam Danz
Adam Danz 2020년 4월 28일
This is easy to do in AppDesigner. The image is loaded from the Icon property and then you can use the IconAlignment to position the image relative to the text (demonstrated here).

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2016년 1월 12일
편집: Jan 2016년 1월 17일
You can use the HTML methods to customize uicontrol's:
pic = fullfile(matlabroot, ...
'\toolbox\shared\dastudio\@DAStudio\@ViewmarkManager\spinner.gif');
pic = strrep(pic, '\', '/');
uicontrol('Style', 'PushButton', 'Position', [10, 10, 200, 50], ...
'String', ['<html><img src = "file:/', pic, '"> Hello!'])
Creating a table inside the button is a powerful alternative also.
  댓글 수: 3
Jan
Jan 2016년 1월 17일
@Armindo: You see, that the formatting is done in HTML. Then the standard HTML styles are working, here the align parameter:
...
'String', ['<html><img align="middle" src="file:/', pic, '"> Hello!']
Armindo
Armindo 2016년 1월 21일
Thank you very much for the help. Solved.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by