what is the handle for my uipanel, GUIDE

3 views (last 30 days)
hi, I have created a uipnel in GUIDE. how can I find the handle to that uipanel? I want to use that uipanel to place a waitbar in it using a function I found here: http://www.mathworks.com/matlabcentral/fileexchange/23169-improved-waitbar
but I cant find the hanndle to that uipnael.
  1 Comment
Milad
Milad on 4 Dec 2014
the name of my gui is g1.m associated with gi.fig
in command window:
>> h=g1
h =
173.0012
>> handles = guihandles(h)
handles =
figure1: 173.0012
waitbarr: 182.0012
exitt: 181.0012
pushbutton28: 180.0012
text24: 179.0012
push_opendatafile: 178.0012
text23: 177.0012
run_examine_N: 176.0012
panel_Nvalues: 15.0013
optimization: 11.0013
axes1: 6.0013
panel1: 3.0013
begin: 0.0013
run1: 174.0012
text18: 175.0012
editN: 17.0013
popup_Nvalues: 16.0013
help1: 14.0013
no: 13.0013
yes: 12.0013
reload: 5.0013
import: 4.0013
single: 2.0013
monte_carlo: 1.0013
doesnt this mean that the handle of my waitbar is 182.0012?
then why I get this response:
>> get(182.0012)
Error using handle.handle/get
Invalid or deleted object.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 5 Dec 2014
The handle is handles.panel1. You use that instead of the actual number. For what it's worth, here is the progress bar code I use:
%--------------------------------------------------------------------
% Displays a progress bar on the figure at the specified location.
% percentageDone should be a number between 0 and 1.
function handleToProgressBar = DisplayProgressBar(varargin)
%DisplayProgressBar: A progress bar that can be embedded in a GUI figure.
% Syntax and sample calling:
% progressBarPosition = [.007 .46 .38 .027]; % Position of progress bar in normalized units.
% handleToProgressBar = DisplayProgressBar(progressBarPosition);
% for k = 1:100
% percentageDone = k / 100;
% DisplayProgressBar(handleToProgressBar, percentageDone)
% end
% % Delete the progress bar. Make it disappear.
% delete(handleToProgressBar);
% Written by Doug Schwarz, 11 December 2008
try
if ishandle(varargin{2})
% Progress Bar axes exist already. Just need to set the value.
handleToProgressBar = varargin{2};
%msgboxw('Progress bar already exists.');
value = varargin{3}; % Percent done, in the range 0-1.
numberOfImagesAlreadySnapped = int32(varargin{4});
grandTotalOfImages = int32(varargin{5});
p = get(handleToProgressBar, 'Child');
x = get(p, 'XData');
x(3:4) = value;
set(p, 'XData',x);
caption = sprintf('%d of %d Images = %.2f%%Done', numberOfImagesAlreadySnapped, grandTotalOfImages, value*100);
title(handleToProgressBar, []);
title(handleToProgressBar, caption);
return;
else
% Progress Bar axes doesn't yet exist. Need to create one.
% First argument is the size (not a handle).
%msgboxw('Progress bar does not exist yet. First argument is the location and size (not a handle).');
h = varargin{1}; % Get the handles structure.
progressBarPosition = varargin{2};
% Make sure we're on this figure, not the calibration figure like we are if we launch this from calibrate().
figure(h.figMainWindow);
drawnow;
if length(progressBarPosition) < 4
%msgboxw('Problem: length(progressBarPosition) = %d.', length(progressBarPosition));
% Should not happen. If it does, set up default.
progressBarPosition = [.007 .46 .38 .027];
end
backgroundColor = [236 0 140] / 255; % Fuschia, magenta.
foregroundColor = [0 128 0] / 255; % Dark Green
handleToProgressBar = axes('Units', 'normalized',...
'Position',progressBarPosition,...
'XLim',[0 1], 'YLim',[0 1],...
'XTick',[], 'YTick',[],...
'Color', backgroundColor,...
'XColor', backgroundColor, 'YColor', backgroundColor);
patch([0 0 0 0], [0 1 1 0], foregroundColor,...
'Parent', handleToProgressBar,...
'EdgeColor', 'none',...
'EraseMode', 'none');
% set(h, 'units', 'normalized');
% Set up a title for it.
title(handleToProgressBar, []);
title(handleToProgressBar, '0% Done');
end
catch ME
message = sprintf('Error in DisplayProgressBar():\n%s', ME.message);
WarnUser(message);
end
return; % from DisplayProgressBar()
  1 Comment
Milad
Milad on 11 Dec 2014
thanks Image Analyst. that was the answer to my question.

Sign in to comment.

More Answers (2)

Milad
Milad on 5 Dec 2014
any idea?

Adam
Adam on 5 Dec 2014
Edited: Adam on 5 Dec 2014
handles.panel1
I would imagine since it doesn't look like you changed its tag. I don't know anything about that waitbar submission though as I use a different one that is in its own figure rather than embedded.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!