creating uicontrol in gui without using guide

조회 수: 11 (최근 30일)
luis fonseca
luis fonseca 2011년 2월 3일
I made a gui using guide. But in my .m gui I need to create a uicontrol but not using guide. The problem I have is that when I create a uicontrol('Style','Edit','Position',[Posx,Posy,w,l]) it plots the uicontrol well, but when I change the position the previous uicontrol is still seen, therefore I have two uicontrols, it seems it does not update the uicontrol and just creates new ones everytime I press a callback button to update the position. If I use the uicontrol in guide it does not show this problem, but I dont want to create it from guide, I will like the user to create a uicontrol if he needs too.
Regards Diego
  댓글 수: 1
Matt Fig
Matt Fig 2011년 2월 3일
Where in your code are you calling UICONTROL to create the editbox?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2011년 2월 4일
You can move the UICONTROL:
Pos = [0.0, 0.0, 0.1, 0.04];
EditH = uicontrol('Style', 'edit', ...
'Units', 'normalized', ...
'Position', Pos);
for i = 1:100
Pos(1:2) = [rand * 0.9, rand * 0.96];
set(EditH, 'Position', Pos);
drawnow;
pause(0.5);
end
If your program creates new UICONTROLs, when a callback runs, it (sorry) creates new UICONTROLs instead of moving the existing one. Please inspect (or post here) the code used for the intentional moving.

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by