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 Center および File ExchangeDialog Boxes についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by