GUIDE GUI Vs Programmatic GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
Is there any advantage of creating a GUI programmatically over using GUIDE?
I have created a GUI using GUIDE and noticed that its objects are displaced when I access it using different machines. Is setting its posotion more robust if programmed rather than creating it though GUIDE?
답변 (2개)
per isakson
2014년 4월 23일
편집: per isakson
2014년 4월 23일
"Is there any advantage of creating a GUI programmatically over using GUIDE?" . Yes, I'm positive there are many. I hardly ever use GUIDE. I'm heavily biased. I did my first Matlab GUIs before GUIDE existed.
The main advantages of "programmatically" are
- the gui-files are not littered with hard coded numbers. An appropriate position of the GUI can be calculated based on the value returned by get(0,'screensize'); to mention one example.
- GUI Layout Toolbox by Ben Tordoff and other Fex-contribuitions
The main disadvantage has to do with the learning curve. There could be many more "design tutorials". The Fex includes a few, e.g. GUI Examples using Nested Functions by Steven Lord.
댓글 수: 0
Sean de Wolski
2014년 4월 23일
Add: http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples to the good programmatic example list.
Here are my thoughts. If I need a quick UI that I'll only use a couple of times or just need as an example, then I'll use GUIDE. This gives quick layout and easy setup to get fast results.
For anything that needs to last for any time at all, I'll skip GUIDE and go directly to programmatic. Programatic UIs afford the flexibility of being able to code however you like, organize however you like, and in general will use more modern syntax that is easier to follow and faster. Whether I make a fully object oriented UI or just use nested functions depends on the complexity.
It will take a little longer to learn how to lay out UIs programmatically but once you get the hang of it, it's fast enough and in some ways actually scales better. How quickly can I add 10 evenly spaced check boxes?
figure
h = gobjects(10,1);
for ii = 1:10
h(ii) = uicontrol('Style','Checkbox','Units','normalized','Position',[0.1 (ii/10-0.1) 0.1 0.1]);
end
Now I want to check the odd ones?
set(h(1:2:end),'Value',true)
This would be way more work in GUIDE.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!