uiparent in Matlab 2013b

3 visualizaciones (últimos 30 días)
Vlad
Vlad el 5 de Mzo. de 2015
Respondida: Adam el 5 de Mzo. de 2015
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*?

Respuestas (2)

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

Iniciar sesión para comentar.


Adam
Adam el 5 de Mzo. de 2015
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.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by