📄 gui_demo_matlabsky.m
字号:
function varargout = gui_demo_matlabsky(varargin)% GUI_DEMO_MATLABSKY M-file for gui_demo_matlabsky.fig% GUI_DEMO_MATLABSKY, by itself, creates a new GUI_DEMO_MATLABSKY or raises the existing% singleton*.%% H = GUI_DEMO_MATLABSKY returns the handle to a new GUI_DEMO_MATLABSKY or the handle to% the existing singleton*.%% GUI_DEMO_MATLABSKY('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in GUI_DEMO_MATLABSKY.M with the given input arguments.%% GUI_DEMO_MATLABSKY('Property','Value',...) creates a new GUI_DEMO_MATLABSKY or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before gui_demo_matlabsky_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to gui_demo_matlabsky_OpeningFcn via varargin.%% *See GUI Options on GUIDE's 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 gui_demo_matlabsky% Last Modified by GUIDE v2.5 21-Mar-2009 17:42:31% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_demo_matlabsky_OpeningFcn, ... 'gui_OutputFcn', @gui_demo_matlabsky_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 gui_demo_matlabsky is made visible.function gui_demo_matlabsky_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 gui_demo_matlabsky (see VARARGIN)% Choose default command line output for gui_demo_matlabskyhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_demo_matlabsky wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_demo_matlabsky_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 structurevarargout{1} = handles.output;% --- Executes on button press in pb.function pb_Callback(hObject, eventdata, handles)% hObject handle to pb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)logo=imread('logo.jpg');set(hObject,'Cdata',logo,'string','')set(handles.st,'string','为Pushbutton按钮添加背景图像');% --- Executes during object creation, after setting all properties.function pb_CreateFcn(hObject, eventdata, handles)% hObject handle to pb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'string','Push Here,Add A Imgine Background For the PushButton');% --- Executes on button press in tb.function tb_Callback(hObject, eventdata, handles)% hObject handle to tb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of tbset(handles.st,'string','演示ToggleButton按钮的状态与value、max和min属性的关系')value=get(hObject,'value');max=get(hObject,'max');min=get(hObject,'min');if value==max set(hObject,'string',['value=' num2str(value) ',max=' num2str(max) ',so the state is down']);else set(hObject,'string',['value=' num2str(value) ',min=' num2str(min) ',so the state is up']);end% --- Executes during object creation, after setting all properties.function tb_CreateFcn(hObject, eventdata, handles)% hObject handle to tb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'max',100,'min',10);set(hObject,'value',10);function et_Callback(hObject, eventdata, handles)% hObject handle to et (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of et as text% str2double(get(hObject,'String')) returns contents of et as a doubleset(handles.st,'string','Now Edit_Callback Is Running');% --- Executes during object creation, after setting all properties.function et_CreateFcn(hObject, eventdata, handles)% hObject handle to et (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endset(hObject,'max',2);set(hObject,'string',{'This is the multiple lines demo','——by matlabsky'});% --- Executes on selection change in lb.function lb_Callback(hObject, eventdata, handles)% hObject handle to lb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns lb contents as cell array% contents{get(hObject,'Value')} returns selected item from lbnum=get(hObject,'value');string=get(hObject,'string');item=string{num};str=(['the ' num2str(num),'-th item ''' item ''' is selected']);set(handles.st,'string',str);% --- Executes during object creation, after setting all properties.function lb_CreateFcn(hObject, eventdata, handles)% hObject handle to lb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endset(hObject,'string',{'西工大','西交大','中科大','复旦','同济','北大','清华'})handles% --- Executes on slider movement.function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function slider1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function sl_Callback(hObject, eventdata, handles)% hObject handle to sl (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slidervalue=get(hObject,'value');str=['Now Slider_Callback Is Running,The Current Value Is ' num2str(value)];set(handles.st,'string',str);% --- Executes during object creation, after setting all properties.function sl_CreateFcn(hObject, eventdata, handles)% hObject handle to sl (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes during object creation, after setting all properties.function bg_CreateFcn(hObject, eventdata, handles)% hObject handle to bg (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% --- Executes when selected object is changed in bg.function bg_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in bg % 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)str=[get(hObject,'tag') ' is selected,anothers must be unselected'];set(handles.st,'string',str)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -