Home > Archive > Matlab > April 2005 > Data grid in GUI (Linux)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Data grid in GUI (Linux)
|
|
| Tomas Vondra 2005-04-27, 9:01 pm |
| Hello,
I need to display the user data in the GUI, using some kind of table
(data grid). I don't need the editing ability - all I need is to
display them.
As far as I know there's no such UI element in the Matlab itself, and
here I've found only some ActiveX controls, but I'm working on Linux,
so it's useless for me. Is there some way to display a simple table?
Thanks a lot in advance.
Tomas
| |
| Brad Phelan 2005-04-28, 9:00 am |
| Tomas Vondra wrote:
> Hello,
>
> I need to display the user data in the GUI, using some kind of table
> (data grid). I don't need the editing ability - all I need is to
> display them.
>
> As far as I know there's no such UI element in the Matlab itself, and
> here I've found only some ActiveX controls, but I'm working on Linux,
> so it's useless for me. Is there some way to display a simple table?
>
> Thanks a lot in advance.
>
> Tomas
If you have R14 ( sp2 ?? ) there is the command uitable. Do
help uitable
| |
| Brad Phelan 2005-04-28, 9:00 am |
| >>Tomas
>
>
> If you have R14 ( sp2 ?? ) there is the command uitable. Do
>
> help uitable
>
I've had a little play with the object and I'm not too sure how usable
it is. Here is an example of it's use but it's a bit fiddly.
function out = use_table
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
t = uitable(data, colnames,'Position', [20 20 250 100]);
t.DataChangedCallback = @change_fcn;
out = @get_data;
function out = get_data
out = data;
end
function change_fcn(src, ev)
row = ev.getEvent.getFirstRow;
col = ev.getEvent.getColumn;
d = src.TableModel.getValueAt(row,col);
data(row+1,col+1) = str2num(d);
end
end
The trick to make this more usable would be to create some
implementation of javax.swing.TableModel that has a friendly matlab back
end such like so that you can do the following somehow.
function use_table
data = rand(10);
% Create a uitable with a simple matlab data model. Specify
% that the cell class will be all of double.
t = uitable(@getfun, @setfun, 'double');
function val = getfun(t, row, col)
val = data(row,col);
end
function setfun(t, row, col, val)
data(row,col) = val;
end
end
| |
| Brad Phelan 2005-04-28, 9:00 am |
| Wasn't as hard as I thought ....
http://xtargets.com/cms/Tutorials/M...GUI-Tables.html
You use the little tool detailed on the website as below
function use_table
data = rand(4);
% Create a uitable with a simple matlab data model. Specify
% that the conversion class will be %g.
t = xtargets_uitable(4,4, @getfun, @setfun, '%g');
function val = getfun( row, col)
val = data(row,col);
end
function setfun( row, col, val)
data(row,col) = val;
end
end
|
|
|
|
|