简体   繁体   English

从现有的GUI Matlab打开“新图形”窗口

[英]Open New Figure Window from Existing GUI Matlab

Please, I have created this sample GUI. 拜托,我已经创建了这个示例GUI。 I want to be able to open a new GUI from the old one that contains the same information just like in MSWord where the Submenu 'New' always opens a new MSWord document. 我希望能够从包含相同信息的旧GUI中打开一个新GUI,就像在MSWord中一样,子菜单“ New”始终会打开一个新的MSWord文档。 I don't know if my effort is really the answer since it opens a new figure alright but for a big code, will I always copy and paste? 我不知道我的努力是否真的是答案,因为它打开了一个新的图形,但是对于大型代码,我将始终复制并粘贴吗? Please is there a better way to do this? 请问有更好的方法吗? Thank you. 谢谢。

function []=workmenu()
f=figure('MenuBar','None');
mh=uimenu(f,'Label','File');
mh1=uimenu(f,'Label','Edit');

mh_chd1=uimenu(mh,'Label','New'); %Submenu of mh
set(mh_chd1,'callback',{@newopen}); %Callback for mh_chd1

%Create pop up menu
pp=uicontrol(f,'Style','popupmenu','string',{'One';'Two';'Three'},...
'pos',[30 250 130 20]);

function []=newopen(varargin)
f=figure('MenuBar','None');
mh=uimenu(f,'Label','File');
mh1=uimenu(f,'Label','Edit');

mh_chd1=uimenu(mh,'Label','New'); %Submenu of mh
set(mh_chd1,'callback',{@newopen}); %Callback for mh_chd1

%Create pop up menu
pp=uicontrol(f,'Style','popupmenu','string',{'One';'Two';'Three'},...
'pos',[30 250 130 20]);
end

end

Ok, this is what I found out. 好的,这就是我发现的。 It still opens a new figure alright. 仍然可以打开一个新的数字。

function []=workmenu()
f=figure('MenuBar','None');
mh=uimenu(f,'Label','File');
mh1=uimenu(f,'Label','Edit');

mh_chd1=uimenu(mh,'Label','New'); %Submenu of mh
set(mh_chd1,'callback',{@newopen}); %Callback for mh_chd1

%Create pop up menu
pp=uicontrol(f,'Style','popupmenu','string',{'One';'Two';'Three'},...
'pos',[30 250 130 20]);

function []=newopen(varargin)
    workmenu
end

end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM