自定义工具栏问题
非常感谢 eight 给我提供的创建自定义工具栏的程序,每次我发的贴子,你都能给我解决问题,强烈支持你,再一次感谢你!!!我要用MATLAB的GUI来编写图像处理的界面,自己定义工具栏上的菜单,所以最基本的"新建","打开","保存"等这些功能是必须要有的,还有很多功能都需要我自己想(最后做出来的界面最好就像word那样).请问实现"打开","新建"等功能的后台程序应该怎么写?
我查了好多MATLAB书都没有相关程序,请大师们帮帮我,知道哪些书上有相关程序的请告诉我,谢谢你们了! 首先,不要乱叫大师,这里都是初学者。
关于你的问题,新建功能用如下代码,以前在simwe写的,方便起见贴在这里:
function GUIWithMenu
clc
hMainFig=figure('numbertitle','off','units','normalized','tag','hMainFig','menubar','none');
set(hMainFig,'units','normalized','position',[.2,.2,.6,.6]);
set(hMainFig,'defaultuicontrolfontname','隶书');
set(hMainFig,'defaultuicontrolfontsize',13);
set(hMainFig,'defaultuicontrolunits','normalized');
ht = uitoolbar(hMainFig);
X1=imread('newfile.jpg');
hpt1 = uipushtool(ht,'CData',X1,'TooltipString','创建新M-file',...
'ClickedCallback','edit');
附件是必须的图标,其他的保存,打开等,照猫画虎自己用uigetfile、savefig等命令一一实现吧,总之很麻烦,玩玩儿还可以,真去复制WORD的功能个人感觉意义也不大。
[ 本帖最后由 bainhome 于 2007-3-20 19:24 编辑 ] 原帖由 bainhome 于 2007-3-20 19:20 发表
首先,不要乱叫大师,这里都是初学者。
关于你的问题,新建功能用如下代码,以前在simwe写的,方便起见贴在这里:
function GUIWithMenu
clc
hMainFig=figure('numbertitle','off','units','normalized','t ...
bainhome兄息怒,呵呵,你的好东东早就被我发现了,见以下链接:编程问题
我想楼主是不懂如何变成fig文件方式的GUI,以下是一点提示:
% --- Executes just before GUIWithMenu is made visible.
function GUIWithMenu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUIWithMenu (see VARARGIN)
% Choose default command line output for GUIWithMenu
handles.output = hObject;
ht = uitoolbar(handles.figure1);
X1=imread('newfile.jpg');
hpt1 = uipushtool(ht,'CData',X1,'TooltipString','创建新M-file',...
'ClickedCallback','edit');
handles.hpt1 = hpt1;
handles.ht = ht;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUIWithMenu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
不知道把你的语句放在这个函数中是否合适(还是放在其他函数中更好?),呵呵,bainhome兄可否指点一二?
[ 本帖最后由 eight 于 2007-3-20 21:48 编辑 ] 呵呵,三人行,必有我师焉!!
非常感谢二位提供的指点,向你们学习!!!
求助!程序问题
% --- Executes just before GUIWithMenu is made visible.function GUIWithMenu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUIWithMenu (see VARARGIN)
% Choose default command line output for GUIWithMenu
handles.output = hObject;
ht = uitoolbar(handles.figure1);
X1=imread('newfile.jpg');
hpt1 = uipushtool(ht,'CData',X1,'TooltipString','创建新M-file',...
'ClickedCallback','edit');
handles.hpt1 = hpt1;
handles.ht = ht;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUIWithMenu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
我把这段程序编译了,提示有错误
??? Input argument "hObject" is undefined.
Error in ==> GUIWithMenu at 10
handles.output = hObject;
请问这段程序怎么改? 原帖由 bssuda 于 2007-3-21 21:39 发表
% --- Executes just before GUIWithMenu is made visible.
function GUIWithMenu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject h ...
晕~~~楼主你没有接触过GUI吗?建议先看看关于GUI的精华贴
页:
[1]