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:
GUI Help

Subject: GUI Help

From: Ashley Wright

Date: 9 Jul, 2010 03:30:20

Message: 1 of 7

I've got a few questions regarding GUI development. I'm making a GUI that will allow the user to input a bunch of different items. To give you a simplified example, I'm trying to allow a user to input characteristics on different animals in a pet store. Each animal will have a separate GUI to input name, color, type of animal (cat or dog) and things like that. Right now I'm trying to do this with guide.

Name: Fluffy (String)
Type: Dog (From Popup Menu that has Cat, Dog, and Fish as string options)
Weight: 20 (String)
Breed: Lab (From listbox??)

My questions are as follows:
1. How can I make the Breed listbox dependent on the type of animal? For example, I want the user to select dog from the popup menu, then have the breed listbox populated by common dog breed names instead of allowing the user to input a text string.
2. How can I make it so the user can input the next animal? I'd like the user to click a box that says something like NEXT animal and then be able to have another screen that allows him/her to put in the same type of data for the next animal.

Thanks for the help!

Subject: GUI Help

From: Matt Fig

Date: 9 Jul, 2010 03:44:05

Message: 2 of 7

1. In the callback for the type listbox, use a SWITCH on the selection to repopulate the breed listbox if necessary.
2. This depends somewhat on what you are going to do with the user's selections. If it was me I might have a pushbutton which indicates that the user is done with that particular animal and would like to enter another animal. This would cause all data to be stored in the appropriate elements of a structure. Then all uicontrols would be reset to initial values. I would probably also have another button which let the user indicate that he was done with all animal inputs. This is the point at which one would need to know what you are going to do with the data.

Subject: GUI Help

From: Walter Roberson

Date: 9 Jul, 2010 03:52:49

Message: 3 of 7

Ashley Wright wrote:

> My questions are as follows:
> 1. How can I make the Breed listbox dependent on the type of animal?
> For example, I want the user to select dog from the popup menu, then
> have the breed listbox populated by common dog breed names instead of
> allowing the user to input a text string.

Set the String parameter of the Breed listbox to a cell array of strings
that lists the possible breeds for the species.

> 2. How can I make it so the user can input the next animal? I'd like
> the user to click a box that says something like NEXT animal and then be
> able to have another screen that allows him/her to put in the same type
> of data for the next animal.

Why would you need to go on to another screen when the current screen
already has the proper controls? Why not just store the data and reset
the controls to their default state?

Subject: GUI Help

From: Ashley Wright

Date: 9 Jul, 2010 04:02:20

Message: 4 of 7

Walter Roberson <roberson@hushmail.com> wrote in message <m2xZn.11992$3%3.4063@newsfe23.iad>...
> Ashley Wright wrote:
>
> > My questions are as follows:
> > 1. How can I make the Breed listbox dependent on the type of animal?
> > For example, I want the user to select dog from the popup menu, then
> > have the breed listbox populated by common dog breed names instead of
> > allowing the user to input a text string.
>
> Set the String parameter of the Breed listbox to a cell array of strings
> that lists the possible breeds for the species.
>
> > 2. How can I make it so the user can input the next animal? I'd like
> > the user to click a box that says something like NEXT animal and then be
> > able to have another screen that allows him/her to put in the same type
> > of data for the next animal.
>
> Why would you need to go on to another screen when the current screen
> already has the proper controls? Why not just store the data and reset
> the controls to their default state?

What would be the best way to do that without overwriting the data?

Subject: GUI Help

From: Walter Roberson

Date: 9 Jul, 2010 05:03:20

Message: 5 of 7

Ashley Wright wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <m2xZn.11992$3%3.4063@newsfe23.iad>...
>> Ashley Wright wrote:

>> > 2. How can I make it so the user can input the next animal? I'd
>> like > the user to click a box that says something like NEXT animal
>> and then be > able to have another screen that allows him/her to put
>> in the same type > of data for the next animal.
>>
>> Why would you need to go on to another screen when the current screen
>> already has the proper controls? Why not just store the data and reset
>> the controls to their default state?
>
> What would be the best way to do that without overwriting the data?

You did not indicate what you want to do with all the data you
collected, so we can't tell you the "best" way.

A way that sounds reasonable for your circumstances would be to use a
structure array, and when the user indicates they have finished entering
the data for an animal, store the information into the next available
structure array member.

AllSpecies = get(handles.species,'String');
thisspecies = AllSpecies{get(handles.species,'Value')};
AllBreeds = get(handles.breeds,'String');
thisbreed = AllBreeds{get(handles.breeds,'Value')};

Animals(end+1).species = thisspecies;
Animals(end).breed = thisbreed;

That sort of thing.

Subject: GUI Help

From: Ashley Wright

Date: 10 Jul, 2010 00:21:06

Message: 6 of 7

Thanks for the help! This is my first GUI so I'm still trying to figure out how all this works.

Subject: GUI Help

From: GUIBuilder

Date: 28 Jun, 2011 17:13:05

Message: 7 of 7

"Ashley Wright" <navyasw02@gmail.com> wrote in message <i1654c$gs5$1@fred.mathworks.com>...
> I've got a few questions regarding GUI development. I'm making a GUI that will allow the user to input a bunch of different items. To give you a simplified example, I'm trying to allow a user to input characteristics on different animals in a pet store. Each animal will have a separate GUI to input name, color, type of animal (cat or dog) and things like that. Right now I'm trying to do this with guide.
>
> Name: Fluffy (String)
> Type: Dog (From Popup Menu that has Cat, Dog, and Fish as string options)
> Weight: 20 (String)
> Breed: Lab (From listbox??)
>
> My questions are as follows:
> 1. How can I make the Breed listbox dependent on the type of animal? For example, I want the user to select dog from the popup menu, then have the breed listbox populated by common dog breed names instead of allowing the user to input a text string.
> 2. How can I make it so the user can input the next animal? I'd like the user to click a box that says something like NEXT animal and then be able to have another screen that allows him/her to put in the same type of data for the next animal.
>
> Thanks for the help!


I am trying to do almost the same thing. I wanted ask if you could provide some of the code if you ever solved this problem?

Thank in advance!

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