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

Matlab Pro
Matlab Pro 2024년 6월 17일
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 2024년 6월 17일
편집: dpb 2024년 6월 18일
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 2024년 6월 18일

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.

Alain Barraud
Alain Barraud 2024년 6월 18일
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 2024년 6월 19일
편집: Mario Malic 2024년 6월 19일
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.
Alain Barraud
Alain Barraud 2024년 6월 20일
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
Mario Malic
Mario Malic 2024년 6월 20일
Meanwhile, you can also try hiding the visibility of UIFigure, while you create components and see if anything changes.
Alain Barraud
Alain Barraud 2024년 6월 21일
my uifigure is set visible on at the end of gui construction. No change.
Umar
Umar 2024년 6월 22일
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.
Alain Barraud
Alain Barraud 2024년 6월 22일
편집: Walter Roberson 2024년 8월 10일
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
Alain Barraud
Alain Barraud 2024년 6월 22일
편집: Walter Roberson 2024년 8월 10일
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 2024년 6월 22일
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
Mario Malic
Mario Malic 2024년 6월 26일
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.
Alain Barraud
Alain Barraud 2024년 6월 27일
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
Alain Barraud
Alain Barraud 2024년 6월 27일
yes!! see included file
Mario Malic
Mario Malic 2024년 6월 28일
편집: Mario Malic 2024년 6월 28일
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.

댓글을 달려면 로그인하십시오.

 채택된 답변

Alice
Alice 2024년 8월 10일

2 개 추천

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

Alain Barraud
Alain Barraud 2024년 8월 14일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

릴리스

R2024a

태그

질문:

2024년 6월 17일

댓글:

2024년 8월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by