Is there a way to create a GUI which starts as a maximized windows?
I've tried to add set(gcf,'Units','normalized','Position',[0,0,1,1]); at the end of my gui's mygui_OpeningFcn() function but the GUI is not maximized properly (see printscreen).
Setting the GUI properties at GUIDE to Units-'normalized' and Position-[0,0,1,1] didn't help either.
I've also tried to use the Matlab File Exchange maximize function by adding maximize(handle.figure1); at the end of my gui's mygui_OpeningFcn() but it doesn't work either (same visual result - a GUI which is not entirely maximized).
Is there a way to make the Matlab GUI appear as a maximized figure when I launch it?
Why am I getting this strange visual behavior of the GUI?
If you are on a Windows machine, I suggest you use the WindowAPI submission from FEX. It directly calls Windows API functions (using a MEX file), thus allowing far more advanced control of figures than just minimize and maximize:
hFig = figure('Menubar','none');
WindowAPI(hFig,'Maximize')
Related
I'm calling a script from another program (Vicon Nexus 2.3). This other program will launch Matlab, then run the script.
The first thing the script does is it calls uigetfile(). However since the Nexus program has the Windows focus, the uigetfile() window appears behind everything. Is there any way to bring it to the front without using the mouse?
I've tried:
shg
uistack()
But I think the issue here is windows focus, not uistack. Anyone out there know if this is possible?
What you need to do is bring Matlab to front before opening uigetfile dialogue. You can do that e.g. by calling commandwindow:
commandwindow();
uigetfile();
Tested by starting Matlab from command line and overlaying some other windows on top once it is open, but before the code after pause is executed:
matlab -r "pause(3); commandwindow(); uigetfile();"
Is there any way to resize the MATLAB IDE using MATLAB code? I want to be able to maximize the window or have it take up half the screen from a script. This is on a Windows machine.
I can probably call out to an external program like AutoHotkey to do it, but am wondering if there is a native way.
You can do this using a handle to the desktop:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
desktop.getMainFrame.setSize(1200, 1000)
desktop.getMainFrame.setLocation(0, 0)
I am running a GUI in MATLAB. I want whenever my GUI gets opened MATLAB command window should be minimized?
I have tried with WindowAPI but it is not working. Please give some suggestions on how to do this.
You can do this using Matlab's Java support, thereby manipulating the (undocumented) Java objects that make up the Matlab IDE. As far as I know, the Command Window is always embedded in the main Matlab Desktop Window, so here's the code to minimize that.
Get a reference to the Java object that implements the Matlab Desktop:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance();
Get a reference to the window (Java Frame) that contains the Desktop:
mf = desktop.getMainFrame();
Minimize it:
mf.setMinimized(true);
This approach works across platforms.
See http://undocumentedmatlab.com/ for more information on the undocumented internals of Matlab.
For some reason I am unable to resize the workspace size of a GUI figure using MATLAB's built in GUIDE editor. Every time I do so (by dragging the corner of the workspace), I get a warning in MATLAB's console stating:
Warning: Cannot set Position while WindowStyle is 'docked'
> In guidefunc>resizeFigure at 2693
In guidefunc at 116
I have tried setting the default window style to 'normal' (set(0,'DefaultFigureWindowStyle','normal')) to no avail.
I see no reports of this strange behaviour elsewhere online, and wonder if anyone else has experienced this?
Am using MATLAB R2012a. Any thoughts appreciated(!)
Improving upon Lucius' answer, I was able to resize the figure after using the following command on the workspace window.
set(gcf,'WindowStyle','normal')
This command helps sets the window style to normal and hence is resize-able.
I am using Matlab R2020b and the figure under question was selected (highlighted) before I ran this command.
Default-Window-Style and Window-Style are two different things. If you want to change the WindowStyle, you should use that property.
In addition take care for the handle of the figure!
%get handle:
myFigure= findobj('Tag','SomeUniqueTagHere') %make sure to get the right one
set(myFigure,'WindowStyle','normal')
I guess (but I'm not absolutely sure) default-properties will just be used during creation.
You can resize the workspace in GUI and therefore avoid the error message
Warning: Cannot set Position while WindowStyle is 'docked'
by changing the setting WindowStyle in the GUI. To the end you should:
Go to the GUI
Double click on the background, which makes appear the inspector panel.
Go to the property WindowStyle and change it from docked to normal.
After that you can resize your workspace normally.
How can I create tabs in matlab gui?
I did something like this a while ago...
I mean I created some menus at top of my GUI and then pressing each menu will set visible property of some controls on and the others get off
that way is useful for small GUIs but in beag GUIs it encounters problems and editing the GUI gets hard
I need someway to create seperate GUIs acting just like Mozilla tabs
Is there anyway to create that?
Tabs aren't officially supported yet, even though there exists the semi-documented function uitab. Note that in 2012a it warns you that the function will change.
However, there is a very nice submission on the File Exchange, the GUI layout toolbox that comes with tab functionality.
Matlab supports tabs from R2014b
See uitabgroup