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 External Main Functions

Subject: GUI External Main Functions

From: Nick

Date: 24 Mar, 2011 20:54:05

Message: 1 of 4

I apologize if this has been answered in the past, I cannot seem to find an easy explanation for this.

The short version of what I am trying to accomplish is that I want to create a main function inside a GUI that can execute after the init and opening functions have completed and the GUI has appeared on the screen. If I try putting a call to a main loop inside the opening function, it will execute before the window even opens, and I do not want to mess with the init function at all.

Is it possible to create a wrapper to the GUI and update the fields using that instead? This might be a rookie question, but I could not find any guides for how to do this. I have no idea how to modify handles from outside the GUI script.

Ideally what I would like to do is have a main function inside the GUI script that I can just call AFTER the window has opened, but that doesn't seem to be possible.

Again, I might just be having a hard time finding the resources for doing something like this, so if someone can point me in a direction I would be very grateful. Thank you!

Subject: GUI External Main Functions

From: Nick

Date: 24 Mar, 2011 22:11:04

Message: 2 of 4

I actually ended up figuring this out over time and did not realize it was this easy.

Matlab already provides a guihandles process, so I just turned the GUI into an object an ran it from a wrapper.

That is:

mywindow = myguiscript();
myhandles = guihandles(mywindow);

myhandles now allows me to manipulate the object callbacks as if I were in the gui script.

Subject: GUI External Main Functions

From: Ioan Alexandru

Date: 13 Mar, 2013 19:29:11

Message: 3 of 4

"Nick" wrote in message <imgfho$cb6$1@fred.mathworks.com>...
> I actually ended up figuring this out over time and did not realize it was this easy.
>
> Matlab already provides a guihandles process, so I just turned the GUI into an object an ran it from a wrapper.
>
> That is:
>
> mywindow = myguiscript();
> myhandles = guihandles(mywindow);
>
> myhandles now allows me to manipulate the object callbacks as if I were in the gui script.

Hello Nick. Could you please provide a bit more info on how I would actually apply this in a function?
To simplify the example, I would like to modify the text in a static text box which is part of a Guide GUI from an external matlab function. When I say external I mean is not part of the GUI Guide .m file at all; it is just a separate matlab file. I would like to call that text box to update from this external matlab file.
Thank you very much and I look forward to your reply.

 

Subject: GUI External Main Functions

From: Kristin

Date: 19 Mar, 2013 23:09:05

Message: 4 of 4

"Ioan Alexandru" wrote in message <khqk27$6hn$1@newscl01ah.mathworks.com>...
> "Nick" wrote in message <imgfho$cb6$1@fred.mathworks.com>...
> > I actually ended up figuring this out over time and did not realize it was this easy.
> >
> > Matlab already provides a guihandles process, so I just turned the GUI into an object an ran it from a wrapper.
> >
> > That is:
> >
> > mywindow = myguiscript();
> > myhandles = guihandles(mywindow);
> >
> > myhandles now allows me to manipulate the object callbacks as if I were in the gui script.
>
> Hello Nick. Could you please provide a bit more info on how I would actually apply this in a function?
> To simplify the example, I would like to modify the text in a static text box which is part of a Guide GUI from an external matlab function. When I say external I mean is not part of the GUI Guide .m file at all; it is just a separate matlab file. I would like to call that text box to update from this external matlab file.
> Thank you very much and I look forward to your reply.
>

You will need to pass the handles structure (or whatever GUIDE calls it) into this function. To update the text:
set(textbox_handle, 'String', 'this is a new string!');

Tags for 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