uiparent in Matlab 2013b

조회 수: 2 (최근 30일)
Vlad
Vlad 2015년 3월 5일
답변: Adam 2015년 3월 5일
Good day everyone.
I have a question about syntax of a "uipanel". In documentation of my 2013b version I see the following:
Section "Description"
p = uipanel( parent ,Name,Value,...) creates a uipanel with a specific parent and one or more uipanel properties.
And in the "Example":
h = figure; hp = uipanel('Title','Main Panel','FontSize',12,... 'BackgroundColor','white',... 'Position',[.25 .1 .67 .67]);
hsp = uipanel( 'Parent',hp ,'Title','Subpanel','FontSize',12,... 'Position',[.4 .1 .5 .5]);
Does *parent* in Description really mean *'Parent',hp* or I can write just *hp* as a *parent*?

답변 (2개)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 3월 5일
These are value/pair arguments. That means you have to write explicitly:
hsp = uipanel('Parent', hp)
  댓글 수: 1
Vlad
Vlad 2015년 3월 5일
At least for me it is not obvious that parent == ('Parent', hp). But OK, take noe of it.
Thanx.

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


Adam
Adam 2015년 3월 5일
Matlab functions usually have numerous allowed calling syntaxes. In some cases if you use 'Name', 'Value' pairs for any of the arguments you must do so for all the arguments.
However, in other cases this is not necessary.
p = uipanel
p = uipanel(Name,Value,...)
p = uipanel(parent)
p = uipanel(parent,Name,Value,...)
are the allowed calling syntaxes (in Matlab R2014b - I assume it hasn't changed since R2013b) for a uipanel.
As you can see, parent is the one argument that is different from all the rest and can be passed in without the 'Parent' name field if you so wish. So where parent is concerned:
hsp = uipanel( 'Parent',hp ,'Title','Subpanel','FontSize',12,... 'Position',[.4 .1 .5 .5]);
and
hsp = uipanel( hp ,'Title','Subpanel','FontSize',12,... 'Position',[.4 .1 .5 .5]);
should be exactly equivalent.
Note though that every other argument passed to uipanel must be in the form of 'Name', 'Value' pairs.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by