• tablelist itemtodict

    From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Tue Oct 8 18:21:19 2024
    From Newsgroup: comp.lang.tcl

    Hi

    I have a small script.

    ##

    set ::nix {{nix0 5 p-4 o0} {nix11 6 p-3 o2}}

    ::tablelist::tablelist .tbl -listvariable ::nix\
    -columns "0 col1 left 0 col2 right 0 col3 center 0 col4 center"
    .tbl columnconfigure 0 -name col0
    .tbl columnconfigure 1 -name col1
    .tbl columnconfigure 2 -name col2
    .tbl columnconfigure 3 -name col3
    pack .tbl



    puts "itemtodict : [.tbl itemtodict 0]"

    ##

    the puts command show me: % itemtodict : col0 0 col1 {} col2 {} col3 {}

    I expected that I get "col0 nix0 col1 5 col2 p-4 col3 o0".

    I'll get all values from a row with columnname like a dict.

    What do I wrong or I don't understand?



    regards

    Manfred



    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Tue Oct 8 18:50:06 2024
    From Newsgroup: comp.lang.tcl

    * Manfred Stelzhammer <manfred@antispam.at>
    | puts "itemtodict : [.tbl itemtodict 0]"

    | the puts command show me: % itemtodict : col0 0 col1 {} col2 {} col3 {}

    | I expected that I get "col0 nix0 col1 5 col2 p-4 col3 o0".

    | I'll get all values from a row with columnname like a dict.

    | What do I wrong or I don't understand?

    If I understand the 'itemtodict' command correctly, it will not return
    the values of the *table*, but from the *item* you passed to it.

    https://www.nemethi.de/tablelist/tablelistWidget.html#itemtodict
    [...]
    The dictionary's keys will be column numbers or names, and the values
    will be the corresponding elements of the given item.
    [...]

    Since the only value in the item is '0', you get empty strings for the
    rest.

    HTH
    R'
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Tue Oct 8 21:12:52 2024
    From Newsgroup: comp.lang.tcl

    Hi

    Thank's for your answer.

    I know, that I don't get the values from the table,
    but I thought the first row is the first item.
    The first row has the values "nix0 5 p-4 o0".

    I set the variable ::nix with {{nix0 5 p-4 o0} {nix11 6 p-3 o2}}
    which is the listvariable of the table an which is shown in the first
    row in the table.

    I'll ask another question.
    Who can I get all values of a row from the table with the columnnames?

    with: ".tbl rowcget 0 -text" I only get the value, but I'll get the
    columnname and the values like a dict.


    regards

    Manfred


    Am 08.10.24 um 18:50 schrieb Ralf Fassel:
    * Manfred Stelzhammer <manfred@antispam.at>
    | puts "itemtodict : [.tbl itemtodict 0]"

    | the puts command show me: % itemtodict : col0 0 col1 {} col2 {} col3 {}

    | I expected that I get "col0 nix0 col1 5 col2 p-4 col3 o0".

    | I'll get all values from a row with columnname like a dict.

    | What do I wrong or I don't understand?

    If I understand the 'itemtodict' command correctly, it will not return
    the values of the *table*, but from the *item* you passed to it.

    https://www.nemethi.de/tablelist/tablelistWidget.html#itemtodict
    [...]
    The dictionary's keys will be column numbers or names, and the values
    will be the corresponding elements of the given item.
    [...]

    Since the only value in the item is '0', you get empty strings for the
    rest.

    HTH
    R'

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Wed Oct 9 11:08:52 2024
    From Newsgroup: comp.lang.tcl

    * Manfred Stelzhammer <manfred@antispam.at>
    | I know, that I don't get the values from the table,
    | but I thought the first row is the first item.
    | The first row has the values "nix0 5 p-4 o0".

    That's true, but 'item' in this context does not mean "item in the
    tablelist", it literally means the 'item' argument to the 'itemtodict'
    command, which is not some kind of index into the tablelist, but the
    literal values:

    puts "itemtodict : [.tbl itemtodict {nix0 5 p-4 o0}]"
    itemtodict : col0 nix0 col1 5 col2 p-4 col3 o0

    | I'll ask another question.
    | Who can I get all values of a row from the table with the columnnames?

    That would probably be

    .tbl itemtodict [.tbl rowcget 0 -text]

    HTH
    R'
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nemethi@csaba.nemethi@t-online.de to comp.lang.tcl on Wed Oct 9 11:29:24 2024
    From Newsgroup: comp.lang.tcl

    Am 08.10.24 um 21:12 schrieb Manfred Stelzhammer:
    Hi

    Thank's for your answer.

    I know, that I don't get the values from the table,
    but I thought the first row is the first item.
    The first row has the values "nix0 5 p-4 o0".

    I set the variable ::nix with {{nix0 5 p-4 o0} {nix11 6 p-3 o2}}
    which is the listvariable of the table an which is shown in the first
    row in the table.

    I'll ask another question.
    Who can I get all values of a row from the table with the columnnames?

    with: ".tbl rowcget 0 -text" I only get the value, but I'll get the columnname and the values like a dict.


    regards

    Manfred


    Am 08.10.24 um 18:50 schrieb Ralf Fassel:
    * Manfred Stelzhammer <manfred@antispam.at>
    | puts "itemtodict : [.tbl itemtodict 0]"

    | the puts command show me: % itemtodict : col0 0 col1 {} col2 {} col3 {} >>>
    | I expected that I get "col0 nix0 col1 5 col2 p-4 col3 o0".

    | I'll get all values from a row with columnname like a dict.

    | What do I wrong or I don't understand?

    If I understand the 'itemtodict' command correctly, it will not return
    the values of the *table*, but from the *item* you passed to it.

       https://www.nemethi.de/tablelist/tablelistWidget.html#itemtodict
       [...]
       The dictionary's keys will be column numbers or names, and the values >>    will be the corresponding elements of the given item.
       [...]

    Since the only value in the item is '0', you get empty strings for the
    rest.

    HTH
    R'


    The itemtodict subcommand expects as its first argument an item (i.e., a
    list of elements), not an item index. To get and print the desired
    dict, use

    puts "itemtodict : [.tbl itemtodict [.tbl rowcget 0 -text]]"

    or

    puts "itemtodict : [.tbl itemtodict [.tbl get 0]]"
    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From nemethi@csaba.nemethi@t-online.de to comp.lang.tcl on Wed Oct 9 11:38:02 2024
    From Newsgroup: comp.lang.tcl

    Am 09.10.24 um 11:29 schrieb nemethi:
    Am 08.10.24 um 21:12 schrieb Manfred Stelzhammer:
    Hi

    Thank's for your answer.

    I know, that I don't get the values from the table,
    but I thought the first row is the first item.
    The first row has the values "nix0 5 p-4 o0".

    I set the variable ::nix with {{nix0 5 p-4 o0} {nix11 6 p-3 o2}}
    which is the listvariable of the table an which is shown in the first
    row in the table.

    I'll ask another question.
    Who can I get all values of a row from the table with the columnnames?

    with: ".tbl rowcget 0 -text" I only get the value, but I'll get the
    columnname and the values like a dict.


    regards

    Manfred


    Am 08.10.24 um 18:50 schrieb Ralf Fassel:
    * Manfred Stelzhammer <manfred@antispam.at>
    | puts "itemtodict : [.tbl itemtodict 0]"

    | the puts command show me: % itemtodict : col0 0 col1 {} col2 {}
    col3 {}

    | I expected that I get "col0 nix0 col1 5 col2 p-4 col3 o0".

    | I'll get all values from a row with columnname like a dict.

    | What do I wrong or I don't understand?

    If I understand the 'itemtodict' command correctly, it will not return
    the values of the *table*, but from the *item* you passed to it.

       https://www.nemethi.de/tablelist/tablelistWidget.html#itemtodict
       [...]
       The dictionary's keys will be column numbers or names, and the values >>>    will be the corresponding elements of the given item.
       [...]

    Since the only value in the item is '0', you get empty strings for the
    rest.

    HTH
    R'


    The itemtodict subcommand expects as its first argument an item (i.e., a list of elements), not an item index.  To get and print the desired
    dict, use

        puts "itemtodict : [.tbl itemtodict [.tbl rowcget 0 -text]]"

    or

        puts "itemtodict : [.tbl itemtodict [.tbl get 0]]"


    Oops, I have basically written the same as Ralf. It was not before
    posting my answer that I saw Ralf's one.
    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Wed Oct 9 12:57:26 2024
    From Newsgroup: comp.lang.tcl

    * nemethi <csaba.nemethi@t-online.de>
    | > The itemtodict subcommand expects as its first argument an item
    | > (i.e., a
    | > list of elements), not an item index.  To get and print the desired
    | > dict, use
    | >     puts "itemtodict : [.tbl itemtodict [.tbl rowcget 0 -text]]"
    | > or
    | >     puts "itemtodict : [.tbl itemtodict [.tbl get 0]]"
    | >

    | Oops, I have basically written the same as Ralf. It was not before
    | posting my answer that I saw Ralf's one.

    Always good to get confirmation from *the* boss himself ;-)

    R'
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Thu Oct 10 17:32:59 2024
    From Newsgroup: comp.lang.tcl

    Thank's for the answers

    Manfred

    Am 09.10.24 um 12:57 schrieb Ralf Fassel:
    * nemethi <csaba.nemethi@t-online.de>
    | > The itemtodict subcommand expects as its first argument an item
    | > (i.e., a
    | > list of elements), not an item index.  To get and print the desired
    | > dict, use
    | >     puts "itemtodict : [.tbl itemtodict [.tbl rowcget 0 -text]]"
    | > or
    | >     puts "itemtodict : [.tbl itemtodict [.tbl get 0]]"
    | >

    | Oops, I have basically written the same as Ralf. It was not before
    | posting my answer that I saw Ralf's one.

    Always good to get confirmation from *the* boss himself ;-)

    R'

    --- Synchronet 3.20a-Linux NewsLink 1.114