我按照这些说明创建并显示自定义帮助文档:http://www.mathworks.co.uk/help/matlab/matlab_prog/display-custom-documentation.html。我正在为使用GUIDE编写的GUI提供此帮助,并且想知道是否可以从我的GUI直接进入步骤5中描述的“补充软件”页面。我打算将这个程序变成一个独立的应用程序。如果还有其他更好的方法来为独立应用程序创建帮助文档,我也很乐意听到它们。
答案 0 :(得分:1)
并非必须在MatLab文档中嵌入自定义帮助文档。
您可以在menu
中添加专用figure menu bar
来构建自己的文档帮助。
实际上,您可以通过添加个人资料或定义自己的menu bar
来标准化menu bar
,并将其添加到GUI
以代替标准的MatLab。
此外,您还可以context menu
添加uicontrol
GUI
menu
right clicking
uicontrol
上的menu
Bot contextmenu
和format
可以访问多个menu
(HTML,PDF,TXT,...)中编写的文档。
您可以通过GUIDE
或by code
GUIDE
项
Menu Editor
,您可以在GUIDE
工具栏上选择menu
工具。它允许同时创建context menu
和Mneu bar
。通过将GUI窗口的figure
属性设置为menu
,您的added
figure menu bar
将Mneu bar
none
通过将GUI窗口的menu
属性设置为figure menu bar
,您的by code
将成为menu
context menu
您分别使用uimenu
和uicontextmenu
内置函数创建menu
和context menu
。您已经创建了menu item
和/或callback
,您可以在其HTML
中为每个web
指定要打开的文档:
web('my_doc.html') % Open doc with MatLab default browser, if the doc folder is not in the MatLab Path, add the full path
文档,您可以使用web('my_doc.html','-browser') % Open doc with custom browser, if the doc folder is not in the MatLab Path, add the full path
函数,它允许使用默认的MatLab浏览器或自定义浏览器打开文档 PDF
open
open('example.pdf')
文档,您可以使用TXT
函数 winopen
winopen('release_notes.txt')
文档,您可以使用GUI
函数(menu
我构建了一个简单的context menu
来展示menu bar
和pushbutton
的实现:它由axes
,manu bar
和{Menu bar
组成{1}}。
none
仅包含用户定义的项目(pushbutton
属性为axes
),但是,custon菜单中的in项目也允许显示标准MatLab菜单栏
peaks
允许在context menu
由pushbutton
函数生成的曲面中绘图(只是为了让它进行干预);更重要的是,pushbutton
添加了right clicking
,其中包含两项内容。用户可以pushbutton
.m
访问menu
文档
此外,我编写了一个标准的MatLab context manu
脚本,该脚本使用相同的功能创建相同的GUI,以显示如何使用uimenu
创建uicontextmanu
和.m
function varargout = custom_menu_gui(varargin)
% CUSTOM_MENU_GUI MATLAB code for custom_menu_gui.fig
% CUSTOM_MENU_GUI, by itself, creates a new CUSTOM_MENU_GUI or raises the existing
% singleton*.
%
% H = CUSTOM_MENU_GUI returns the handle to a new CUSTOM_MENU_GUI or the handle to
% the existing singleton*.
%
% CUSTOM_MENU_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CUSTOM_MENU_GUI.M with the given input arguments.
%
% CUSTOM_MENU_GUI('Property','Value',...) creates a new CUSTOM_MENU_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before custom_menu_gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to custom_menu_gui_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 custom_menu_gui
% Last Modified by GUIDE v2.5 19-Aug-2015 17:40:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @custom_menu_gui_OpeningFcn, ...
'gui_OutputFcn', @custom_menu_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if 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 custom_menu_gui is made visible.
function custom_menu_gui_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 custom_menu_gui (see VARARGIN)
% Choose default command line output for custom_menu_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes custom_menu_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = custom_menu_gui_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 structure
varargout{1} = handles.output;
%
% Callback for:
% Custom DOC -> Getting Started (HTML) -> Open with browser
% --------------------------------------------------------------------
function open_with_browser_Callback(hObject, eventdata, handles)
% hObject handle to open_with_browser (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
web('my_doc.html','-browser')
%
% Callback for:
% Custom DOC -> Getting Started (HTML) -> Open with MatLab browser
% --------------------------------------------------------------------
function open_with_matlab_browser_Callback(hObject, eventdata, handles)
% hObject handle to open_with_matlab_browser (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
web('my_doc.html')
%
% Callback for:
% Custom DOC -> Reference Manual (PDF)
% --------------------------------------------------------------------
function reference_manual_pdf_Callback(hObject, eventdata, handles)
% hObject handle to reference_manual_pdf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open('example.pdf')
%
% Callback for:
% Custom DOC -> Release Notes (TXT)
% --------------------------------------------------------------------
function release_notes_txt_Callback(hObject, eventdata, handles)
% hObject handle to release_notes_txt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
winopen('release_notes.txt')
%
% Callback for:
% Custom DOC -> Show Standard Menu
% --------------------------------------------------------------------
function show_standard_menu_Callback(hObject, eventdata, handles)
% hObject handle to show_standard_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(strcmp(get(gcf,'menubar'),'figure'))
set(gcf,'menubar','none')
set(hObject,'checked','off')
else
set(gcf,'menubar','figure')
set(hObject,'checked','on')
end
%
% Pushbutton callback, just to make it doing somenting
%
% --- Executes on button press in plot_button.
function plot_button_Callback(hObject, eventdata, handles)
% hObject handle to plot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
peaks
%
% Callback for pushbuton ContextMenu "Open Doc (HTML)
%
% --------------------------------------------------------------------
function open_plot_button_doc_html_Callback(hObject, eventdata, handles)
% hObject handle to open_plot_button_doc_pdf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
web('my_doc.html','-browser')
%
% Callback for pushbuton ContextMenu "Open Doc (PDF)
%
% --------------------------------------------------------------------
function open_plot_button_doc_pdf_Callback(hObject, eventdata, handles)
% hObject handle to open_plot_button_doc_pdf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open('example.pdf')
函数。
在下文中,您可以找到源代码和显示GUI的图片。
% Create the Main Window
the_fig=figure('unit','normalized','menubar','none', ...
'color',[0.9412 0.9412 0.9412],'position',[0.4 0.5 0.5 0.3]);
% Create the Axes
the_ax=axes('position',[0.07 0.1 0.5 0.7500],'unit','normalized');
% Create the Pushbutton uicontrol
the_pb=uicontrol('style','pushbutton','unit','normalized', ...
'position',[.7 .7 .2 .2], 'string','Plot', ...
'tooltipstring','Right Click for Menu','callback','peaks;');
% Create the Main Custom Menu
the_menu=uimenu(the_fig,'label','Custom DOC');
% Create the first sub-menu
the_sub_menu=uimenu(the_menu,'label','Getting Started (HTML)');
% Create the 2 menu items belongoing to the sub-menu
the_sub_menu_1=uimenu(the_sub_menu,'label','Open with browser', ...
'callback',['web(''my_doc.html'',''-browser'')']);
the_sub_menu_2=uimenu(the_sub_menu,'label','Open with MatLab browser', ...
'callback',['web(''my_doc.html'')']);
% Creater 3 su-menu belonging to the main menu
the_sub_menu_3=uimenu(the_menu,'label','Reference manual (PDF)', ...
'callback',['open(''example.pdf'')']);
the_sub_menu_4=uimenu(the_menu,'label','Release notes (TXT)', ...
'callback',['winopen(''release_notes.txt'')']);
the_sub_menu_5=uimenu(the_menu,'label','Show Standard Menu', ...
'callback','show_std_menu');
% Create the uicontext menu of the pushbutton
the_context_menu=uicontextmenu;
% Create the menu items of the uicontext menu
uimenu(the_context_menu,'label','Open ODC (HTML)', ...
'callback',['web(''my_doc.html'',''-browser'')'])
uimenu(the_context_menu,'label','Open ODC (PDF)', ...
'callback',['open(''example.pdf'')'])
% Assign the uicontextmenu to the pushbutton
set(the_pb,'uicontextmenu',the_context_menu);
个文件the_sub_menu_5 callback
% If the Figure menubar is on
if(strcmp(get(gcf,'menubar'),'figure'))
% Remove it
set(gcf,'menubar','none')
% Un-check the menu item
set(the_sub_menu_5,'checked','off')
% If the Figure menubar is off
else
% Show it
set(gcf,'menubar','figure')
% Check the menu item
set(the_sub_menu_5,'checked','on')
end
fos_user:
........
registration:
form:
......
type: your_form_type_id
的show_std_menu.m脚本
services:
user.your_form_type.form.type:
class: MyBundle\Form\MyRegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: your_form_type_id }
希望这有帮助。