关于popup menu的调用函数的问题
那个switch的 代码该怎么样写?图中该设置什么?
多谢大家了
% --- Executes on selection change in sel.
function sel_Callback(hObject, eventdata, handles)
% hObject handle to sel (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 sel contents as cell array
% contents{get(hObject,'Value')} returns selected item from sel
switch sel_data
case 1
haha=str2num(get(handles.input,'string'))
case 2
hehe=str2num(get(handles.input,'string'))
case 3
huhu=str2num(get(handles.input,'string'))
otherwise
hoho=str2num(get(handles.input,'string'))
end
% --- Executes during object creation, after setting all properties.
function sel_CreateFcn(hObject, eventdata, handles)
% hObject handle to sel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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');
end
[ 本帖最后由 HolySaint 于 2007-7-24 19:29 编辑 ] 错误如下
??? Undefined function or variable 'sel_data'.
Error in ==> test>sel_Callback at 84
switch sel_data
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> test at 42
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
哪一项改设成switch的参数呢?
我是想达到这个要求:
分别给四个变量赋值
另外,如果赋一个值后删除edit的内容用clc edit可以吗? 看gui设计的精华帖 自己搞定了一部分
seldata = get(handles.sel, 'Value');
switch seldata
case 1
haha=str2num(get(handles.input,'string'))
case 2
hehe=str2num(get(handles.input,'string'))
case 3
huhu=str2num(get(handles.input,'string'))
otherwise
hoho=str2num(get(handles.input,'string'))
end
但是不能清楚edit的内容
有类似的例子吗?用popup menu的例子? http://forum.vibunion.com/forum/viewthread.php?tid=41997&highlight=%BE%AB%CD%A8GUI%CD%BC%D0%CE%BD%E7%C3%E6%B1%E0%B3%CC
这页的东西我也下不了啊
版主能帮忙传到邮箱里吗?
多谢了啊BIT20040605@gmail.com
回复 #5 HolySaint 的帖子
程序调试遇到错误请参考常见的程序出错问题整理
参考例子请到这个帖子下载
http://forum.vibunion.com/forum/vi ... 6amp%3Btypeid%3D164
[ 本帖最后由 花如月 于 2007-7-24 22:48 编辑 ]
回复 #6 花如月 的帖子
多谢版主大大:handshake 还有一个问题就是我不能保存输入的数据
弹出菜单下选中a输入12
根据我定义的变量输出a=12
但是以后用a的时候还是会出错
说是没定义
怎么把数据输入後保存呢? 请看eight版主的关于gui的精华帖子
页:
[1]