From: Alex Richards (
Date: Wed Jun 19 2013 - 16:49:40 CDT

That was certainly informative, but how thorny is thornier? Here is what
I get when I execute the following:

>> proc hello_world {args} {puts "Hello, World"}
>> hello_world
Hello, World
>> trace add variable ::vmd_pick_event write hello_world
>> trace info variable ::vmd_pick_event
{write hello_world}
>> puts $::vmd_pick_event
can't read "::vmd_pick_event": no such variable
>> puts $::vmd_pick_atom
can't read "::vmd_pick_atom": no such variable

After setting the trace, picking atoms in the OpenGL Display causes
nothing to occur in the TkConsole. It's interesting that the info
command shows the attached trace even though the variable doesn't seem
to exist anyways. What would be the next step in determining why this is
so? I see that vmd_pick_event was added in version 1.8.7 and my version
purports to be 1.9.1. I did not download and install it myself, however,
so I may simply replace the installation and see if that works. Also,
the machine I'm using has OSX 10.7.

On 06/19/2013 02:29 PM, Josh Vermaas wrote:
> Hi Alex,
> I've tested it on both machines I have ready access to, and I have no
> specific ideas as to why it works on my machines but not yours. There
> are a number of potential failure points. First off, you need to make
> sure the trace is working. For that, I'd start with a much simpler
> proc (puts "Hello World" or something like that) to make sure your
> procedure is activating when you pick an atom. If the trace is
> working, the most likely point of failure is not being able to find
> the variables... This is somewhat thornier, and should be investigated
> by explicitly calling your proc (somehow trace quashes error
> messages). On my machine, the variable $vmd_pick_atom exists in the
> global namespace, so "puts $::vmd_pick_atom" always works.
> Hope this helps!
> -Josh Vermaas
> On 06/18/2013 03:31 PM, Alex Richards wrote:
>> Josh,
>> That is exactly what I was looking for! Except... it doesn't quite
>> seem to be working for me. Here's my process. In VMD TkConsole, enter
>> set ilist [list ]
>> proc add_to_list {args} {lappend ::ilist $::vmd_pick_atom ; puts
>> $::vmd_pick_atom}
>> trace add variable vmd_pick_event write add_to_list
>> Then I take the mouse, enter Query Mode (although I believe any
>> left-clicking counts as picking...), pick atoms, at which point I can
>> see the feedback in the Terminal, but nothing in TkConsole where I
>> would expect to see the output of that puts command. Then, in
>> TkConsole, if I enter
>> puts $ilist
>> it just returns an empty list.
>> Noting the syntax highlighting in the TkConsole, I see that
>> [::]vmd_pick_atom and [::]vmd_pick_event do not become highlighted as
>> though they were variable names, which I think I would expect them to
>> be. From everything I've read on callbacks, trace, proc, global,
>> upvar, etc., I see no reason why your code wouldn't work except for
>> perhaps not being able to access the global variables vmd_pick_atom
>> and ilist, but I would think the :: would take care of that. At any
>> rate, I've used all the combinations of:: andglobal that I can think
>> of, but nothing seems to be taking.
>> Also, the output of
>> trace info variable vmd_pick_event
>> is
>> {write add_to_list}
>> like I would expect.
>> Any ideas?
>> Thank You,
>> A- R-
>> On 06/17/2013 05:37 PM, Josh Vermaas wrote:
>>> Hi Alex,
>>> I think you'll be interested in the TCL callbacks
>>> ( You'll be
>>> wanting to do something like this in the tkCon window (or in your
>>> startup script):
>>> #Make an empty list
>>> set ilist [list ]
>>> #Define a new proc to add new indices to the list.
>>> proc add_to_list {args} {
>>> lappend ::ilist $::vmd_pick_atom
>>> puts $::vmd_pick_atom
>>> }
>>> #Add a trace so that the proc is called whenever an atom is picked
>>> trace add variable vmd_pick_event write add_to_list
>>> After picking a few atoms, you should see that $ilist now contains the
>>> indices of the selected atoms.
>>> Happy Picking!
>>> -Josh Vermaas
>>> On 06/17/2013 04:32 PM, Alex Richards wrote:
>>>> Hi All,
>>>> I see that I can "pick" an atom in the OpenGL Display and have some
>>>> identifying information about it posted into the terminal window. I
>>>> would like to be able to "pick" an atom in such manner and automatically
>>>> have it or its index added to a list which I can use in scripting. Is
>>>> there a way to do this that has already been established? I usually use
>>>> the TkConsole and I know that the atom info gets output to the Terminal
>>>> window, so I'm not sure if I can move data back and forth between the
>>>> two anyways. Thank you.
>>>> A- R-