bugpyFormex - Bugs: bug #36805, Display and edit problems for...

 
 

bug #36805: Display and edit problems for Table widget

Submitter:  Tran Phuong Toan <phuotran>
Submitted:  Sat 07 Jul 2012 01:39:34 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Item Group:  Feature request Status:  Fixed
Privacy:  Public Assigned to:  sdebock
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 19 Jan 2013 06:46:44 PM UTC, comment #7: 

Fixed in commit 877b93c

Tables can now be edited from inside an InputDialog. See the following example

    data = arange(12).reshape(3,4)
    atable = widgets.Table(data)
    btable = widgets.Table(data.tolist(),celltype=int)
    ctable = widgets.Table(data.tolist(),rowtype=[int,str,float])

    input_data = [
        _I('info','Two table types',itemtype='info'),
        _I('array_table',atable,itemtype='widget'),
        _I('list_table',btable,itemtype='widget'),
        ctable
        ]
    dialog = widgets.InputDialog(input_data,autoprefix=True,caption='InputDialog',modal=True)
    print(dialog.getResult())
    print(data)
    print(ctable.value())

giving the following output after changing the entries in the first column to '1'.

[('info', 'Two table types'), ('array_table', array([[ 1,  1,  2,  3],
       [ 1,  5,  6,  7],
       [ 1,  9, 10, 11]])), ('list_table', [[1, 1, 2, 3], [1, 5, 6, 7], [1, 9, 10, 11]])]
[[ 1  1  2  3]
 [ 1  5  6  7]
 [ 1  9 10 11]]
[[1, 1, 2, 3], ['1', '5', '6', '7'], [1.0, 9.0, 10.0, 11.0]]


Note

  • You have to use the itemtype='widget' syntax to get the results of the table back in the dialog results.
  • The result is an array for the ArrayModel, and a list for

the TableModel.

  • TableModel can have per row or per column different type.
  • Default TableModel type is str.
  • The possibility of adding a plain widget to the dialog items

is intended for widgets that just display information or that aid in the working of other input fields. They can not return a value, as they do not even have a key (name).

I leave this bug open for a while, in case some problems arise with the new functionality.

Benedict Verhegghe <bverheg>
Group administrator
Thu 17 Jan 2013 09:18:11 AM UTC, comment #6: 

For the nested results: consider this example:

def run2():
    """Table widget in InputDialog"""
    dataTable = np.arange(40).reshape((-1, 2)).tolist()
#    print(dataTable)
    table = widgets.Table(dataTable,  label='table',chead=[1, 2],  edit=True)
   
    input_data = [
        dict(name='bla',value=None,text="A constant info field",itemtype='info'),
        _I('clist',['First','Third'],text="itemtype 'list' with check=True",itemtype='list',choices=['First','Second','Third','Fourth'],check=True),
        table
        ]   
    dialog = widgets.InputDialog(input_data, autoprefix=True,caption='InputDialog',modal=True)
    print dialog.getResult()
    print table.tm.arraydata


The getResults() will only output [('bla', None), ('clist', ['First', 'Third'])], while we also want the table.tm.arraydata in the results I imagine!

I have not found a way to fix this without breaking something else.

Sander De Bock <sdebock>
Group Member
Wed 16 Jan 2013 10:33:52 PM UTC, comment #5: 

We need to revive this bug, or close it.

I am not sure I understand the problem with the nested results.

As far as Array/Table model is concerned: I suggest Array to be used for float/int tables, while Table holds just strings.
We could add a list of validator and/or convertor functions though, permitting the table to have different type of values in different columns.

Benedict Verhegghe <bverheg>
Group administrator
Fri 24 Aug 2012 10:44:33 AM UTC, comment #4: 

The ArrayModel could rely on the data being a numpy array, and thus could also use numpy methods and access elements as data[row,column].

The TableModel will always us a list of lists and elements are accessed as data[row][column]. This model could allow rows of unequal length.


Benedict Verhegghe <bverheg>
Group administrator
Fri 17 Aug 2012 11:10:30 AM UTC, comment #3: 

Fixed the "array" problem.
It seems two different functions are called depending on the type of list/array:

ArrayModel
and
TableModel

But I don't really see the point of this.

Still to do:
getResults to show nested widget results.

Sander De Bock <sdebock>
Group Member
Fri 10 Aug 2012 09:29:58 AM UTC, comment #2: 

Fixed it so now you can edit tables.
Array->list can be fixed easily by IF statement and tolist, but thinking of other way.

New bug found: InputDialog > getResults will only show the results of the 'items' i.e. the dictionaries added, not the results of the nested Widgets.
Quick fix: ask directly for result of nested Widget, e.g.:
table.tm.arraydata , but thinking of a way to make it general for all widgets.

Sander De Bock <sdebock>
Group Member
Thu 09 Aug 2012 03:07:39 PM UTC, comment #1: 

Editing a Table widget has not been implemented yet. Still I consider it important, so I have added an entry for this in the Tasks list. Now we are just waiting for somebody to pick it up ;)

Benedict Verhegghe <bverheg>
Group administrator
Sat 07 Jul 2012 01:39:34 PM UTC, original submission:  

Table widget can't display numpy arrays. Data have to be converted into List.

Editing the table through the interface (parameter edit=True) doesn't work.

Tran Phuong Toan <phuotran>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #26161:  testTable.py added by phuotran (2KiB - text/x-python)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sdebock (Updated the item)
  • -email is unavailable- added by bverheg (Posted a comment)
  • -email is unavailable- added by phuotran (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-14 bverheg StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-01-19 bverheg Item GroupNone Feature request
        StatusIn Progress Ready For Test
    2012-08-10 sdebock StatusNone In Progress
        Assigned toNone sdebock
    2012-07-07 phuotran Attached File- Added testTable.py, #26161

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code