is there a layout manager for making Matlab GUI's?

3 visualizaciones (últimos 30 días)
Nasser M. Abbasi
Nasser M. Abbasi el 3 de Dic. de 2012
Comentada: Joseph Cheng el 18 de Ag. de 2014
I normally use GUIDE to make matlab GUI.
If I want to make GUI myself without GUIDE, and layout the controls and the axis on the figure area, I really do not want to sit down and count pixels myself to determine where to put each control.
Is there a layoyt manager one can use to help in the layout of the controls, similar to Java's layout manager http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html.
Otherwise, will just continue to use GUIDE.
btw, I know about http://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox I was not sure since it is not part of Matlab itself, if I spend time to learn it and write something using it, my code will not work in the next version of Matlab.
I see that the name Mathworks is on the above toolbox files. Does this mean one can depend on this code being there all the time with some update to it for future versions of Matlab? And why isn't this toolbox part of Matlab itself since it seems to have been written by Mathworks. I'd like to know this before I spend time learning something new.
thanks,
  2 comentarios
per isakson
per isakson el 18 de Ag. de 2014
Why isn't there a good answer to this question?
Iain
Iain el 18 de Ag. de 2014
Sadly, I think the answer is that GUIs just don't get much love from the mathworks.

Iniciar sesión para comentar.

Respuesta aceptada

Joseph Cheng
Joseph Cheng el 18 de Ag. de 2014
Well, it took a while for me to remember how to search my previous answers for this but you can use guide in a semi-automatic fashion.
Layout the GUI as desired and save it somewhere. Then in one of the callbacks (usually in a button) put a breakpoint (i use disp('debug')) and save the handles structure. Then open up the handles structure and you can write a loop to extract the positions or any other param.
  1. save handles using save('handles.mat','-struct','handles')
  2. exit existing gui and clear all variables.
  3. load handles.mat
  4. listofuiobjects = who;
  5. fid = fopen('textfile.txt')
  6. write for loop to get(listofuiobjects(i).Position) and style and other param.
  7. uitext = [''uicontrol('Style',' retreivedStyle ','Units','pixels','Position', ' retreivedPosition ' ,'Enable','off'))'] %this is air coding (saw term in another post here and liked it-similar to air guitar) so don't hold it against me if the string concatenation is wrong.
  8. fprintf uitext within the above forloop.
  1 comentario
Joseph Cheng
Joseph Cheng el 18 de Ag. de 2014
If i have more free time i am considering creating a function that would do this using GUIDE that one would just stick in the GUI startup sequence and generate some output file.

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 3 de Dic. de 2012
Editada: Sean de Wolski el 3 de Dic. de 2012
One thing that I've found useful (and I'd never used this tool until recently) is to use the "Increment Value and Run Section" tool.
Here is an example:
%%Section 1
h = figure;
%%Section 2
pb = uicontrol('Style','Pushbutton','Units','Pixels','Position',[10 10 100 100]);
set(pb,'Position',[80, 110, 210, 30]) %This line!!!
drawnow
Now run the first two sections and put the cursor next to each of the numbers on "This Line", right click and select the first option. This will bring up the little box that allows you to move your various position numbers. So for example set the +/- values to 10, i.e. operate at a resolution of 10px, and then increment/decrement until that part of the position is adjusted to your liking.
Repeat for each number in the position.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by