[chimera-dev] ViewMatch extension for Chimera

Eric Pettersen pett at cgl.ucsf.edu
Wed Dec 10 14:58:58 PST 2008


> This is my first attempt at writing an extension for Chimera (and  
> writing anything in python, for that matter). Using the ViewDock  
> extension as a starting point (which Scooter suggested to me at  
> CSB2007) made it very easy. There are probably many things that  
> could be done better. If you have any suggestions, we would very  
> much like to know. One thing that would be nice to have is to be  
> able to select a maximum number of matches to load in the ViewMatch  
> Open-File dialog. Right now, that number is hard-coded in the code,  
> which is not ideal.

First I want to agree with Elaine:  ViewMatch is very nice!

You can definitely customize Open/Save dialogs to get additional  
parameters that you need.  This is documented in good detail in the  
module doc string of OpenSave (i.e. at the top of OpenSave/ 
__init__.py). Basically you: subclass from OpenModeless; supply the  
'clientPos' keyword when you call OpenModeless.__init__ from your  
__init__ (probably with the value 's'); overrride fillInUI() by  
calling the parent fillInUI() and then populate self.clientArea with  
your widgets.  In your Apply function you would read the values from  
your widgets (and the file name from self.getPaths()).  There's a  
reasonably simple example of this usage in the AddAttrDialog class in  
AddAttr/gui.py.  You could use the chimera.tkoptions.IntOption widget  
to get your integer or Pmw.EntryField.

You might also like ViewMatch to remember what value the user chose in  
their last session so you can use it as the widget's default value in  
the next session.  You use Chimera's "preferences" mechanism for  
that.  It's probably easiest to explain by example; here is the  
prefs.py file of FindHBond:

from chimera import preferences

BOND_COLOR = 'bondColor'
RELAX_COLOR = 'relaxColor'
LINE_WIDTH = 'line width'

defaults = {
	BOND_COLOR: (0.0, 0.8, 0.9, 1.0),
	RELAX_COLOR: (0.95, 0.5, 0.0, 1.0),
	LINE_WIDTH: 1.0,
}
prefs = preferences.addCategory("FindHBonds",  
preferences.HiddenCategory,
						optDict=defaults.copy())

Basically, the 'prefs' instance can be accessed like a dictionary to  
fetch the default value of a parameter (prefs[LINE_WIDTH]) or to set a  
new default (prefs[LINE_WIDTH] = 3) and will be remembered across  
sessions.

I hope this helps.

--Eric

                         Eric Pettersen
                         UCSF Computer Graphics Lab
                         http://www.cgl.ucsf.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20081210/9af25384/attachment.html>


More information about the Chimera-dev mailing list