GUIDE gui handles visibility to user defined function

  • Follow


I have 2 GUIDE guis ( a Main gui & a Sub gui)
I'm calling a user defined function in the main gui from one of callbacks in the sub gui.
this user defined function uses the main gui's handles to produce some out puts. 
My Problem is:
when in this function guidata(hObject, handles) gives an error & handles of Main gui are not recognized (visible) how should address this issue? 

P.S. I'm calling this user defined function by its handle that i previously made in the opening function of main gui.
    setappdata(gcf, 'fhRunSS', @RunSS);

& I'm calling it in the sub gui:
    fhRunSS = getappdata(hMainGui, 'fhRunSS');
    feval(fhRunSS);

thanks
0
Reply Sahra 5/6/2010 10:01:07 PM

Sahra winter wrote:
> I have 2 GUIDE guis ( a Main gui & a Sub gui)
> I'm calling a user defined function in the main gui from one of 
> callbacks in the sub gui.
> this user defined function uses the main gui's handles to produce some 
> out puts. My Problem is:
> when in this function guidata(hObject, handles) gives an error & handles 
> of Main gui are not recognized (visible) how should address this issue?
> P.S. I'm calling this user defined function by its handle that i 
> previously made in the opening function of main gui.
>    setappdata(gcf, 'fhRunSS', @RunSS);
> 
> & I'm calling it in the sub gui:
>    fhRunSS = getappdata(hMainGui, 'fhRunSS');
>    feval(fhRunSS);

guidata and appdata are stored in different places. Each handle graphic 
object has guidata, appdata, and userdata.
0
Reply Walter 5/6/2010 10:56:50 PM


thanks walter
how am I suppose to specify how to see my Main gui's handles( to see guidata of my main gui) while executing this function. 
0
Reply Sahra 5/6/2010 11:18:23 PM

Sahra winter wrote:

> how am I suppose to specify how to see my Main gui's handles( to see 
> guidata of my main gui) while executing this function.

You can use guidata() in other routines, as long as you pass in the 
figure number of the gui.
0
Reply Walter 5/6/2010 11:23:24 PM

I actually did use userdata, but it makes new handles for the gui & does not bring the previously defined handles into focus.!! I want all my main gui's handles to be available to this function. 
p.s. I used the technique showed in Doug hull's video on multiple window gui, but the thing is that he is not using handles of his main gui in the user defined function, but I need them
0
Reply Sahra 5/6/2010 11:31:09 PM

I think I just solved the problem by using 
    handles = guidata(Main-gui);
0
Reply Sahra 5/6/2010 11:50:08 PM

"Sahra winter" <sahra18040@gmail.com> wrote in message <hrvkjg$4q5$1@fred.mathworks.com>...
> I think I just solved the problem by using 
>     handles = guidata(Main-gui);

this erases all the handle structure of my main Gui & gives empty fields!!! 
0
Reply Sahra 5/7/2010 1:37:04 AM

Sahra winter wrote:
> "Sahra winter" <sahra18040@gmail.com> wrote in message 
> <hrvkjg$4q5$1@fred.mathworks.com>...
>> I think I just solved the problem by using     handles = 
>> guidata(Main-gui);
> 
> this erases all the handle structure of my main Gui & gives empty fields!!!

Sorry, I took one look at the code that GUIDE generated and said "We're 
going to have to pull that all out and re-write it!" A few years later, 
there are still some nooks and crannies that we haven't finished 
re-writing... when my boss asks for a change to those sections, I frown 
and ask "Are you sure?? That's going to take awhile to rewrite. I'd 
rather redesign that whole section..."
0
Reply Walter 5/7/2010 3:04:17 AM

 
> Sorry, I took one look at the code that GUIDE generated and said "We're 
> going to have to pull that all out and re-write it!" A few years later, 
> there are still some nooks and crannies that we haven't finished 
> re-writing... when my boss asks for a change to those sections, I frown 
> and ask "Are you sure?? That's going to take awhile to rewrite. I'd 
> rather redesign that whole section..."

Dear Walter

how do you suggest to go around this problem? 
in short: 
I have 2 guis: Main and Sub
I need to be able to trigger a user defined function located in Main-gui from the sub gui. This user defined function uses handles of Main gui and also some variables adjusted by the sub-gui as inputs. this function is used several time in a loop & in each loop those adjustable variables are to be set by the sub-gui.
Problem: how can I make handles of main-gui visible, while in user defined func?
0
Reply Sahra 5/11/2010 1:16:08 AM

> Problem: how can I make handles of main-gui visible, while in user defined func?

H = findall(0,'name','MY_MAIN_GUI') % Use the name of your GUI.

Now you can use GUIDATA on H, or wade through the children of H.
0
Reply Matt 5/11/2010 1:29:05 AM

9 Replies
584 Views

(page loaded in 0.097 seconds)

Similiar Articles:













7/21/2012 1:33:46 AM


Reply: