Hi all, I've run into a strange problem while trying to incorporate radio buttons into my GUI. I'm programming it completely, and I've run into the following error:
Error using uiradiobutton (line 11)
Functionality not supported with figures created with the figure function. For more information, see Graphics Support in App Designer.
So I'm not using App Designer at all, and I've almost copied the example line by line.
Here's my code:
scrsz = get(0,'ScreenSize');
screensize_factor = 0.5;
figsize = [(scrsz(3)*(1-screensize_factor))./2 (scrsz(4)*(1-screensize_factor))./2 ...
scrsz(3)*screensize_factor scrsz(4)*screensize_factor];
handles.myfig = figure('units','pixels','Position',figsize,...
'menubar','none','name','main_figure',...
'numbertitle','off','resize','on',...
'Visible','off','color',[1,1,1],'Tag','myfig');
handles.mypanel = uipanel(handles.myfig,'BorderType','none','BackgroundColor',clr,'Visible','off','Position',panpos,'Tag','mypanel');
mybg = uibuttongroup(handles.mypanel, 'Title', 'bg', 'position',[0 0.3 .47 0.25]);
mybuttonone = uiradiobutton(mybg,... %<<<<<<<< This is where the code fails to compile and the error appears in the command window <<<<<<<
'Text', 'One',...
'Position', [0.1 0.6 0.4 0.2]);
mybuttontwo = uiradiobutton(mybg,...
'Text', 'Two',...
'Position', [0.1 0.4 0.4 0.2]);
mybuttonthree = uiradiobutton(mybg,...
'Text', 'Three',...
'Position', [0.1 0.2 0.4 0.2]);
Is there just something that I'm missing? I followed the instructions here: https://www.mathworks.com/help/matlab/ref/uibuttongroup.html and I just don't know what to do here.

 Akzeptierte Antwort

Adam
Adam am 27 Jun. 2017
Bearbeitet: Adam am 30 Jun. 2017

2 Stimmen

Unfortunately with both AppDesigner and old style UI components floating around with similar or the same names, but different overloaded syntaxes, you have to be very careful what you mix and match when you write a programmatic GUI.
You have mashed together two different examples by the looks of it, one for AppDesigner uifigure and one for old style figures.
If you look at the top example on the link you posted you will see you need
uicontrol(bg,'Style',...
'radiobutton',...
not
uiradiobutton(bg,...
If you look at the second example that uses uiradiobutton you will see that it begins with a uifigure (AppDesigner figure) as oppose to the old style figure that you use.

4 Kommentare

Mandeguz
Mandeguz am 27 Jun. 2017
Thank you! That was very confusing since I have never used AppDesigner and it looks completely gui-based (like GUIDE if you don't touch the code). Is there a list of AppDesigner codes that may conflict with standard GUI programming?
Adam
Adam am 27 Jun. 2017
Not that I am aware of, but I haven't really used AppDesigner much yet, it is far too limited in what it supports and its editor far too restrictive for what I do.
Mandeguz
Mandeguz am 29 Jun. 2017
I agree. I'm surprised you caught the mistake given that you never use AppDesigner
Adam
Adam am 30 Jun. 2017
Well, I've dabbled with it for one simple UI and I do often create programmatic UI components so have had to make sure I don't use the wrong ones!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Jun. 2017

Bearbeitet:

am 30 Jun. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by