uiparent in Matlab 2013b

1 次查看(过去 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
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 中查找有关 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