Adding a push button to a figure without using GUIDE

조회 수: 21 (최근 30일)
Jason
Jason 2014년 12월 5일
댓글: Jason 2014년 12월 5일
Is there a reason why I'm not seeing the pushbutton on the figure? Thanks Jason
hFig=figure('Position',[200 200 1600 600]);
movegui(hFig,'center')
%Add pushbutton to view data
ButtonH=uicontrol('Parent',hFig,'Style','pushbutton','String','View Data','Position',[0.0 0.5 0.4 0.2],'Units','normalized','Visible','on');

채택된 답변

Adam
Adam 2014년 12월 5일
편집: Adam 2014년 12월 5일
You have to specify the Units before the Position else default units of characters are used, meaning your push button will be minuscule with your current code. Use this instead:
ButtonH=uicontrol('Parent',hFig,'Style','pushbutton','String','View Data','Units','normalized','Position',[0.0 0.5 0.4 0.2],,'Visible','on');

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 12월 5일
If you really want to take on the burdensome task of building a complete GUI from scratch using bunches of uicontrol() calls, see Matt Fig's File Exchange http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples
  댓글 수: 3
Image Analyst
Image Analyst 2014년 12월 5일
Nonetheless, there's some good stuff there. It's still worth taking a look at, at least I think so.
Jason
Jason 2014년 12월 5일
Yes of course, thanks for passing the link.

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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by