I am currently developing a GUI for m.file, which I have already completed. The GUI will be one with several pages, with each page being a graphical interface.
In the main graphical interface, the user will make a choice in the group of radio buttons with two parameters. Depending on the choice, the page order should be Master GUI> GUI1> GUI2> GUI3 or Master GUI> GUI1> GUI4> GUI5.
Referring to the example from http://matlabbyexamples.blogspot.sg/2011/10/multipages-gui-forms-combining-from.html , I somehow made it work, I can move from page to page as intended.
The problem is that every time I return to the Master graph to change the selection in the switch group, it will open the entire GUI again and turn off their visibility to hide them again (basically what the program does when I first I open it), which I did not want. As a new MATLAB user, I have no idea why this is.
Below is the code segment for my main gui:
function varargout = StartPage(varargin) % STARTPAGE MATLAB code for StartPage.fig % STARTPAGE, by itself, creates a new STARTPAGE or raises the existing % singleton*. % % H = STARTPAGE returns the handle to a new STARTPAGE or the handle to % the existing singleton*. % % STARTPAGE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in STARTPAGE.M with the given input arguments. % % STARTPAGE('Property','Value',...) creates a new STARTPAGE or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before StartPage_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to StartPage_OpeningFcn via varargin. % % *See GUI Options on GUIDE Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help StartPage % Last Modified by GUIDE v2.5 14-Aug-2013 14:22:36 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @StartPage_OpeningFcn, ... 'gui_OutputFcn', @StartPage_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{:}); end % End initialization code - DO NOT EDIT % --- Executes just before StartPage is made visible. function StartPage_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 StartPage (see VARARGIN) % Choose default command line output for StartPage handles.output = hObject; handles.s1 = InitialCostCalculation; handles.s2 = PVSpecsInput; handles.s3 = PVSummary; handles.s4 = HybridSpecsInput; handles.s5 = HybridSummary; h1=guidata(handles.s1); h1.next = handles.s4; h1.prev = hObject; guidata(handles.s1,h1); h2=guidata(handles.s2); h2.next = handles.s3; h2.prev = handles.s1; guidata(handles.s2,h2); h3=guidata(handles.s3); h3.prev = handles.s2; guidata(handles.s3,h3); h4=guidata(handles.s4); h4.next = handles.s5; h4.prev = handles.s1; guidata(handles.s4,h4); h5=guidata(handles.s5); h5.prev = handles.s4; guidata(handles.s5,h5); % Update handles structure guidata(hObject, handles); handles.output; set(handles.s1,'Visible','off'); set(handles.s2,'Visible','off'); set(handles.s3,'Visible','off'); set(handles.s4,'Visible','off'); set(handles.s5,'Visible','off'); guidata(hObject, handles); % UIWAIT makes StartPage wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = StartPage_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 Pg1Start_Button. function Pg1Start_Button_Callback(hObject, eventdata, handles) % hObject handle to Pg1Start_Button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.output,'Visible','off'); set(handles.s1,'Visible','on'); set(handles.s2,'Visible','off'); set(handles.s3,'Visible','off'); set(handles.s4,'Visible','off'); set(handles.s5,'Visible','off'); % --- Executes when selected object is changed in MainMenu. function MainMenu_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in MainMenu % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) switch get(eventdata.NewValue,'Tag') case 'PV_Button' h1=guidata(handles.s1); h1.next = handles.s2; h1.prev = StartPage; guidata(handles.s1,h1); case 'Hybrid_Button' h1=guidata(handles.s1); h1.next = handles.s4; h1.prev = StartPage; guidata(handles.s1,h1); end % --- Executes on button press in Pg1Close_Button. function Pg1Close_Button_Callback(hObject, eventdata, handles) % hObject handle to Pg1Close_Button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close(gcf);
I would really appreciate if someone could tell me what I'm doing wrong and also provide me with a solution.