Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
anchor GUI elements

Subject: anchor GUI elements

From: wapo

Date: 14 Dec, 2009 09:19:26

Message: 1 of 4

Hi all,

I am trying to arrange some GUI elements. lets say that i have 10 rows
of two objects. I want vertical and horizontal alignment. I start by
aligning vertically the first column and then I want for each row to
center align the objects in the row. If I try to align them then some
times the vertical alignment of the object in the first column is
destroyed. How can I anchor the objects of the first column and use
them as pivots for aligning the rest of the objects.

Thanks in advance for your help

Apostolos

PS. WindowsXP and Matlab 7.4.0 (R2007a)

Subject: anchor GUI elements

From: Stephen

Date: 14 Dec, 2009 22:09:02

Message: 2 of 4

wapo <apostolos1975@gmail.com> wrote in message <f9941911-23e9-4152-8860-319906e0617f@c3g2000yqd.googlegroups.com>...
> Hi all,
>
> I am trying to arrange some GUI elements. lets say that i have 10 rows
> of two objects. I want vertical and horizontal alignment. I start by
> aligning vertically the first column and then I want for each row to
> center align the objects in the row. If I try to align them then some
> times the vertical alignment of the object in the first column is
> destroyed. How can I anchor the objects of the first column and use
> them as pivots for aligning the rest of the objects.
>
> Thanks in advance for your help
>
> Apostolos
>
> PS. WindowsXP and Matlab 7.4.0 (R2007a)

Are you defining the "position" parameter for each GUI element in xy coordinates? You are doing this with "guide" I suspect?

Stephen

Subject: anchor GUI elements

From: wapo

Date: 15 Dec, 2009 08:29:30

Message: 3 of 4

On Dec 14, 11:09 pm, "Stephen " <smetru...@parker.com> wrote:
> wapo <apostolos1...@gmail.com> wrote in message <f9941911-23e9-4152-8860-319906e06...@c3g2000yqd.googlegroups.com>...
> > Hi all,
>
> > I am trying to arrange some GUI elements. lets say that i have 10 rows
> > of two objects. I want vertical and horizontal alignment. I start by
> > aligning vertically the first column and then I want for each row to
> > center align the objects in the row. If I try to align them then some
> > times the vertical alignment of the object in the first column is
> > destroyed. How can I anchor the objects of the first column and use
> > them as pivots for aligning the rest of the objects.
>
> > Thanks in advance for your help
>
> > Apostolos
>
> > PS. WindowsXP and Matlab 7.4.0 (R2007a)
>
> Are you defining the "position" parameter for each GUI element in xy coordinates?  You are doing this with "guide" I suspect?
>
> Stephen

Yes, I am using GUIDE. I want to have (for example) ten static text
objects in the first column and ten edit text boxes in the second
column. Each static text should be aligned with one edit box in the
second column. I start by aligning vertically the first column but
then due to size differences when i try to center per row the elements
some of the vertically aligned elements are thrown out of place.

As a general comment I should say that GUIDE is not intended for
aesthetically pleasing GUIs.

Apostolos

Subject: anchor GUI elements

From: Stephen

Date: 15 Dec, 2009 15:53:01

Message: 4 of 4

Haha, yes, it is a purely functional tool isn't it?

Try this:
Double click the first object
Find the "Position" parameter
Set the x and y values of the Parameter until the box is where you want it.
Set the width and height until you get the intended size
Now grab the next edit text and repeat, you'll want to use the exact same value for x, and alter y until it is in the right position. Set height and width to be same as first.
Determine the difference between y values in first and second, this offset value will be added to each subsequent placement, continue until all edit boxes are set.

I'm asssuming that your static text is not exactly the same size as the edit text boxes, so finding the initial y value will be a bit trickier. To get them on the same centerline, find the difference in height between the static text and the edit text, divide by two, and subtract from the value of y in the corresponding edit text, this is the y value for the static text. Now you use the same value for the Yoffset as the edit text column and you end up with a perfectly aligned set of static and edit text boxes.

Hope this helps,

Stephen

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us