calling one GUI from another GUI?

hey!!
i am trying to call one gui from another gui using this code for the push buttons suppose from GUI_1 i have to call GUI_2
pushbutton1_Callback(GUI_2);
GUI_2.m;
errordlg('Ok the call back is linked');
its working for one of the gui's but not for the other. this is the error which m getting
*Error in sample>pushbutton2_Callback (line 94)
pushbutton2_Callback(start_gui_single_mode);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in sample (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)sample('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback*
for the source code please refer:
i am new to matlab, please help!!

2 Commenti

Jan
Jan il 6 Mag 2013
This is the part of the error message, which explaines where the problem occurred. But the part is missing, which tells what the error is.
Jan
Jan il 6 Mag 2013
The reference to page, which contains about 24 links, is not helpful. Of course the readers of this forum will not read all of them to find out more.

Accedi per commentare.

Risposte (1)

Jan
Jan il 6 Mag 2013
You call a function by using its name without file extension:
GUI_2; % Instead of: GUI_2.m;
I'm not sure if this causes your problem, but it is at least not correct.

11 Commenti

niyeti
niyeti il 6 Mag 2013
i have tried that already but it isn't working. Gives the same error.
Unfortunately you do not tell us, what the error message tells you, but only, that the error appears in line 94. But we cannot know, which is the line 94, as I have mentioned in my comment already.
pushbutton1_Callback(GUI_2);
This looks strange also. But without a crystal ball I cannot know what this line should do. When GUI_2 is a function call, it is not really well placed in this line - perhaps.
Please do not let us guess the details.
niyeti
niyeti il 6 Mag 2013
Modificato: niyeti il 6 Mag 2013
m sorry for the inconvenience
the code is:
//
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @sample_OpeningFcn, ...
'gui_OutputFcn', @sample_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:}); /////line no 42
end
% End initialization code - DO NOT EDIT
function sample_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to sample (see VARARGIN)
% Choose default command line output for sample
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes sample wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = sample_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pushbutton2_Callback(start_gui_single_mode); ////line no 94
start_gui_single_mode;
errordlg('Ok the call back is linked');////line no 96
//
and the here the fingerprint recognition code (in the code start_gui_single_mode) is available on this site:
and on this page the source code is available at the end of the page. u can download .m files from there if u want.
thank you for replying!!
Can you put a debug button before the line
start_gui_single_mode;
and tell us if your code can reach this line at all?
why do u need to call the function
pushbutton2_Callback(start_gui_single_mode);
from inside itself?
its not reaching beyond
pushbutton2_Callback(start_gui_single_mode);
this is not the only GUI that i am calling from inside, the other one is working perfectly, but not this one.
This is not right:
function pushbutton2_Callback(hObject, eventdata, handles)
//....
pushbutton2_Callback(start_gui_single_mode);
you cannot call pushbutton2_Callback function inside itself. You can call another GUI (child) from inside a parent GUI, but calling same function from inside itself is problematic.
niyeti
niyeti il 7 Mag 2013
No i'm calling two child GUIs from a parent GUI. the other GUI is working perfectly. M making a multimodal biometric recognition system, in which i am calling two separate systems from a single GUI.
I totally agree with Babak. It is very strange when you are calling a callback from the callback itself. Even though, it is a regular function, it is supposed to be called when an event occurs!!! I am also not experienced but this is how I understand the event/callback mechanism. Besides, you have three parameters at the callback definition but you seem to pass only one when you actually call the function; and your parameters during the call is a function name like you would like to pass a function handle. It really looks wrong to me.
just use close(filename) filename(to which u want to open)
Le Dung
Le Dung il 26 Dic 2018
Modificato: Le Dung il 26 Dic 2018
dear Jan
I have two GUI , one is vefrf, and other is Printedit. i saved at the desktop
I want to open GUI Printedit when use a push button.
I used command: (as you recommanded above)
Printedit;
in function Callback of push buttoon in GUI 1. And, it worked fine.
And then, i cut all file (m.file and fig.file of two GUIs to a E:\ ....(not is C:\)
And, now, when i run GUI, click on push button in GUI 1, Matlab didn't open GUI 2.
Why ???????
Please help me!

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Centro assistenza e File Exchange

Richiesto:

il 6 Mag 2013

Modificato:

il 26 Dic 2018

Community Treasure Hunt

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

Start Hunting!

Translated by