Filter löschen
Filter löschen

How to make all the buttons of same size in matlab guide

4 Ansichten (letzte 30 Tage)
Aash
Aash am 10 Mai 2018
Beantwortet: Walter Roberson am 10 Mai 2018
At the end of designing stage of my MATLAB gui, I want to make sure that all the buttons are of same size How
can I set all properties same?

Akzeptierte Antwort

Jim Riggs
Jim Riggs am 10 Mai 2018
Bearbeitet: Jim Riggs am 10 Mai 2018
Right-click on the pushbutton and open the property inspector. There you can set the exact height and width of the button (in the position field)
  1 Kommentar
Aash
Aash am 10 Mai 2018
Oh thanks so much. I have been trying to fix it manually. YOu saved me.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 10 Mai 2018
In your gui OpenFcn callback,
buttons = findobj(hObject, 'type', 'uicontrol', '-or', 'type', 'matlab.ui.control.UIControl' );
set(buttons, 'Units', 'pixels');
for thisbutton = buttons
curpos = get(thisbutton, 'Position');
curpos(3:4) = [new_width, new_height];
set(thisbutton, 'Position', curpos);
end
There are other ways of doing this, some of which are slightly more vectorized.
Note that in each case, the bottom left corner of the button will stay fixed while the buttons get larger or smaller.
The code makes no attempt to position the buttons "nicely" to fit them between objects or aligned with objects. For example if you had
++++ ++++++++++
+Go+ + +
++++ + image +
+ +
++++++++++
and the button was made larger, then you could end up with
++++++
+ +
+ Go +
+ + ++++++++++
+ + + +
++++++ + image +
+ +
++++++++++

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by