0

I am developing a tool for image processing on MATLAB using GUIDE. I have a small snag to correct in it. The question is:

*

The user is asked to select one of the two images on the tool (in different axis) and then the handle of this image is passed on using a function for further processing. I am using the function UIGETPREF for this purpose. I want to disable one button on this dialogue when certain condition is true. How can I do that? The documentation does not list any such option.

  • The instruction:

    selectedButton = uigetpref(...
    'mygraphics',...                            % Group
    'imageselection',...            % Preference
    'Select Image',...                        % Window title
    {'Please select a picture to enable labelling on.'
     ''
     'The labelled points will be shown in other two axes after completion'},...
    {1,2;'Image A','Image B'},...        % Values and button strings
     'ExtraOptions','Cancel',...                % Additional button
     'DefaultButton','Image A',...      % Default choice
     'HelpString','Help',...                    % String for Help button
     'HelpFcn','doc(''Axes'');');
    

Thank you.

Tomar
  • 174
  • 1
  • 12
  • Do you mean that under one condition you wish your dialog to display buttons for `ImageA` and `ImageB`, and under another condition just a button for `ImageA`? – Sam Roberts May 15 '13 at 15:32
  • No. Actually it should display the button in all cases but show it as greyed out (disabled). – Tomar May 17 '13 at 15:39

1 Answers1

0

If you want the button grayed out or disabled, you're going to need to either construct your own dialog instead of using uigetpref, or you're going to need to somehow find a hidden handle to the uigetpref dialog, and manually gray out the button.

If you would just like to have the button display or not display depending on your condition, try something like this code:

mycondition = true;
% mycondition = false % Uncomment to test

switch mycondition
    case true
        buttonDetails = {1,2;'Image A','Image B'};
        defaultButton = 'Image B';
    case false
        buttonDetails = {1;'Image A'};
        defaultButton = 'Image A';
end        

selectedButton = uigetpref(...
'mygraphics',...
'imageselection',...
'Select Image',...
{'Please select a picture to enable labelling on.'
 ''
 'The labelled points will be shown in other two axes after completion'},...
 buttonDetails,...
 'ExtraOptions','Cancel',...
     'DefaultButton',defaultButton,...
 'HelpString','Help',...
 'HelpFcn','doc(''Axes'');');
Sam Roberts
  • 23,951
  • 1
  • 40
  • 64