Table in a modal window

Is there a way to use a table in a modal window? (quick comment to summarize findings, started from GUIDE play button it does not work as described, started from a command line and then it works)
I have a table in a modal window and it is not displaying the 'Data' from the text cell structure that I am setting into it.
Problem Example
1) Use Matlab Menu -> File -> New -> GUI
2) Select "Modal Question Dialog"
3) In GUIDE, Edit figure, stretch it larger, move a few things around
4) Add button and a table (default 4x2 is fine)
5) Add code to button call back to put data in the table
function pbTest_Callback(hObject, eventdata, handles)
theDdata{1,1} = 'test 11';
theDdata{1,2} = 'test 12';
set(handles.tblTest, 'Data', theDdata);
6) run program
7) click button
Table goes to one row but does not have data. When I checked the get(..'Data') the values were set. So it is simply not displaying the data. If you change this figure to 'normal' then it displays the text.
Changing the figure to normal:
1) In GUIDE, change WindowStyle to normal
2) In code, Comment out 'uiwait' in uiTestModal_OpeningFcn
% uiwait(handles.figure1);
3) comment out 'delete' in uiTestModal_OutputFcn
% delete(handles.figure1);
Now the table shows the data when the button is clicked.
MATLAB Version 7.13.0.564 (R2011b) Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1) Java VM Version: Java 1.6.0_29-b11 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode

 Réponse acceptée

Matt Fig
Matt Fig le 19 Août 2012
Modifié(e) : Matt Fig le 19 Août 2012

0 votes

It works fine here. Same specs as you have. Does this work?
function [] = modal_gui
% Help
S.fh = figure('units','pixels',...
'position',[500 500 200 260],...
'menubar','none',...
'name','modal_gui',...
'numbertitle','off',...
'resize','off',...
'windowstyle','modal');
S.tb = uitable('unit','pix',...
'position',[10 60 180 180],...
'fontsize',12);
S.pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 180 40],...
'fontsize',14,...
'string','Push Me',...
'callback',{@pb_call,S});
% uiwait(S.fh) % Either way, works here.
function [] = pb_call(varargin)
% Callback for pushbutton.
S = varargin{3}; % Get the structure.
TD = {'T11','T12';'T21','T22';'T31','T32';'T41','T42'};
set(S.tb, 'Data', TD);

4 commentaires

Daniel
Daniel le 19 Août 2012
Modifié(e) : Daniel le 19 Août 2012
Yes, your example works. Thank you. I found something strange however. I needed to run your example from a MATLAB command line, so I tried that with mine. When I start my figure from the MATLAB command line it works. If I start it from the GUIDE play button its does not work.
Jan
Jan le 19 Août 2012
@Daniel: "It does not work" sounds, like there is a problem. But as long as you do not explain any details of this problem, it is nearly impossible to answer.
Matt Fig
Matt Fig le 19 Août 2012
I'll second Jan's comment, and add that things like what you are experiencing are the reason I started writing my own GUIs instead of using GUIDE!
I assume you will be using the GUI from the CL anyway, right? You wouldn't start GUIDE every time you wanted to actually use the GUI, but only to edit the GUI I assume.
Daniel
Daniel le 19 Août 2012
Modifié(e) : Daniel le 19 Août 2012
Yes I will be using the GUI from the command line or another figure to start the modal figure in actual usage. So from that aspect I can get the functionality I need. Since I was developing a complex figure I was only using GUIDE to start it. The first comment got me to try the command line and so I found the source of the problem and the work around. So effectively it solved my problem.
As far as 'It does not work': My opening statement describes how to setup and recreate the problem along with the invalid functionality. It is still not working in the same way.
After a little more testing I found: If I start this GUI in GUIDE it does not work as described in the opening. If I start this GUI with another GUI that I started in GUIDE it does not work in the same way.
It does work when I start the GUI from a command line. It does work when I start it from another GUI started by the command line.
I might expect that this is a problem with GUIDE. So perhaps it should be entered as a MATLAB GUIDE BUG. I am not sure how to do that.
Some more tags for GOOGLE: MATLAB, modal Figure, modal GUI, modal Window, "does not show" "does not display", Table Data, when started from GUIDE, does work when started from command line

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by