stop bringing GUI to front
조회 수: 7 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
Jan
2013년 9월 20일
A figure is moved to the front if it is explicitly requested to do so. Perhaps there is a figure(figHandle); axes(axesH) in your code, which move the figure to front and code to activate the wanted axes. Then text() writes to the specified axes, but the lifting of the figure is not useful in your case. A solution would be then:
text(0.5, 0.5, 'Hello', 'Parent', axesH)
Specifying the parent cares for writing to the wanted axes also, but without moving the figure to the front.
So please check your code e.g. by using the debugger until you find the command, which causes the activation of the figure. Then remove this command and replace it accordingly.
댓글 수: 0
추가 답변 (1개)
Sean de Wolski
2013년 9월 20일
편집: Sean de Wolski
2013년 9월 20일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!