gui matlab help
tmh88
Pittsburgh / Athens, OH
Hey, I'm messing around gui for a digital clock that I'm making in matlab and I'm stuck. I have drop down file with 'Exit' in it. I'm obviously trying to make it so when you select exit, the figure closes, but I can't figure it out. Any suggestions to get the exit button working?
heres what I have so far. The first block of code is the working one just so you can see what it looks like. To exit you have to use ctl+C. The second code block is what I think it should be, but doesn't work.
and heres the code for what I think it should be. Doesnt work though
heres what I have so far. The first block of code is the working one just so you can see what it looks like. To exit you have to use ctl+C. The second code block is what I think it should be, but doesn't work.
HFIG = figure('Name', 'Digital Clock', 'Numbertitle', 'off', 'Position', [400 300 350 100], ... 'Menubar', 'none', 'Resize', 'on'); filemenu = uimenu('Label', 'File'); uimenu(filemenu, 'Label', 'Exit', 'Callback', [mfilename, '(''EXIT'')']); th = text(0.5,0.5,'xxx') ; % retrieve handle set(gca,'visible','off') ; set(th,'visible','on','horizontalalignment','center') while(1), c1 = datestr(clock,13) ; set(th,'string',c1);% set the string pause(.1) ; % break with ctrl-C end
and heres the code for what I think it should be. Doesnt work though
if narg < 1 HFIG = figure('Name', 'Digital Clock', 'Numbertitle', 'off', 'Position', [400 300 350 100], ... 'Menubar', 'none', 'Resize', 'on'); filemenu = uimenu('Label', 'File'); uimenu(filemenu, 'Label', 'Exit', 'Callback', [mfilename, '(''EXIT'')']); th = text(0.5,0.5,'xxx') ; % retrieve handle set(gca,'visible','off') ; set(th,'visible','on','horizontalalignment','center') while(1), c1 = datestr(clock,13) ; set(th,'string',c1);% set the string pause(.1) ; % break with ctrl-C else switch cmd case 'EXIT' close(HFIG); end end
0
Comments
heres the updated code that works now. Also made the font larger.