Hi Takanori,
thanks for the detailed analysis. Very helpful
Cheers,
Carsten
-----Original Message-----
From: Takanori Nakane [mailto:[email protected]]
Sent: Tuesday, August 21, 2012 5:18 AM
To: [email protected]
Subject: Re: [PyMOL] Syntax for cmd.auto_arg.update
Hi Carsten,
Below is what I learned by reading codes and experimenting.
The relevant code is in parser.py, cmd.py and shortcut.py.
Please correct me if I am wrong.
+++++++++++++++++++++
When Pymol's console attempts to auto-complete the n-th argument
of command 'abc', it will look at cmd.auto_arg[n]['abc']
(n starts from 0). This is a list with three elements.
The first element is a lambda function which returns an Shortcut object.
Shortcut object wraps the list of candidate strings, given to
its constructor.
The second element is a string, which describs the argument.
The third element is a string, which will be added after autocompletion
(postfix).
Example:
cmd.auto_arg[0]['test']=[lambda: cmd.Shortcut(['abc','bcd']), '1st
argument', ', ']
will setup the autocompletion list of the first argument of command
'test'. When you type 'test ' and press TAB, PyMOL will show you
two candidates as:
parser: matching 1st argument:
abc bcd
If you type 'a' and press TAB again, PyMOL will complete it to
"test abc, ". Please note that ', ' is added.
Pre-defined lambdas:
In most cases, you just want to complete from object names or
setting lists. Then you don't have to write your own lambda
function. Just use cmd.object_sc for choosing from objects.
cmd.auto_arg[0]['test'] = [ cmd.object_sc, 'object', '']
Use cmd.selection_sc for setting names (like 'line_width'),
cmd.map_sc for maps, cmd,repres_sc for representations
(sticks, lines, etc).
By the way, update is another way to set values to Python's Dict.
auto_arg[0]['test'] = [some, thing, s] is same as
auto_arg[0].update([('test', [some, thing, s])]).
Best regards,
Takanori Nakane
------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
PyMOL-users mailing list ([email protected])
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/[email protected]
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
PyMOL-users mailing list ([email protected])
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/[email protected]