stop bringing GUI to front
Mostra commenti meno recenti
Hi,
I actually have 2 GUIs. One open in the front and another one running in the background. The GUI in the background shows an axes which displays a text that is rebuilt periodically. Every rebuild brings the GUI to front. How can I turn this off?
Risposta accettata
Più risposte (1)
Sean de Wolski
il 20 Set 2013
Modificato: Sean de Wolski
il 20 Set 2013
Hi Adrian,
You have to use low level plotting functionality to set the properties of graphics objects (i.e. the text) that already exist rather than creating new ones.
I did this in an example here for changing the figure settings, you'll need to do the same for text.
If you want a small example, I could create it for you.
More: Example
function changeTextInBackground
%Some strings to cycle through
strings = {'Hello World';...
'Happy Friday';...
'Oktoberfest is nearly here';...
'The Patriots are still 2-0!';...
'And the Ravens aren''t.'};
%Background figure
hFig1 = figure;
set(hFig1,'units','normalized');
plot(1:10);
%We create the text box here, only once
hText = text(5,5,'Initializing...');
%Build the foreground figure
hFig2 = figure;
surf(peaks);
% Timer will change text every second
T = timer('Period',1,... %period
'ExecutionMode','fixedRate',... %{singleShot,fixedRate,fixedSpacing,fixedDelay}
'BusyMode','drop',... %{drop, error, queue}
'TasksToExecute',200,...
'StartDelay',0,...
'TimerFcn',@changeText,...
'StartFcn',[],...
'StopFcn',[],...
'ErrorFcn',[]);
ii = 0; %index for cycling through strings
start(T);
function changeText(~,~)
% increment location
ii = ii+1; %Move the figure
%This is the key line!!! hText already exists, we're just updating
%it
set(hText,'String',strings{ii});
drawnow; %force update
%Reset
if ii == numel(strings)
ii = 0;
end
end
end
4 Commenti
Adrian
il 20 Set 2013
Sean de Wolski
il 20 Set 2013
Well you don't want to set it to invisible! You want to change the property that controls what you're seeing. Let me adapt the last example.
Adrian
il 20 Set 2013
Adrian
il 20 Set 2013
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!