Hi every body,
I have coded a moderatly complex gui first within a standard figure and a second version within a uifigure. As usually observed the second version is very very slow compared against the first one. This is not my problem. To obtain a correct gui I must execute ma code in debug mode step by step. Otherwise, the gui is very strange as if each graphic object was not finished before the next one begins to be buit. I have tried to add pause, drawnow, drownow limiterate, uifigure visible off until the last command... Nothing works.
Any idea to find a workaround?
Thank a lot

17 Comments

Hi.
Even if there is a workarround - this is ridiculous!
I myself have very bad feelings about the new features of the new Graphical "upgrade" (especially appdesigner, which is super slow, cumbersome and worst than all: 100% binary file == no way to use any (Git) standard apps/tools for version control)
Please try to elaborate to Mathworks support or even better - send some angry letter.
:-(
dpb
dpb on 17 Jun 2024
Edited: dpb on 18 Jun 2024
Think would have to have a MWE that illustrates the behavior for anybody to be able to comment at all...
I gather the uifigure version was not built with AppDesigner but as standalone code? If so, have you built the same interface (or a subset of it at least) with AppDesigner to see if it also has the same behavior?
While I agree the overhead of the app is huge and painful, not being really a gui coder I've simply put up with the problems when a GUI was mandatory, but I've never seen such a behavior as you describe with the AppDesigner generated code. Then again, I've never built anything that would even approximate a "minimally complex" GUI, what more a "moderately" or "seriously" complex one...A few labels/textboxxes and check boxes to allow user to select input files and some minimal control over what the app does is about it...other than that, I use MATLAB almost exclusively as development/exploratory data analysis tool and interactively because I rarely do the same thing more than once...
Rik
Rik on 18 Jun 2024

I don't recognize the main symptom you are describing, so I agree that reproduction code would be a good idea.

I only write GUIs from code, because I want to support a wide range of releases (back to v6.5, which celebrates its 23rd birthday today). I know that at some point the plan is to transition normal object to the ui type, since that makes them easier to make cross-platform. The community advisory board has stressed to Mathworks that it is important the performance gap is minimized before that happens.

I can send you my code if some body is ready to run it and look at the result. My laptop is a lenovo with an intel xeon processor with oled 4K screen running windows 11 workstation version. In the past i have several times observed problem with high definition screen.
Best regards
Mario Malic
Mario Malic on 19 Jun 2024
Edited: Mario Malic on 19 Jun 2024
Sure, people will take a look at it if you post the code.
It may be a Windows related issue. This is just a wild guess, go to MATLAB.exe, Properties, Compatibility, Change high DPI settings:
I don't have experience with building complex apps only from the code, however, one thing that may be useful is to maybe use gridlayout.
Hi, I have tried all the options available around windows and high dpi problems. No solution.
During the following days I'll re write my gui using the gui layout toolbox and widget toolbox compatible with figure and uifigure. Once finished I send a comment to tell you what hapens.
best regards
alain
Meanwhile, you can also try hiding the visibility of UIFigure, while you create components and see if anything changes.
my uifigure is set visible on at the end of gui construction. No change.
Hi Alain,
I would suggest that you ensure the uifigure is visible at the end of the GUI construction in Matlab, you need to explicitly set the visibility property of the uifigure object. You can do this by using the Visible property and setting it to 'on' at the appropriate stage in your code. By setting the Visible property to 'on' when needed, you can ensure that the uifigure` becomes visible at the end of the GUI construction process.
OK I already do that. Try these first lines extract from my gui
%initalisation of IdMiniTool constants
IdD.nmax=10;ninit=2;sep=4.5e-3;ypos=.925;%htlb=.069;
tabL=[0.04,.48,0.13 0.245];tabx=[0,cumsum(tabL+sep)]+sep;
IdD.BackColor=[0, .75, 1];IdD.SPcolor=[1 .75 0];
%Build IdMiniTool Container
delete(findobj('parent',groot,'tag','IdMiniTool'));
IdD.Container=uifigure('Tag','DataScreen.','color',IdD.BackColor,'Visible','off',...
'WindowState','FullScreen','handlevisibility','on',...
'NumberTitle','off','menubar','none','unit','normal','tag','IdMiniTool');
b = uix.VBox( 'Parent', IdD.Container );
uipanel( 'Parent', b, 'Background', 'r' )
uipanel( 'Parent', b, 'Background', 'b' )
uipanel( 'Parent', b, 'Background', 'g' )
set( b, 'Heights', [-2 -40 -1], 'Spacing', 5 );
IdD.Container.Visible='on';
It is OK with figure. With uifigure it is wrong except if I stop (debug mode) until uifigure construction is finished. I have uses layout toolbox test thinking that will be the solution to run my code both using figure and uifigure!!
Alain
Hello you can look at my problem as follows.At command prompt >>TestUIBug . It will be fine (with gui layout toolbox).
And >>TestUIBug('web') with uifugure. Active or desactive the drawnow line 36. Try to modify the figure size.
Best regards, Alain
function TestUIBug(todo)
if nargin==0
todo='init';
elseif nargin==1&&strcmp(todo,'web')
todo='winit';
else
%retrieve database
IdD=getappdata(findobj('parent',groot,'tag','IdMiniTool'),'IdD');
end
switch todo
case {'init','winit'}
%initalisation of IdMiniTool constants
IdD.BackColor=[0, .75, 1];IdD.SPcolor=[1 .75 0];
%Build IdMiniTool Container
delete(findobj('parent',groot,'tag','IdMiniTool'));
switch todo
case 'init'
IdD.Container=figure('Tag','DataScreen.','color',IdD.BackColor,'Visible','on',...
'WindowState','FullScreen','handlevisibility','on',...
'NumberTitle','off','menubar','none','unit','normal','tag','IdMiniTool');
b = uix.VBox( 'Parent', IdD.Container);
uipanel( 'Parent', b, 'Background', 'r' )
htab=uipanel( 'Parent', b, 'Background', 'b' );
hfp=uipanel( 'Parent', b);
set( b, 'Heights', [-2 -30 -1], 'Spacing', 0 ,'Padding',0);
case 'winit'
IdD.Container=uifigure('Tag','DataScreen.','color',IdD.BackColor,'Visible','on',...
'WindowState','FullScreen','handlevisibility','on',...
'NumberTitle','off','menubar','none','unit','normal','tag','IdMiniTool');
b=uigridlayout('Parent', IdD.Container,'RowHeight',{'2x','30x','1x'},...
'ColumnWidth',{'1x'});
uipanel( 'Parent', b, 'Background', 'r' )
htab=uipanel( 'Parent', b, 'Background', 'b' );
hfp=uipanel( 'Parent', b,'Background', 'k');
set(b,'Padding',1,'RowSpacing',1)
drawnow;
end
%create two tab panels "Data" and "Model"
tabgp = uitabgroup(htab,'units','norma','Position',[0 0 1 1]);
ha = uitab(tabgp,"Title","Data",'background',IdD.SPcolor);
hmtab = uitab(tabgp,"Title","Model",'background',IdD.SPcolor);%#ok
%create plot data handle
hdl.hu=axes(ha,'units','normalized','Position',[0.05,.57,.9,.35]);
hdl.hy=axes(ha,'units','normalized','Position',[0.05,.135,.9,.35]);
set([hdl.hu,hdl.hy],'fontw','bold','fontsize',16,'Color','k');
hdl.ulabel=ylabel(hdl.hu,'','interpreter','none');
hdl.tlabel=xlabel('','interpreter','none');
hdl.ylabel=ylabel('','interpreter','none');
hdl.lgd=gobjects();%#ok
%foot page
hf=axes('parent',hfp,'color','k','unit','normal','position',[0 0 1 1],'visible','on',...
'XTick',[],'YTick',[],'Toolbar',[],'Interactions',[]);
text(.5,.55,['Identification MiniTool \copyright 2000-2024 ABC Software - ' ...
'Contact abc.consultant@wanadoo.fr'],'parent',hf,'background','k',...
'color',IdD.BackColor,'horizon','c','fontw','b','fontsize',16)
IdD.Container.Visible='on';
end
dpb
dpb on 22 Jun 2024
Please format your code...use the funny-looking icon in the CODE section or select the code and CTRL-e
function TestUIBug(todo)
if nargin==0
todo='init';
elseif nargin==1&&strcmp(todo,'web')
todo='winit';
else
%retrieve database
IdD=getappdata(findobj('parent',groot,'tag','IdMiniTool'),'IdD');
end
switch todo
case {'init','winit'}
%initalisation of IdMiniTool constants
IdD.BackColor=[0, .75, 1];IdD.SPcolor=[1 .75 0];
%Build IdMiniTool Container
delete(findobj('parent',groot,'tag','IdMiniTool'));
switch todo
case 'init'
IdD.Container=figure('Tag','DataScreen.','color',IdD.BackColor,'Visible','on',...
'WindowState','FullScreen','handlevisibility','on',...
'NumberTitle','off','menubar','none','unit','normal','tag','IdMiniTool');
b = uix.VBox( 'Parent', IdD.Container);
uipanel( 'Parent', b, 'Background', 'r' )
htab=uipanel( 'Parent', b, 'Background', 'b' );
hfp=uipanel( 'Parent', b);
set( b, 'Heights', [-2 -30 -1], 'Spacing', 0 ,'Padding',0);
case 'winit'
IdD.Container=uifigure('Tag','DataScreen.','color',IdD.BackColor,'Visible','on',...
'WindowState','FullScreen','handlevisibility','on',...
'NumberTitle','off','menubar','none','unit','normal','tag','IdMiniTool');
b=uigridlayout('Parent', IdD.Container,'RowHeight',{'2x','30x','1x'},...
'ColumnWidth',{'1x'});
uipanel( 'Parent', b, 'Background', 'r' )
htab=uipanel( 'Parent', b, 'Background', 'b' );
hfp=uipanel( 'Parent', b,'Background', 'k');
set(b,'Padding',1,'RowSpacing',1)
drawnow;
end
%create two tab panels "Data" and "Model"
tabgp = uitabgroup(htab,'units','norma','Position',[0 0 1 1]);
ha = uitab(tabgp,"Title","Data",'background',IdD.SPcolor);
hmtab = uitab(tabgp,"Title","Model",'background',IdD.SPcolor);%#ok
%create plot data handle
hdl.hu=axes(ha,'units','normalized','Position',[0.05,.57,.9,.35]);
hdl.hy=axes(ha,'units','normalized','Position',[0.05,.135,.9,.35]);
set([hdl.hu,hdl.hy],'fontw','bold','fontsize',16,'Color','k');
hdl.ulabel=ylabel(hdl.hu,'','interpreter','none');
hdl.tlabel=xlabel('','interpreter','none');
hdl.ylabel=ylabel('','interpreter','none');
hdl.lgd=gobjects();%#ok
%foot page
hf=axes('parent',hfp,'color','k','unit','normal','position',[0 0 1 1],'visible','on',...
'XTick',[],'YTick',[],'Toolbar',[],'Interactions',[]);
text(.5,.55,['Identification MiniTool \copyright 2000-2024 ABC Software - ' ...
'Contact abc.consultant@wanadoo.fr'],'parent',hf,'background','k',...
'color',IdD.BackColor,'horizon','c','fontw','b','fontsize',16)
IdD.Container.Visible='on';
end
Apologies for the delay, I would have checked this but we can't reproduce this. I don't really see any issues in this code or something that would take super long.
OK, I run again my code today and it seems to be OK. I don't understand what happens !!??
If I can reproduce the "bug", I send you a screen copy
Thank a lot
Alain
Mario Malic
Mario Malic on 28 Jun 2024
Edited: Mario Malic on 28 Jun 2024
Alright, I have encountered this issue. I think what helps is, if you resize the figure, and it will update the layout.
I don't know the reason why this would happen.

Sign in to comment.

 Accepted Answer

For figures created via the uifigure() function and for containers within a uifigure, the property AutoResizeChildren will be 'on' by default. This means that AutoResizeChildren will try to resize the content when the uifigure is resized, without the need to write a SizeChangedFcn callback or to use uigridlayout.
An important note about AutoResizeChildren: it will resize components even if the components are in normalized units, and treat them as if they were in pixels units.
In this case, AutoResizeChildren on the panel that contains the uitabgroup is not working well because the panel is positioned by a uigridlayout, but the content is absolutely positioned. It is not recommended to mix absolute positioning and use of uigridlayout.
Here is my recommendation:
- If you would like to leverage normalized units, turn off AutoResizeChildren on all containers within the uifigure using the following right after the uifigure call:
set(IdD.Container, 'DefaultUipanelAutoresizechildren', 'off');
set(IdD.Container, 'DefaultUitabAutoresizechildren', 'off');
- Alternatively, use uigridlayout throughout the app. In other words, insert a uigridlayout between containers and their content, e.g. between the uipanel and the uitabgroup, and between the uitab and the axes.

1 Comment

The code I sent works correctly adding this two lines. I think using uifigure and coding manually must be done very rigouresly. My full code using uifigure does not work correctly the GUI remains very strange with superposition or bad sized components. The figure version works nicely without any issues.
Thanks a lot for the time spent around this question
Alain

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Release

R2024a

Community Treasure Hunt

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

Start Hunting!