回 帖 发 新 帖 刷新版面

主题:设置工具栏出问题?

X1=imread('打开.bmp'); 
X2=imread('保存.bmp');
X3=imread('打印.bmp');
X4=imread('放大.bmp');
X5=imread('undo.bmp');
X6=imread('redo.bmp');
% 建立工具栏
uipushtool('Separator','on','TooltipString','打开','ClickedCallback',...
           @open_Callback,'CData',X1);
uipushtool('Separator','on','TooltipString','保存','ClickedCallback',...
           @save_Callback,'CData',X2);
uipushtool('Separator','on','TooltipString','打印','ClickedCallback',...
           'printdlg','CData',X3);
uipushtool('Separator','on','TooltipString','放大','ClickedCallback',...
           @image_zoom_Callback,'CData',X4);
uipushtool('Separator','on','TooltipString','撤消','ClickedCallback',...
           @remove_Callback,'CData',X5);
uipushtool('Separator','on','TooltipString','恢复','ClickedCallback',...
           @resume_Callback,'CData',X6);
创建工具栏成功,但是只有open能正常使用,其它的都提示
?? Input argument "handles" is undefined.
??? Error while evaluating uipushtool ClickedCallback.
这是为什么,请指教,open_Callback里也用到handles!

回复列表 (共4个回复)

沙发

你要先建立一个工具栏,用uitoolbar,然后才能用uipushtool或uitoggletool,其中在uipushtool中的第一个参数就应该是工具栏的句柄。比如:
htb=uitoolbar();
hpushbtn1=(htb,'Separator','on','TooltipString','撤消','ClickedCallback',...
           @remove_Callback,'CData',X5);
这样才可以的。
UITOOLBAR Create a toolbar in a figure window.
    UITOOLBAR creates an empty toolbar with default property values in the
    current figure window and returns a handle to it.
 
    UITOOLBAR('PropertyName1', value1, 'PropertyName2', value2,...)
    creates an empty toolbar with the specified properties in the current
    figure window and returns a handle to it.
 
    UITOOLBAR(FIG, ...) creates an empty toolbar in the specified figure.
 
    H = UITOOLBAR(...) creates an empty toolbar and assigns the handle to H.
 
    UITOOLBAR properties can be set at object creation time using the
    PropertyName/PropertyValue pair arguments to UITOOLBAR, or changed
    later using the SET command.
 
    Execute GET(H) to see a list of UITOOLBAR object properties and their
    current values. Execute SET(H) to see a list of UITOOLBAR object
    properties and legal property values. See the reference guide for more
    information.





UIPUSHTOOL Create a pushbutton in the toolbar of a figure window.
    UIPUSHTOOL creates a pushbutton control in the last added toolbar
    of the current figure window and returns a handle to it.
 
    UIPUSHTOOL('PropertyName1', value1, 'PropertyName2', value2,...)
    creates a pushbutton control with the specified properties in the
    toolbar and returns a handle to it.
 
    UIPUSHTOOL(TBAR, ...) creates a pushbutton control in the specified
    toolbar.
 
    H = UIPUSHTOOL(...) creates a pushbutton control and assigns a
    handle to H.
 
    UIPUSHTOOL properties can be set at object creation time using the
    PropertyName/PropertyValue pair arguments to UIPUSHTOOL, or changed
    later using the SET command.
 
    Execute GET(H) to see a list of UIPUSHTOOL object properties and their
    current values. Execute SET(H) to see a list of UIPUSHTOOL object
    properties and legal property values. See the reference guide for more
    information.

板凳

万分感谢

3 楼

不过我试过了,还是不行!同样的提示!

4 楼

如果你用Matlab2007b版本就不用自己编程序来实现工具栏了,因为2007b中有一个工具栏编辑器,很方便的,我就是因为这个才装2007b,下载地址我的博客有的,去看看吧

我来回复

您尚未登录,请登录后再回复。点此登录或注册