Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Everyone's head is a cheap movie show." -- Jeff G. Bone


devel / comp.lang.tcl / TCL Treeview issues

SubjectAuthor
* TCL Treeview issuesGeorgeB
+* Re: TCL Treeview issuesRalf Fassel
|`* Re: TCL Treeview issuesGeorgeB
| `* Re: TCL Treeview issuesRalf Fassel
|  +* Re: TCL Treeview issuesRalf Fassel
|  |`- Re: TCL Treeview issuesGeorgeB
|  `* Re: TCL Treeview issuesGeorgeB
|   +* Re: TCL Treeview issuesRich
|   |`* Re: TCL Treeview issuessaitology9
|   | `* Re: TCL Treeview issuesRalf Fassel
|   |  `- Re: TCL Treeview issuessaitology9
|   `* Re: TCL Treeview issuesRalf Fassel
|    `* Re: TCL Treeview issuesGeorgeB
|     `* Re: TCL Treeview issuesRich
|      `* Re: TCL Treeview issuesGeorgeB
|       +* Re: TCL Treeview issuesRich
|       |`* Re: TCL Treeview issuesGeorgeB
|       | `* Re: TCL Treeview issuessaitology9
|       |  +- Re: TCL Treeview issuesGeorgeB
|       |  `* Re: TCL Treeview issuesGeorgeB
|       |   +- Re: TCL Treeview issuesGeorgeB
|       |   `* Re: TCL Treeview issuessaitology9
|       |    `* Re: TCL Treeview issuesGeorgeB
|       |     `* Re: TCL Treeview issuesGeorgeB
|       |      `* Re: TCL Treeview issuesRich
|       |       `* Re: TCL Treeview issuesGeorgeB
|       |        `* Re: TCL Treeview issuesRich
|       |         `* Re: TCL Treeview issuesGeorgeB
|       |          `* Re: TCL Treeview issuesGeorgeB
|       |           +- Re: TCL Treeview issuesRich
|       |           `* Re: TCL Treeview issuessaitology9
|       |            `* Re: TCL Treeview issuessaitology9
|       |             `* Re: TCL Treeview issuesGeorgeB
|       |              `* Re: TCL Treeview issuessaitology9
|       |               `* Re: TCL Treeview issuesGeorgeB
|       |                `* Re: TCL Treeview issuesGeorgeB
|       |                 `* Re: TCL Treeview issuessaitology9
|       |                  `- Re: TCL Treeview issuesGeorgeB
|       `* Re: TCL Treeview issuessaitology9
|        `- Re: TCL Treeview issuesGeorgeB
`* Re: TCL Treeview issuesAlan Grunwald
 `* Re: TCL Treeview issuesGeorgeB
  +- Re: TCL Treeview issuesRich
  `* Re: TCL Treeview issueset4
   `* Re: TCL Treeview issueset4
    `- Re: TCL Treeview issuesGeorgeB

Pages:12
TCL Treeview issues

<ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20093&group=comp.lang.tcl#20093

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:59cd:0:b0:35c:e1f8:3382 with SMTP id f13-20020ac859cd000000b0035ce1f83382mr4337606qtf.304.1663529288612;
Sun, 18 Sep 2022 12:28:08 -0700 (PDT)
X-Received: by 2002:a4a:e54e:0:b0:44a:fb57:7022 with SMTP id
s14-20020a4ae54e000000b0044afb577022mr5597178oot.91.1663529288378; Sun, 18
Sep 2022 12:28:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sun, 18 Sep 2022 12:28:08 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.125; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.125
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
Subject: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Sun, 18 Sep 2022 19:28:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3866
 by: GeorgeB - Sun, 18 Sep 2022 19:28 UTC

Hello,

Newbie here, and I'm having some difficulties with treeview in TCL.

I'm working off a demo example from Active State TCL.

1) I wondered if someone could help, I get the following error but don't know what to do to fix or how to fix.

Error is invalid command error ERROR: invalid command name "populateTree"

command bound to event: "populateTree .fc.tv.tree [.fc.tv.tree focus]"

Code is below

2) How do I get a selection from multiple items treeview to be saved in a variable.

# temp dir to mimic Network dir
set ::dir "C:/Dev"

proc populateRoots {tree} {
populateTree $tree [$tree insert {} end -text "Network File" \
-values [list $::dir directory]]
}

## Code to populate a node of the tree
proc populateTree {tree node} {
if {[$tree set $node type] ne "directory"} {
return
}
set path [$tree set $node fullpath]
$tree delete [$tree children $node]
foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] {
set type [file type $f]
set id [$tree insert $node end -text [file tail $f] \
-values [list $f $type]]
if {$type eq "directory"} {
## Make it so that this node is openable
$tree insert $id 0 -text dummy ;# a dummy
$tree item $id -text [file tail $f]/
} elseif {$type eq "file"} {
set size [file size $f]
set ttime [file mtime $f]
## Format the file size nicely
if {$size >= 1024*1024*1024} {
set size [format %.1f\ GB [expr {$size/1024/1024/1024.}]]
} elseif {$size >= 1024*1024} {
set size [format %.1f\ MB [expr {$size/1024/1024.}]]
} elseif {$size >= 1024} {
set size [format %.1f\ kB [expr {$size/1024.}]]
} else {
append size " bytes"
}
$tree set $id size $size
}
}

# Stop this code from rerunning on the current node
$tree set $node type processedDirectory
}

# ## Create the tree and set it up


ttk::treeview $tw.tree -columns {fullpath type size date time} -displaycolumns {size date time} \
-yscroll "$tw.vsb set" -xscroll "$tw.hsb set"
ttk::scrollbar $tw.vsb -orient vertical -command "$tw.tree yview"
ttk::scrollbar $tw.hsb -orient horizontal -command "$tw.tree xview"
$tw.tree heading \#0 -text "Directory Structure"
$tw.tree heading size -text "File Size"
$tw.tree column size -stretch 0 -width 70
populateRoots $tw.tree
bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}

# ## Arrange the tree and its scrollbars in the toplevel
lower [ttk::frame $tw.dummy]
pack $tw.dummy -fill both -expand 1
grid $tw.tree $tw.vsb -sticky nsew -in $tw.dummy
grid $tw.hsb -sticky nsew -in $tw.dummy
grid columnconfigure $tw.dummy 0 -weight 1
grid rowconfigure $tw.dummy 0 -weight 1

Thank you in advance

George

Re: TCL Treeview issues

<yga8rmfof7s.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20095&group=comp.lang.tcl#20095

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 12:01:27 +0200
Lines: 40
Message-ID: <yga8rmfof7s.fsf@akutech.de>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net KpCYZLRqdt3IR/L/EOg1OAX28QM+9tW9frVUdoIPVN8C8Q4h0=
Cancel-Lock: sha1:DTE2aV2AyKeKKz6fjcxAdPIvqBY= sha1:40wqMsp5V5bSMqE5kax7zhDBvtU=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Mon, 19 Sep 2022 10:01 UTC

* GeorgeB <george.booth3182@gmail.com>
| Hello,
>
| Newbie here, and I'm having some difficulties with treeview in TCL.
>
| I'm working off a demo example from Active State TCL.
>
| 1) I wondered if someone could help, I get the following error but don't know what to do to fix or how to fix.
>
| Error is invalid command error ERROR: invalid command name "populateTree"
>
| command bound to event: "populateTree .fc.tv.tree [.fc.tv.tree focus]"
>
| Code is below

The code you posted works for me (I don't get that error, and from the
code logic, I could not understand how populateTree could not be
defined), so there probably is something else wrong. Are you using
additional namespace code around that example?

| ttk::treeview $tw.tree -columns {fullpath type size date time} -displaycolumns {size date time} \
| -yscroll "$tw.vsb set" -xscroll "$tw.hsb set"

Note that it is always preferable to use [list] to build up callback
commands:

... -yscroll [list $tw.vsb set] -xscroll [list $tw.hsb set]

In your example it depends on what $tw is set to whether it makes a
difference, but if more complex arguments are passed in the callbacks,
the [list] approach is the better one.

| 2) How do I get a selection from multiple items treeview to be saved in a variable.

It seems that [pathname selection] returns the currently selected items,
so just store that in a variable. But since that seems obvious maybe
that is not your question...

HTH
R'

Re: TCL Treeview issues

<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20096&group=comp.lang.tcl#20096

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a37:3c5:0:b0:6ce:3f31:e019 with SMTP id 188-20020a3703c5000000b006ce3f31e019mr12653757qkd.498.1663585546471;
Mon, 19 Sep 2022 04:05:46 -0700 (PDT)
X-Received: by 2002:a05:6214:627:b0:4ac:adeb:58d9 with SMTP id
a7-20020a056214062700b004acadeb58d9mr13873038qvx.128.1663585546299; Mon, 19
Sep 2022 04:05:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 19 Sep 2022 04:05:45 -0700 (PDT)
In-Reply-To: <yga8rmfof7s.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=31.51.81.76; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 31.51.81.76
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <yga8rmfof7s.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Mon, 19 Sep 2022 11:05:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3443
 by: GeorgeB - Mon, 19 Sep 2022 11:05 UTC

Hi Ralf,

Thank you for you response.

Please pardon as I'm very new to TCL.

Yes there is an additional namespace around this code, and I have tried multiple examples all seem to give me an invalid name error.

Is there a way to define "populateTree" so that the error is not generated? or should the tree have it's own name space?

2) How do I get a selection from multiple items treeview to be saved in a variable.
> It seems that [pathname selection] returns the currently selected items,
> so just store that in a variable. But since that seems obvious maybe
> that is not your question...

I've tried [pathname selection], it doesn't print anything in console

On Monday, September 19, 2022 at 11:01:32 AM UTC+1, Ralf Fassel wrote:
> * GeorgeB <george.b...@gmail.com>
> | Hello,
> >
> | Newbie here, and I'm having some difficulties with treeview in TCL.
> >
> | I'm working off a demo example from Active State TCL.
> >
> | 1) I wondered if someone could help, I get the following error but don't know what to do to fix or how to fix.
> >
> | Error is invalid command error ERROR: invalid command name "populateTree"
> >
> | command bound to event: "populateTree .fc.tv.tree [.fc.tv.tree focus]"
> >
> | Code is below
> The code you posted works for me (I don't get that error, and from the
> code logic, I could not understand how populateTree could not be
> defined), so there probably is something else wrong. Are you using
> additional namespace code around that example?
> | ttk::treeview $tw.tree -columns {fullpath type size date time} -displaycolumns {size date time} \
> | -yscroll "$tw.vsb set" -xscroll "$tw.hsb set"
> Note that it is always preferable to use [list] to build up callback
> commands:
>
> ... -yscroll [list $tw.vsb set] -xscroll [list $tw.hsb set]
>
> In your example it depends on what $tw is set to whether it makes a
> difference, but if more complex arguments are passed in the callbacks,
> the [list] approach is the better one.
> | 2) How do I get a selection from multiple items treeview to be saved in a variable.
> It seems that [pathname selection] returns the currently selected items,
> so just store that in a variable. But since that seems obvious maybe
> that is not your question...
>
> HTH
> R'

Re: TCL Treeview issues

<tg9kol$12gei$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20097&group=comp.lang.tcl#20097

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nospam.nurdglaw@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 12:45:09 +0100
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <tg9kol$12gei$1@dont-email.me>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Sep 2022 11:45:25 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="56819759dd6d76a5c8f74a8ea25fa894";
logging-data="1130962"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+egErMLI6tPGdAJ/NE4Nuw6aa9GTB75lI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Cancel-Lock: sha1:lVG2QyWSjcT9wY5i/yB3st4tS/Y=
Content-Language: en-US
In-Reply-To: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
 by: Alan Grunwald - Mon, 19 Sep 2022 11:45 UTC

On 18/09/2022 20:28, GeorgeB wrote:
> Hello,
>
> Newbie here, and I'm having some difficulties with treeview in TCL.
>
> I'm working off a demo example from Active State TCL.
>
> 1) I wondered if someone could help, I get the following error but don't know what to do to fix or how to fix.
>
> Error is invalid command error ERROR: invalid command name "populateTree"
>
> command bound to event: "populateTree .fc.tv.tree [.fc.tv.tree focus]"
>
> Code is below
>
> 2) How do I get a selection from multiple items treeview to be saved in a variable.
>
>
> # temp dir to mimic Network dir
> set ::dir "C:/Dev"
>
> proc populateRoots {tree} {
> populateTree $tree [$tree insert {} end -text "Network File" \
> -values [list $::dir directory]]
> }
>
> ## Code to populate a node of the tree
> proc populateTree {tree node} {
> if {[$tree set $node type] ne "directory"} {
> return
> }
> set path [$tree set $node fullpath]
> $tree delete [$tree children $node]
> foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] {
> set type [file type $f]
> set id [$tree insert $node end -text [file tail $f] \
> -values [list $f $type]]
> if {$type eq "directory"} {
> ## Make it so that this node is openable
> $tree insert $id 0 -text dummy ;# a dummy
> $tree item $id -text [file tail $f]/
> } elseif {$type eq "file"} {
> set size [file size $f]
> set ttime [file mtime $f]
> ## Format the file size nicely
> if {$size >= 1024*1024*1024} {
> set size [format %.1f\ GB [expr {$size/1024/1024/1024.}]]
> } elseif {$size >= 1024*1024} {
> set size [format %.1f\ MB [expr {$size/1024/1024.}]]
> } elseif {$size >= 1024} {
> set size [format %.1f\ kB [expr {$size/1024.}]]
> } else {
> append size " bytes"
> }
> $tree set $id size $size
> }
> }
>
> # Stop this code from rerunning on the current node
> $tree set $node type processedDirectory
> }
>
> # ## Create the tree and set it up
>
>
> ttk::treeview $tw.tree -columns {fullpath type size date time} -displaycolumns {size date time} \
> -yscroll "$tw.vsb set" -xscroll "$tw.hsb set"
> ttk::scrollbar $tw.vsb -orient vertical -command "$tw.tree yview"
> ttk::scrollbar $tw.hsb -orient horizontal -command "$tw.tree xview"
> $tw.tree heading \#0 -text "Directory Structure"
> $tw.tree heading size -text "File Size"
> $tw.tree column size -stretch 0 -width 70
> populateRoots $tw.tree
> bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
>
> # ## Arrange the tree and its scrollbars in the toplevel
> lower [ttk::frame $tw.dummy]
> pack $tw.dummy -fill both -expand 1
> grid $tw.tree $tw.vsb -sticky nsew -in $tw.dummy
> grid $tw.hsb -sticky nsew -in $tw.dummy
> grid columnconfigure $tw.dummy 0 -weight 1
> grid rowconfigure $tw.dummy 0 -weight 1
>
>
> Thank you in advance
>
> George

The error message says that the system doesn't know anything about the
command populateTree. This is a little surprising since you have defined
it in the code you have posted.

Probably what has happened is that when you executed "proc populateTree
{tree node} {...}" you were inside a namespace, so you ended up defining
<someNamespace>::populateTree; since the code associated with the event
operates in the global namespace, it is looking for ::populateTree and
can't find it.

You can ensure that you define populateTree in the global namespace by
changing your [proc] statment to "proc ::populateTree {tree node}...".
If you are interested to know where your current populateTree command is
ending up, you could add "puts stdout [namespace current]" immediately
before the [proc] statement, which willwrite the current namespace to
standard output when the script is first sourced.

Good luck sorting out your script, I hope this proves helpful,

Alan

Re: TCL Treeview issues

<4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20098&group=comp.lang.tcl#20098

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:23c6:b0:491:99e3:80ce with SMTP id hr6-20020a05621423c600b0049199e380cemr14300095qvb.111.1663590513394;
Mon, 19 Sep 2022 05:28:33 -0700 (PDT)
X-Received: by 2002:ac8:5f91:0:b0:35c:bfaa:5156 with SMTP id
j17-20020ac85f91000000b0035cbfaa5156mr14539626qta.40.1663590513207; Mon, 19
Sep 2022 05:28:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 19 Sep 2022 05:28:32 -0700 (PDT)
In-Reply-To: <tg9kol$12gei$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=31.51.81.76; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 31.51.81.76
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <tg9kol$12gei$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Mon, 19 Sep 2022 12:28:33 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 116
 by: GeorgeB - Mon, 19 Sep 2022 12:28 UTC

On Monday, September 19, 2022 at 12:45:29 PM UTC+1, Alan Grunwald wrote:
> On 18/09/2022 20:28, GeorgeB wrote:
> > Hello,
> >
> > Newbie here, and I'm having some difficulties with treeview in TCL.
> >
> > I'm working off a demo example from Active State TCL.
> >
> > 1) I wondered if someone could help, I get the following error but don't know what to do to fix or how to fix.
> >
> > Error is invalid command error ERROR: invalid command name "populateTree"
> >
> > command bound to event: "populateTree .fc.tv.tree [.fc.tv.tree focus]"
> >
> > Code is below
> >
> > 2) How do I get a selection from multiple items treeview to be saved in a variable.
> >
> >
> > # temp dir to mimic Network dir
> > set ::dir "C:/Dev"
> >
> > proc populateRoots {tree} {
> > populateTree $tree [$tree insert {} end -text "Network File" \
> > -values [list $::dir directory]]
> > }
> >
> > ## Code to populate a node of the tree
> > proc populateTree {tree node} {
> > if {[$tree set $node type] ne "directory"} {
> > return
> > }
> > set path [$tree set $node fullpath]
> > $tree delete [$tree children $node]
> > foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] {
> > set type [file type $f]
> > set id [$tree insert $node end -text [file tail $f] \
> > -values [list $f $type]]
> > if {$type eq "directory"} {
> > ## Make it so that this node is openable
> > $tree insert $id 0 -text dummy ;# a dummy
> > $tree item $id -text [file tail $f]/
> > } elseif {$type eq "file"} {
> > set size [file size $f]
> > set ttime [file mtime $f]
> > ## Format the file size nicely
> > if {$size >= 1024*1024*1024} {
> > set size [format %.1f\ GB [expr {$size/1024/1024/1024.}]]
> > } elseif {$size >= 1024*1024} {
> > set size [format %.1f\ MB [expr {$size/1024/1024.}]]
> > } elseif {$size >= 1024} {
> > set size [format %.1f\ kB [expr {$size/1024.}]]
> > } else {
> > append size " bytes"
> > }
> > $tree set $id size $size
> > }
> > }
> >
> > # Stop this code from rerunning on the current node
> > $tree set $node type processedDirectory
> > }
> >
> > # ## Create the tree and set it up
> >
> >
> > ttk::treeview $tw.tree -columns {fullpath type size date time} -displaycolumns {size date time} \
> > -yscroll "$tw.vsb set" -xscroll "$tw.hsb set"
> > ttk::scrollbar $tw.vsb -orient vertical -command "$tw.tree yview"
> > ttk::scrollbar $tw.hsb -orient horizontal -command "$tw.tree xview"
> > $tw.tree heading \#0 -text "Directory Structure"
> > $tw.tree heading size -text "File Size"
> > $tw.tree column size -stretch 0 -width 70
> > populateRoots $tw.tree
> > bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
> >
> > # ## Arrange the tree and its scrollbars in the toplevel
> > lower [ttk::frame $tw.dummy]
> > pack $tw.dummy -fill both -expand 1
> > grid $tw.tree $tw.vsb -sticky nsew -in $tw.dummy
> > grid $tw.hsb -sticky nsew -in $tw.dummy
> > grid columnconfigure $tw.dummy 0 -weight 1
> > grid rowconfigure $tw.dummy 0 -weight 1
> >
> >
> > Thank you in advance
> >
> > George
> The error message says that the system doesn't know anything about the
> command populateTree. This is a little surprising since you have defined
> it in the code you have posted.
>
> Probably what has happened is that when you executed "proc populateTree
> {tree node} {...}" you were inside a namespace, so you ended up defining
> <someNamespace>::populateTree; since the code associated with the event
> operates in the global namespace, it is looking for ::populateTree and
> can't find it.
>
> You can ensure that you define populateTree in the global namespace by
> changing your [proc] statment to "proc ::populateTree {tree node}...".
> If you are interested to know where your current populateTree command is
> ending up, you could add "puts stdout [namespace current]" immediately
> before the [proc] statement, which willwrite the current namespace to
> standard output when the script is first sourced.
>
> Good luck sorting out your script, I hope this proves helpful,
>
> Alan

Alan, you genius....you have sorted the problem, thank you so much.
It also sorted one other issue I was having populating the nodes from a folder in network location...Thank you, I was going round in circles!.

Now I just need to figure out how to print selection (single or multiple) into console. It always comes up blank...

If you any tips or suggestion I'd greatly appreciate.

Re: TCL Treeview issues

<ygav8pjfsfo.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20099&group=comp.lang.tcl#20099

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 14:40:43 +0200
Lines: 54
Message-ID: <ygav8pjfsfo.fsf@akutech.de>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net RTVHJs5/LOD2XBpeqNjLsgLfokLHyUMtB1UR4W4ErFdWWdwI0=
Cancel-Lock: sha1:72xDbsU3P3VLe3leEOj3YXhbcmc= sha1:TU+2ZH3Xw5tyh0y0O3H9gDdbSEs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Mon, 19 Sep 2022 12:40 UTC

* GeorgeB <george.booth3182@gmail.com>
| Hi Ralf,
>
| Thank you for you response.
>
| Please pardon as I'm very new to TCL.
>
| Yes there is an additional namespace around this code, and I have
| tried multiple examples all seem to give me an invalid name error.

Usually it is best to post a _complete_ example which actually shows the
error. The code you posted did not use an additional namespace, so it
does not show the error.

If you define a proc inside a namespace, you need to specify that
namespace in callbacks, since those callbacks usually are invoked
outside of that namespace when they run later.

Instead of
bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
try
bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]

The [namespace code ...] captures the current namespace for the
asynchronous invocation of the command later.

| Is there a way to define "populateTree" so that the error is not
| generated? or should the tree have it's own name space?

It's not how "populateTree" is defined, but how it is to be called.
If you define it inside a namespace, you need to specify that namespace
when calling it.

Note that procs which are defined in the same namespace can call other
procs in that namespace without specifying that namespace explicitly,
but for callbacks like [bind] you need to specfiy the namespace via
[namespace code ...].

| 2) How do I get a selection from multiple items treeview to be saved in a variable.
| > It seems that [pathname selection] returns the currently selected items,
| > so just store that in a variable. But since that seems obvious maybe
| > that is not your question...
>
| I've tried [pathname selection], it doesn't print anything in console

You need to replace 'pathname' by $tw.tree, then select something in the
treeview, then issue that command:

set selected [$tw.tree selection]
puts $selected
=> I004 I005 I006

HTH
R'

Re: TCL Treeview issues

<tg9s1e$13m5t$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20100&group=comp.lang.tcl#20100

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 13:49:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <tg9s1e$13m5t$1@dont-email.me>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <tg9kol$12gei$1@dont-email.me> <4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>
Injection-Date: Mon, 19 Sep 2022 13:49:34 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="64efa1bda0834ec6a2be384c158402e9";
logging-data="1169597"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VDumoK5nRE8cHOR4J1Hyo"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:IeiGUElUmoskUD3kX2EXfFoR3Ug=
 by: Rich - Mon, 19 Sep 2022 13:49 UTC

GeorgeB <george.booth3182@gmail.com> wrote:
> On Monday, September 19, 2022 at 12:45:29 PM UTC+1, Alan Grunwald wrote:
>> On 18/09/2022 20:28, GeorgeB wrote:
>> > Error is invalid command error ERROR: invalid command name "populateTree"
>> >
>>
>> Probably what has happened is that when you executed "proc populateTree
>> {tree node} {...}" you were inside a namespace, so you ended up defining
>> <someNamespace>::populateTree; since the code associated with the event
>> operates in the global namespace, it is looking for ::populateTree and
>> can't find it.
>>
>> You can ensure that you define populateTree in the global namespace by
>> changing your [proc] statment to "proc ::populateTree {tree node}...".
>> If you are interested to know where your current populateTree command is
>> ending up, you could add "puts stdout [namespace current]" immediately
>> before the [proc] statement, which willwrite the current namespace to
>> standard output when the script is first sourced.
>
> Alan, you genius....you have sorted the problem, thank you so much.

> If you any tips or suggestion I'd greatly appreciate.

If you do wish to use namespaces to structure your code, and if you do
not wish to pollute the global namespace (implied yes given you appear
to be using namespaces), then you should use Ralf's suggestion of
utilizing 'namespace code' to generate the callback script bound to the
binding event.

That will do the work of setting up the binding to call the proc inside
the namespace where it is defined, without you having to add lots of
global procs or having to manually handle the insertion of the
namespace pathname for each binding.

Re: TCL Treeview issues

<ygaleqf75ae.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20102&group=comp.lang.tcl#20102

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 17:27:53 +0200
Lines: 26
Message-ID: <ygaleqf75ae.fsf@akutech.de>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net H6vU+Q19P+wVxVgrZZI5CwkDSZLaOk+222xz1M9/WMcc/AhDM=
Cancel-Lock: sha1:sCBKm3iZogSST0SwjOM9A3TolGc= sha1:c0UY9Fw8N4yTMm7aRbsff6Xjqgo=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Mon, 19 Sep 2022 15:27 UTC

* Ralf Fassel <ralfixx@gmx.de>
| Instead of
| bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
| try
| bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]

Nah, that's nonsense, since the [%W focus] needs to run later when the
binding is triggered, not when it is defined.

Easiest solution seems to move the "%W focus" into populateTree:

proc populateTree {tree node} {
...
=>
proc populateTree {tree {node ""}} {
if {$node eq ""} {
set node [$tree focus]
}
...

and then just do

bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W]]

HTH
R'

Re: TCL Treeview issues

<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20104&group=comp.lang.tcl#20104

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:13d3:b0:35a:6c40:da6d with SMTP id p19-20020a05622a13d300b0035a6c40da6dmr15102645qtk.253.1663601563861;
Mon, 19 Sep 2022 08:32:43 -0700 (PDT)
X-Received: by 2002:ae9:f810:0:b0:6ce:3cf5:42cc with SMTP id
x16-20020ae9f810000000b006ce3cf542ccmr12763145qkh.216.1663601563687; Mon, 19
Sep 2022 08:32:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 19 Sep 2022 08:32:43 -0700 (PDT)
In-Reply-To: <ygav8pjfsfo.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=31.51.81.76; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 31.51.81.76
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Mon, 19 Sep 2022 15:32:43 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4622
 by: GeorgeB - Mon, 19 Sep 2022 15:32 UTC

On Monday, September 19, 2022 at 1:40:47 PM UTC+1, Ralf Fassel wrote:
> * GeorgeB <george.b...@gmail.com>
> | Hi Ralf,
> >
> | Thank you for you response.
> >
> | Please pardon as I'm very new to TCL.
> >
> | Yes there is an additional namespace around this code, and I have
> | tried multiple examples all seem to give me an invalid name error.
> Usually it is best to post a _complete_ example which actually shows the
> error. The code you posted did not use an additional namespace, so it
> does not show the error.
>
> If you define a proc inside a namespace, you need to specify that
> namespace in callbacks, since those callbacks usually are invoked
> outside of that namespace when they run later.
>
> Instead of
> bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
> try
> bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]
>
> The [namespace code ...] captures the current namespace for the
> asynchronous invocation of the command later.
> | Is there a way to define "populateTree" so that the error is not
> | generated? or should the tree have it's own name space?
> It's not how "populateTree" is defined, but how it is to be called.
> If you define it inside a namespace, you need to specify that namespace
> when calling it.
>
> Note that procs which are defined in the same namespace can call other
> procs in that namespace without specifying that namespace explicitly,
> but for callbacks like [bind] you need to specfiy the namespace via
> [namespace code ...].
> | 2) How do I get a selection from multiple items treeview to be saved in a variable.
> | > It seems that [pathname selection] returns the currently selected items,
> | > so just store that in a variable. But since that seems obvious maybe
> | > that is not your question...
> >
> | I've tried [pathname selection], it doesn't print anything in console
> You need to replace 'pathname' by $tw.tree, then select something in the
> treeview, then issue that command:
>
> set selected [$tw.tree selection]
> puts $selected
> => I004 I005 I006
>
> HTH
> R'

Hi Rich and Ralf,

Thank you for the suggestion,

I've replaced the binding with
bind $tw.tv.tree <<TreeviewOpen>> {::FG::populateTree %W [%W focus]}

However if I use bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]], where code = container name I get error
ERROR: invalid command name "%W"
in "%W focus"

> | I've tried [pathname selection], it doesn't print anything in console
> You need to replace 'pathname' by $tw.tree, then select something in the
> treeview, then issue that command:
>
> set selected [$tw.tree selection]
> puts $selected
> => I004 I005 I006

I'd done exactly as you had suggested...but realised I forgot to select items in the tree....doh!!!

I'm assuming I will have to map the id e.g. I004 etc to actual value in the tree?
i.e. if id = I004 and I004 relates to file config.txt in tree then I'll have to map it somehow to each other .

Is it possible to selected a node and get all values underneath it? On selection of the node is just gives me one single ID?
e.g.
Network file
|- Folder 1
|- file0.txt
|- file1.txt
|- file2.txt
|- file3.txt

I would like to get all items underneath Folder 1 by selecting Folder 1

Re: TCL Treeview issues

<a8546747-fecf-46ef-940f-ab3b99ee8179n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20105&group=comp.lang.tcl#20105

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:daf:b0:49f:5ce8:e628 with SMTP id h15-20020a0562140daf00b0049f5ce8e628mr15031932qvh.115.1663601986303;
Mon, 19 Sep 2022 08:39:46 -0700 (PDT)
X-Received: by 2002:a05:6214:501e:b0:4ac:9afa:80a3 with SMTP id
jo30-20020a056214501e00b004ac9afa80a3mr15473833qvb.79.1663601986171; Mon, 19
Sep 2022 08:39:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 19 Sep 2022 08:39:45 -0700 (PDT)
In-Reply-To: <ygaleqf75ae.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=31.51.81.76; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 31.51.81.76
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de> <ygaleqf75ae.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a8546747-fecf-46ef-940f-ab3b99ee8179n@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Mon, 19 Sep 2022 15:39:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2083
 by: GeorgeB - Mon, 19 Sep 2022 15:39 UTC

On Monday, September 19, 2022 at 4:27:58 PM UTC+1, Ralf Fassel wrote:
> * Ralf Fassel <ral...@gmx.de>
> | Instead of
> | bind $tw.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
> | try
> | bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]
> Nah, that's nonsense, since the [%W focus] needs to run later when the
> binding is triggered, not when it is defined.
>
> Easiest solution seems to move the "%W focus" into populateTree:
> proc populateTree {tree node} {
> ...
> =>
> proc populateTree {tree {node ""}} {
> if {$node eq ""} {
> set node [$tree focus]
> }
> ...
>
> and then just do
>
> bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W]]
>
> HTH
> R'

Ralf
I just saw this as I posted my last reply 5mins ago...this seems to work better.

Re: TCL Treeview issues

<tgales$184jh$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20106&group=comp.lang.tcl#20106

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 21:03:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <tgales$184jh$1@dont-email.me>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com> <ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
Injection-Date: Mon, 19 Sep 2022 21:03:24 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="64efa1bda0834ec6a2be384c158402e9";
logging-data="1315441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+S4PJ1QAOagb4JpAINqLI"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:a+Z5mguNUHWzIT/fAK7UlDfwZMA=
 by: Rich - Mon, 19 Sep 2022 21:03 UTC

GeorgeB <george.booth3182@gmail.com> wrote:
> However if I use bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]]
> , where code = container name I get error
> ERROR: invalid command name "%W"
> in "%W focus"

That is because if you look at the above, you are asking tcl to execute
a command named %W (note the []') at the time you define the binding.

There is no command named %W defined (unless you defined a proc by that
name), so you get "invalid command name "%W".

You would be best to follow Ralf's suggestion and perform the 'focus'
inside the proc, and just pass the window name that Tk inserts for %W
when the binding fires into the proc, then use that window name to
perform the focus. Note, are you sure you want to do a focus here?

>> | I've tried [pathname selection], it doesn't print anything in
>> console You need to replace 'pathname' by $tw.tree, then select
>> something in the treeview, then issue that command:
>>
>> set selected [$tw.tree selection]
>> puts $selected
>> => I004 I005 I006
>
> I'd done exactly as you had suggested...but realised I forgot to
> select items in the tree....doh!!!
>
> I'm assuming I will have to map the id e.g. I004 etc to actual value
> in the tree? i.e. if id = I004 and I004 relates to file config.txt
> in tree then I'll have to map it somehow to each other .

You get the internal ID's of the selected items. That is all Tk knows.
If you need to relate those ID's to something else then you have to
build that relationship map yourself.

> Is it possible to selected a node and get all values underneath it?
> On selection of the node is just gives me one single ID?

You can get a list of the children of a given node with the 'children'
subcommand (see the treeview man page).

If you wish to recurse down the tree, then you have to write your own
proc to walk down the tree and get all the grand/greatgrand/etc.
children.

Re: TCL Treeview issues

<tgar2s$1fm5$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20107&group=comp.lang.tcl#20107

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 18:39:24 -0400
Organization: Aioe.org NNTP Server
Message-ID: <tgar2s$1fm5$1@gioia.aioe.org>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<tgales$184jh$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="48837"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: saitology9 - Mon, 19 Sep 2022 22:39 UTC

On 9/19/22 5:03 PM, Rich wrote:
> GeorgeB <george.booth3182@gmail.com> wrote:
>> However if I use bind $tw.tree <<TreeviewOpen>> [namespace code [list populateTree %W [%W focus]]]
>> , where code = container name I get error
>> ERROR: invalid command name "%W"
>> in "%W focus"
>
> That is because if you look at the above, you are asking tcl to execute
> a command named %W (note the []') at the time you define the binding.
>
> There is no command named %W defined (unless you defined a proc by that
> name), so you get "invalid command name "%W".
>
> You would be best to follow Ralf's suggestion and perform the 'focus'

I agree Ralf's suggestion is the best approach here. Nevertheless, it
might be useful to OP to know that they could fix the error above by
properly constructing the callback like so:

bind $tw.tree <<TreeviewOpen>> \
[namespace code [list populateTree %W [list %W focus]]]

Re: TCL Treeview issues

<tgba47$1sln$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20108&group=comp.lang.tcl#20108

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!YN2ulY6LKp1eoOUw2OJ8ig.user.46.165.242.91.POSTED!not-for-mail
From: tclnews@rocketship1.me (et4)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 19:56:07 -0700
Organization: Aioe.org NNTP Server
Message-ID: <tgba47$1sln$1@gioia.aioe.org>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<tg9kol$12gei$1@dont-email.me>
<4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62135"; posting-host="YN2ulY6LKp1eoOUw2OJ8ig.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: et4 - Tue, 20 Sep 2022 02:56 UTC

On 9/19/2022 5:28 AM, GeorgeB wrote:

>

> Now I just need to figure out how to print selection (single or multiple) into console. It always comes up blank...
>
> If you any tips or suggestion I'd greatly appreciate.
>

Welcome new tcl programmer.

Might I suggest "The Tcl Programming Language" book, both paper and pdf.

https://www.magicsplat.com/ttpl/index.html

I recommend both. They are an exact match; searching in the pdf can take you to the exact same page in the book.

The index and TOC in the pdf are hyperlinked. You can download the TOC for free on the above page and you can get a zip from there with all the utility functions used in the book as well.

You mentioned you print to the console, so probably on windows. Snippets of code from the book can be copied/pasted from the pdf right into a console window where you can interactively try things out.

Your issue with callbacks vs. scripts is discussed in section 10.7.1. and 12.2.1 when combined with namespaces.

I also recommend the free and portable PDF Xchange Viewer program on windows.

Re: TCL Treeview issues

<tgbb3t$43p$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20109&group=comp.lang.tcl#20109

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!YN2ulY6LKp1eoOUw2OJ8ig.user.46.165.242.91.POSTED!not-for-mail
From: tclnews@rocketship1.me (et4)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Mon, 19 Sep 2022 20:13:01 -0700
Organization: Aioe.org NNTP Server
Message-ID: <tgbb3t$43p$1@gioia.aioe.org>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<tg9kol$12gei$1@dont-email.me>
<4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>
<tgba47$1sln$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4217"; posting-host="YN2ulY6LKp1eoOUw2OJ8ig.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: et4 - Tue, 20 Sep 2022 03:13 UTC

Almost forgot, a great on-line manual too:

https://www.magicsplat.com/tcl-docs/docindex.html

Re: TCL Treeview issues

<440abb65-ffbb-4cfd-b5a0-fd96e34bfe46n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20110&group=comp.lang.tcl#20110

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ae9:ef4f:0:b0:6cb:d294:3333 with SMTP id d76-20020ae9ef4f000000b006cbd2943333mr15643859qkg.511.1663658735272;
Tue, 20 Sep 2022 00:25:35 -0700 (PDT)
X-Received: by 2002:ac8:584a:0:b0:35c:bf11:9e42 with SMTP id
h10-20020ac8584a000000b0035cbf119e42mr17689089qth.425.1663658734984; Tue, 20
Sep 2022 00:25:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 20 Sep 2022 00:25:34 -0700 (PDT)
In-Reply-To: <tgbb3t$43p$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.85; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.85
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<tg9kol$12gei$1@dont-email.me> <4b41c6df-79e6-411b-ac51-4211c777f4e4n@googlegroups.com>
<tgba47$1sln$1@gioia.aioe.org> <tgbb3t$43p$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <440abb65-ffbb-4cfd-b5a0-fd96e34bfe46n@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Tue, 20 Sep 2022 07:25:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2121
 by: GeorgeB - Tue, 20 Sep 2022 07:25 UTC

On Tuesday, September 20, 2022 at 4:13:05 AM UTC+1, et4 wrote:
> Almost forgot, a great on-line manual too:
>
> https://www.magicsplat.com/tcl-docs/docindex.html

Morning Rich, saitology9 & et4,

I've got most of the errors sorted (Ralf/Rich, thank you for the help, most appreciated).

I think as I get use to TCL I'll have a better understanding, right now I've been thrown in the deep end and hence steep learning curve.

@Rich thank you for the clarification on the mapping, I suspected as such but thought I'd double check.

@et4, thank you for the resource, anything on tree view (for immediate help), plus I need to add more widgets to treeview once I've figured out mapping.

Lastly, if I have more questions relating to the code shown in my first thread (as I build on it), should I create a new thread or continue with current thread for continuity?

Re: TCL Treeview issues

<ygaczbq78ku.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20111&group=comp.lang.tcl#20111

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 10:29:05 +0200
Lines: 19
Message-ID: <ygaczbq78ku.fsf@akutech.de>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<tgales$184jh$1@dont-email.me> <tgar2s$1fm5$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 8g95CBl/Q95g60LTHC4XFA9tfr52l2RgywXbWihEpYtqA59E4=
Cancel-Lock: sha1:6JrN9KXWAm8Pz92wszHW8BNarko= sha1:Y7tfByyRnd1Z6oY1g3epiSYR4jA=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Tue, 20 Sep 2022 08:29 UTC

* saitology9 <saitology9@gmail.com>
| I agree Ralf's suggestion is the best approach here. Nevertheless, it
| might be useful to OP to know that they could fix the error above by
| properly constructing the callback like so:
>
>
| bind $tw.tree <<TreeviewOpen>> \
| [namespace code [list populateTree %W [list %W focus]]]

I don't think so, since that just builds a list, but does not *execute*
the "%W focus" when the binding is triggered. It just passes the string
"$tw.tree focus" as second parameter to [populateTree].

It is usually very tricky to create callbacks with execution syntax in
them, especially when there might be whitespace involved in the
parameters (let alone arbitrary user input). The better approach is to
keep the arguments minimal and put the workload *inside* the callback.

R'

Re: TCL Treeview issues

<yga8rme7877.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20112&group=comp.lang.tcl#20112

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 10:37:16 +0200
Lines: 45
Message-ID: <yga8rme7877.fsf@akutech.de>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net ilIMA/KZ+kHyfpkZmTp4MAiXYks2TnrI2nXutobgbaTsmA8XY=
Cancel-Lock: sha1:5O6G0bfgA0TqLcN7EQ/A4zFs9d0= sha1:S3KX3t32DijzJkD0ElQmB2dhlfk=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Tue, 20 Sep 2022 08:37 UTC

* GeorgeB <george.booth3182@gmail.com>
| > set selected [$tw.tree selection]
| > puts $selected
| > => I004 I005 I006
>
| I'd done exactly as you had suggested...but realised I forgot to select items in the tree....doh!!!

:-)

| I'm assuming I will have to map the id e.g. I004 etc to actual value in the tree?
| i.e. if id = I004 and I004 relates to file config.txt in tree then
| I'll have to map it somehow to each other .

That would be

$tw.tree item $item -text

or any other item option you are interested in:

foreach s [$tw.tree selection] {
puts "$s => [$tw.tree item $s -text]"
}
=>
I004 => _csp
I005 => _rpm
I006 => _s
I007 => _sk

| Is it possible to selected a node and get all values underneath it? On
| selection of the node is just gives me one single ID? e.g. Network
| file
| |- Folder 1
| |- file0.txt
| |- file1.txt
| |- file2.txt
| |- file3.txt
>
| I would like to get all items underneath Folder 1 by selecting Folder 1

Iterate over

$tw.tree children $item

HTH
R'

Re: TCL Treeview issues

<ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20117&group=comp.lang.tcl#20117

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:5bcd:0:b0:4ad:2ce4:e7d0 with SMTP id t13-20020ad45bcd000000b004ad2ce4e7d0mr11013437qvt.42.1663671455437;
Tue, 20 Sep 2022 03:57:35 -0700 (PDT)
X-Received: by 2002:a05:620a:4613:b0:6ce:bb01:a295 with SMTP id
br19-20020a05620a461300b006cebb01a295mr16425859qkb.71.1663671455217; Tue, 20
Sep 2022 03:57:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 20 Sep 2022 03:57:34 -0700 (PDT)
In-Reply-To: <yga8rme7877.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.85; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.85
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<yga8rme7877.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Tue, 20 Sep 2022 10:57:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2521
 by: GeorgeB - Tue, 20 Sep 2022 10:57 UTC

On Tuesday, September 20, 2022 at 9:37:21 AM UTC+1, Ralf Fassel wrote:
> * GeorgeB <george.b...@gmail.com>
> | > set selected [$tw.tree selection]
> | > puts $selected
> | > => I004 I005 I006
> >
> | I'd done exactly as you had suggested...but realised I forgot to select items in the tree....doh!!!
> :-)
> | I'm assuming I will have to map the id e.g. I004 etc to actual value in the tree?
> | i.e. if id = I004 and I004 relates to file config.txt in tree then
> | I'll have to map it somehow to each other .
> That would be
>
> $tw.tree item $item -text
>
> or any other item option you are interested in:
>
> foreach s [$tw.tree selection] {
> puts "$s => [$tw.tree item $s -text]"
> }
> =>
> I004 => _csp
> I005 => _rpm
> I006 => _s
> I007 => _sk
> | Is it possible to selected a node and get all values underneath it? On
> | selection of the node is just gives me one single ID? e.g. Network
> | file
> | |- Folder 1
> | |- file0.txt
> | |- file1.txt
> | |- file2.txt
> | |- file3.txt
> >
> | I would like to get all items underneath Folder 1 by selecting Folder 1
> Iterate over
>
> $tw.tree children $item
>
> HTH
> R'

:)

Thanks Ralf.

Re: TCL Treeview issues

<tgcge9$1h8e2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20120&group=comp.lang.tcl#20120

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 13:50:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <tgcge9$1h8e2$1@dont-email.me>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com> <ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com> <yga8rme7877.fsf@akutech.de> <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
Injection-Date: Tue, 20 Sep 2022 13:50:01 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="a5f0566b6dae085e145d3c961ab25cad";
logging-data="1614274"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KJ9YY8AVrodYZvGe1BzMq"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:xop72ck7TQvYbAyn+fYSqhCQ9Po=
 by: Rich - Tue, 20 Sep 2022 13:50 UTC

GeorgeB <george.booth3182@gmail.com> wrote:
> On Tuesday, September 20, 2022 at 9:37:21 AM UTC+1, Ralf Fassel wrote:
>> * GeorgeB <george.b...@gmail.com>
>> | > set selected [$tw.tree selection]
>> | > puts $selected
>> | > => I004 I005 I006
>> >
>> | I'd done exactly as you had suggested...but realised I forgot to
>> | select items in the tree....doh!!!
>> | :-)
>> | I'm assuming I will have to map the id e.g. I004 etc to actual value in the tree?
>> | i.e. if id = I004 and I004 relates to file config.txt in tree then
>> | I'll have to map it somehow to each other .
>> That would be
>>
>> $tw.tree item $item -text
>>
>> or any other item option you are interested in:
>>
>> foreach s [$tw.tree selection] {
>> puts "$s => [$tw.tree item $s -text]"
>> }
>
> :)
>
> Thanks Ralf.

Note also that you can add a list of tags to treeview items (read the
manpage for details). You can make use of tags for, among other uses,
tracking how a given row relates to the other data you are marshalling.

Note that the tags associated with an item are a Tcl list, so use
list operators to manipulate them.

Re: TCL Treeview issues

<b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20121&group=comp.lang.tcl#20121

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:528e:b0:4ac:d1bf:59b4 with SMTP id kj14-20020a056214528e00b004acd1bf59b4mr19497385qvb.3.1663687845450;
Tue, 20 Sep 2022 08:30:45 -0700 (PDT)
X-Received: by 2002:a05:6214:226a:b0:4ad:1cf0:849f with SMTP id
gs10-20020a056214226a00b004ad1cf0849fmr15645440qvb.102.1663687845221; Tue, 20
Sep 2022 08:30:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 20 Sep 2022 08:30:44 -0700 (PDT)
In-Reply-To: <tgcge9$1h8e2$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.85; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.85
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<yga8rme7877.fsf@akutech.de> <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
<tgcge9$1h8e2$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Tue, 20 Sep 2022 15:30:45 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3562
 by: GeorgeB - Tue, 20 Sep 2022 15:30 UTC

On Tuesday, September 20, 2022 at 2:50:06 PM UTC+1, Rich wrote:
> GeorgeB <george.b...@gmail.com> wrote:
> > On Tuesday, September 20, 2022 at 9:37:21 AM UTC+1, Ralf Fassel wrote:
> >> * GeorgeB <george.b...@gmail.com>
> >> | > set selected [$tw.tree selection]
> >> | > puts $selected
> >> | > => I004 I005 I006
> >> >
> >> | I'd done exactly as you had suggested...but realised I forgot to
> >> | select items in the tree....doh!!!
> >> | :-)
> >> | I'm assuming I will have to map the id e.g. I004 etc to actual value in the tree?
> >> | i.e. if id = I004 and I004 relates to file config.txt in tree then
> >> | I'll have to map it somehow to each other .
> >> That would be
> >>
> >> $tw.tree item $item -text
> >>
> >> or any other item option you are interested in:
> >>
> >> foreach s [$tw.tree selection] {
> >> puts "$s => [$tw.tree item $s -text]"
> >> }
> >
> > :)
> >
> > Thanks Ralf.
>
> Note also that you can add a list of tags to treeview items (read the
> manpage for details). You can make use of tags for, among other uses,
> tracking how a given row relates to the other data you are marshalling.
>
> Note that the tags associated with an item are a Tcl list, so use
> list operators to manipulate them.

Thanks Rich,

One thing I'm trying to figure out is how to filter on file extension.

Now I'm passing two folder (Folder 1 & Folder 2) to simulate the structure (see below), the tree structure is created as one would expect. However I was hoping to filter on *.ini files.

In doing so I was trying to figure out were it determines the file names before it populates the tree.

For Folder with out sub folder e.g. Folder 2, applying filter to "foreach f [lsort -dictionary [glob -nocomplain -dir $path *.ini]]" works, but not for folder with sub folder i.e. Folder 1

|- Folder 1
|- Sub folder
|- file0.ini
|- file1.docx
|- Sub Folder 2
|- file1.txt
|- file1.ini
|- Sub Folder 3
|- file2.ini
|- file2.txt
|- file2.docx

|- Folder 2
|- file01.ini
|- file11.docx
|- file21.xlsx
|- file31.txt

Re: TCL Treeview issues

<tgcsst$1i87g$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20122&group=comp.lang.tcl#20122

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 17:22:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <tgcsst$1i87g$1@dont-email.me>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com> <yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com> <ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com> <yga8rme7877.fsf@akutech.de> <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com> <tgcge9$1h8e2$1@dont-email.me> <b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>
Injection-Date: Tue, 20 Sep 2022 17:22:37 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="a5f0566b6dae085e145d3c961ab25cad";
logging-data="1646832"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18I1bAjWuUNaQW3opuX6/E4"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:6GaDnD7GDaNHKlGfPwk2sGb8XA4=
 by: Rich - Tue, 20 Sep 2022 17:22 UTC

GeorgeB <george.booth3182@gmail.com> wrote:
> On Tuesday, September 20, 2022 at 2:50:06 PM UTC+1, Rich wrote:
>> Note also that you can add a list of tags to treeview items (read
>> the manpage for details). You can make use of tags for, among other
>> uses, tracking how a given row relates to the other data you are
>> marshalling.
>>
>> Note that the tags associated with an item are a Tcl list, so use
>> list operators to manipulate them.
>
> Thanks Rich,
>
> One thing I'm trying to figure out is how to filter on file
> extension.

Read the 'file' manpage, specifically the "extension" subcommand.

> Now I'm passing two folder (Folder 1 & Folder 2) to simulate the
> structure (see below), the tree structure is created as one would
> expect. However I was hoping to filter on *.ini files.
>
> In doing so I was trying to figure out were it determines the file
> names before it populates the tree.

As we have no idea what "it" is, we are at a loss to offer much in the
way of suggestions.

Re: TCL Treeview issues

<tgcstu$1o9r$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20123&group=comp.lang.tcl#20123

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 13:23:05 -0400
Organization: Aioe.org NNTP Server
Message-ID: <tgcstu$1o9r$1@gioia.aioe.org>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<tgales$184jh$1@dont-email.me> <tgar2s$1fm5$1@gioia.aioe.org>
<ygaczbq78ku.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57659"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: saitology9 - Tue, 20 Sep 2022 17:23 UTC

On 9/20/22 4:29 AM, Ralf Fassel wrote:
>>
> | bind $tw.tree <<TreeviewOpen>> \
> | [namespace code [list populateTree %W [list %W focus]]]
>
> I don't think so, since that just builds a list, but does not *execute*
> the "%W focus" when the binding is triggered. It just passes the string
> "$tw.tree focus" as second parameter to [populateTree].
>

True indeed - it does not execute any code. What it does is enable
proper substitution as the original author of that code must have
intended, and passes its result as the argument. The argument happens
to contain a valid command that can be eval'ed, e.g., in the callback proc.

I am still learning the language but my suspicion is that anyone using
"%W" would know that it is only there to be substituted with the actual
target window name later when the callback takes place. Given the fact
that the original code the OP posted was from a demo file from
ActiveState, I assumed that they would know what they were doing with
that type of callback argument construction.

I completely agree with the rest of your post.

Re: TCL Treeview issues

<tgctbj$1u7g$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20124&group=comp.lang.tcl#20124

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: TCL Treeview issues
Date: Tue, 20 Sep 2022 13:30:22 -0400
Organization: Aioe.org NNTP Server
Message-ID: <tgctbj$1u7g$1@gioia.aioe.org>
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de>
<0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de>
<d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<yga8rme7877.fsf@akutech.de>
<ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
<tgcge9$1h8e2$1@dont-email.me>
<b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="63728"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: saitology9 - Tue, 20 Sep 2022 17:30 UTC

On 9/20/22 11:30 AM, GeorgeB wrote:
>
> For Folder with out sub folder e.g. Folder 2, applying filter to "foreach f [lsort -dictionary [glob -nocomplain -dir $path *.ini]]" works, but not for folder with sub folder i.e. Folder 1
>
> |- Folder 1
> |- Sub folder
> |- file0.ini
> |- file1.docx

Hello,

I doubt that, as Rich pointed out, "it" knows that you mean to separate
files from folders. Here you are dealing with two kinds of nodes in the
tree widget, and I believe it is up to you to determine when to add a
"folder" node and when to add a ".ini" file, or something else, and
where to add them in the tree hierarchy.

Re: TCL Treeview issues

<86a590d0-e640-49ae-b527-785a282fe9edn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20125&group=comp.lang.tcl#20125

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a37:790:0:b0:6cb:ebb2:2bd4 with SMTP id 138-20020a370790000000b006cbebb22bd4mr17391369qkh.612.1663698877239;
Tue, 20 Sep 2022 11:34:37 -0700 (PDT)
X-Received: by 2002:a05:620a:4613:b0:6ce:bb01:a295 with SMTP id
br19-20020a05620a461300b006cebb01a295mr18085753qkb.71.1663698877010; Tue, 20
Sep 2022 11:34:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 20 Sep 2022 11:34:36 -0700 (PDT)
In-Reply-To: <tgcsst$1i87g$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.85; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.85
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<yga8rme7877.fsf@akutech.de> <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
<tgcge9$1h8e2$1@dont-email.me> <b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>
<tgcsst$1i87g$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <86a590d0-e640-49ae-b527-785a282fe9edn@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Tue, 20 Sep 2022 18:34:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3392
 by: GeorgeB - Tue, 20 Sep 2022 18:34 UTC

On Tuesday, September 20, 2022 at 6:22:42 PM UTC+1, Rich wrote:
> GeorgeB <george.b...@gmail.com> wrote:
> > On Tuesday, September 20, 2022 at 2:50:06 PM UTC+1, Rich wrote:
> >> Note also that you can add a list of tags to treeview items (read
> >> the manpage for details). You can make use of tags for, among other
> >> uses, tracking how a given row relates to the other data you are
> >> marshalling.
> >>
> >> Note that the tags associated with an item are a Tcl list, so use
> >> list operators to manipulate them.
> >
> > Thanks Rich,
> >
> > One thing I'm trying to figure out is how to filter on file
> > extension.
> Read the 'file' manpage, specifically the "extension" subcommand.
> > Now I'm passing two folder (Folder 1 & Folder 2) to simulate the
> > structure (see below), the tree structure is created as one would
> > expect. However I was hoping to filter on *.ini files.
> >
> > In doing so I was trying to figure out were it determines the file
> > names before it populates the tree.
> As we have no idea what "it" is, we are at a loss to offer much in the
> way of suggestions.

Yes I've read that bit of the documentation and can filter within directories with extensions.

What I meant was in the code I posted in my first thread, I can't seem to figure out where to correctly apply the filter.

If I apply it where I think I should, foreach f [lsort -dictionary [glob -nocomplain -dir $path *.ini]], doesn't yield the desired result. This only seems to work with folders where files are at top level e.g. Folder 2 in my previous thread.

Hence I was trying to ascertain where within the code (as posted in the first thread), does it create a node for Folder 1 > Sub Folder > file

Since I couldn't figure it out I came asking help.

Maybe this is the downside of using demo.

Anyhoo, I'll try with fresh eyes approach tomorrow.

Re: TCL Treeview issues

<cdd4da22-8312-43e6-90a0-ecdfff0c75ban@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20126&group=comp.lang.tcl#20126

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:762:b0:4ac:ad95:2849 with SMTP id f2-20020a056214076200b004acad952849mr19681609qvz.14.1663698949012;
Tue, 20 Sep 2022 11:35:49 -0700 (PDT)
X-Received: by 2002:a37:2785:0:b0:6ce:7ce6:3d4a with SMTP id
n127-20020a372785000000b006ce7ce63d4amr17218013qkn.322.1663698948779; Tue, 20
Sep 2022 11:35:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Tue, 20 Sep 2022 11:35:48 -0700 (PDT)
In-Reply-To: <tgctbj$1u7g$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=147.161.166.85; posting-account=raWrPgoAAACs0CUtdroJeI3APEgMzJCg
NNTP-Posting-Host: 147.161.166.85
References: <ea3e25e5-e85f-419e-acb4-e66cb2167a14n@googlegroups.com>
<yga8rmfof7s.fsf@akutech.de> <0bb99cea-3097-47a9-9727-af64aff088efn@googlegroups.com>
<ygav8pjfsfo.fsf@akutech.de> <d3d875f4-adfc-4363-b6c8-6b610211604cn@googlegroups.com>
<yga8rme7877.fsf@akutech.de> <ae646732-b8f2-4b31-abfa-a044439f261dn@googlegroups.com>
<tgcge9$1h8e2$1@dont-email.me> <b8a2d45a-89ab-4cf3-8e22-313b096c3463n@googlegroups.com>
<tgctbj$1u7g$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cdd4da22-8312-43e6-90a0-ecdfff0c75ban@googlegroups.com>
Subject: Re: TCL Treeview issues
From: george.booth3182@gmail.com (GeorgeB)
Injection-Date: Tue, 20 Sep 2022 18:35:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2280
 by: GeorgeB - Tue, 20 Sep 2022 18:35 UTC

On Tuesday, September 20, 2022 at 6:30:31 PM UTC+1, saitology9 wrote:
> On 9/20/22 11:30 AM, GeorgeB wrote:
> >
> > For Folder with out sub folder e.g. Folder 2, applying filter to "foreach f [lsort -dictionary [glob -nocomplain -dir $path *.ini]]" works, but not for folder with sub folder i.e. Folder 1
> >
> > |- Folder 1
> > |- Sub folder
> > |- file0.ini
> > |- file1.docx
> Hello,
>
> I doubt that, as Rich pointed out, "it" knows that you mean to separate
> files from folders. Here you are dealing with two kinds of nodes in the
> tree widget, and I believe it is up to you to determine when to add a
> "folder" node and when to add a ".ini" file, or something else, and
> where to add them in the tree hierarchy.

Thanks saitology9, I'll have a think tomorrow.


devel / comp.lang.tcl / TCL Treeview issues

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor