问题描述
我想在面板上方显示照片,我在这里查看文档: http://www.mathworks.com/help/matlab/ref/uistack.html 但仅在图
i want to display photo above the panel , i see the documentation here : http://www.mathworks.com/help/matlab/ref/uistack.htmlbut it only mention how to use this function (uistack) only in figure
我的程序到现在为止:
我的代码:
function varargout = panel(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @panel_OpeningFcn, ...
'gui_OutputFcn', @panel_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
handles.output = hObject;
guidata(hObject, handles);
function varargout = panel_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
k = 1;
[filename pathname] = uigetfile({'*.*'},'File Selector','MultiSelect', 'on')
iscellstr(filename)
celldata1 = cellstr(pathname)
celldata2 = cellstr(filename)
celldata3 = strcat(celldata1,celldata2)
subplot(3,4,1),imshow(celldata3{1})
subplot(3,4,2),imshow(celldata3{2})
subplot(3,4,3),imshow(celldata3{3})
subplot(3,4,4),imshow(celldata3{4})
subplot(3,4,5),imshow(celldata3{5})
subplot(3,4,6),imshow(celldata3{6})
推荐答案
我要求版本的原因是,如果您使用的是较旧的版本(比R2014b更高),则可以设置uipanel
的BackgroundColor
属性.成为无",这将使其透明.此功能"在R2014b及更高版本中不起作用...
The reason I asked for the version was that if you were using an older version (than R2014b) you could set the BackgroundColor
property of the uipanel
to be 'none' which would make it transparent. This "feature" doesn't work in R2014b onwards...
%% Only HG1 (pre R2014b)
f = figure;
subplot ( 3, 3, 4 )
uipanel ( 'parent', f, 'Position', [0. 0. 0.6 0.6], 'BackgroundColor', 'none' );
恐怕其他选项将需要更多有关GUI的工作方式的知识-特别是从命令行(而不是在GUIDE中)创建GUI:
Im afraid other options will require more knowledge of how GUI's work - specifically creating GUI's from the commandline (and not in GUIDE):
% Create a figure
f = figure;
% Create a uicontainer (this is a way of grouping controls together
uic = uicontainer ( 'parent', f, 'position', [0.1 0.1 0.5 0.5] );
% Create an axes -> which is a child of the UICONTAINER
ax = axes ( 'parent', uic, 'position', [0 0 1 1] );
% Create a uipanel -> which is a chilf of the FIGURE
uipanel ( 'parent', f, 'position', [0 0 0.4 0.7] );
% Some data to plot
image(rand(100)*255,'parent',ax)
% Note at this point the axes is underneath the uipanel
%%
% Hey presto we can move the uicontainer to the top and the axes appears! :)
uistack ( uic, 'top' )
注意::如果您在创建uipanel
之后创建uicontainer
,则无需使用uistack
-我按此顺序放置它以显示uistack将移动"axes" 按堆栈顺序...
Note: If you create the uicontainer
after creating the uipanel
then you dont need to use uistack
- I put it in that order to show that uistack will move the 'axes' in the stack order...
这篇关于MATLAB新手-在指南上方的面板上方显示照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!