gui coded with uifigure
105 次查看(过去 30 天)
显示 更早的评论
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
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
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
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
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
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1718496/image.png)
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
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
2024-6-20
Meanwhile, you can also try hiding the visibility of UIFigure, while you create components and see if anything changes.
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
2024-6-22
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
2024-6-22
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
2024-6-22
Please format your code...use the funny-looking icon in the CODE section or select the code and CTRL-e
Alain Barraud
2024-6-22
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
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
2024-6-27,9:55
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
2024-6-28,9:52
编辑:Mario Malic
2024-6-28,9:53
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)