[chimera-dev] dialog, display it, query its size and position on the screen in pixels, reposition it, and close it.

Eric Pettersen pett at cgl.ucsf.edu
Mon Apr 1 12:49:08 PDT 2013


Hi Matt,
	Tom Goddard is on a trip to LA and will be back at work on Wednesday, so I'm going to answer the questions I can and leave the others for Tom...

On Mar 28, 2013, at 7:56 PM, Dougherty, Matthew T wrote:

> Hi Tom,
> 
> the USB-HID development is going well.  I implemented the code below, make it operate where I needed it,

The code listed below actually works as is?  I should think you would need to suppress the "dialog tiling" that Chimera attempts to do, which happens asynchronously after dialog creation.  Do you autostart the SideView?  Anyway, if you run into conflicts between your attempted positioning and the tiling, add a line to your code:

from chimera import dialogs, viewing
viewing.ViewerDialog.autoposition = False
d = dialogs.find(viewing.ViewerDialog.name, create = 1) # Get the side view dialog

The vast majority of Chimera dialogs work this way (IDLE is the only exception I can think of off the top of my head).

> put the cursor onto the panel ready to go, using a single button push; then use another button to close it and move back to the display, click on it to make it active, so to be ready for more button pushes.  This combined with other codes I can now easily manage hundreds of savepos, or tweak z & focal parameters, then triage them later.
> 
> Now I want to do something similar for a variety of dialogs, I particularly want to move the main display, Reply Log, Volume Viewer, Model Panel, & Keyboard Shortcuts.  How can I systemically figure these out without bugging you on these small details?

In IDLE, the following will list the dialog registrations:

from chimera.dialogs import _allDialogs
from pprint import pprint
pprint(_allDialogs)

From the output of the above commands I glean that:

Reply Log:  chimera.tkgui._ReplyDialog
Model Panel:  ModelPanel.base.ModelPanel (since ModelPanel imports * from base, just ModelPanel.ModelPanel is okay)

The main display, which isn't really a dialog, is chimera.tkgui.app.

I guess this isn't exactly systematic since a lot of extensions don't register their dialogs until the extension is imported.  So for example the Volume Viewer dialog isn't listed unless you do an "import VolumeViewer" before the commands I listed above.  If you do then you see that:

Volume Viewer:  VolumeViewer.volumedialog.Volume_Dialog

Unfortunately for Keyboard Shortcuts, simply "import Accelerators" isn't enough; you have to "import Accelerators.gui" by which time you might have well just looked in the Python file.  Nonetheless, that import reveals:

Keyboard Shortcuts:  Accelerators.gui.Accelerator_Browser

So do you know how to find the Python module name for a tool?  Unless it's "core" enough to be in the chimera module itself (in which case the inspection of _allDialogs should get it), go to Chimera's "share" folder and:

grep "Tool Name" */ChimeraExtension.py

That should reveal which module registers the tool.

> Couple of other related questions & observations:
> 1) On the example below: the ViewerDialog has five panels.  How can I control which panel comes up?

Urg.  Do not blame me -- I did not write this code.  You use the displayed tab name prepended with a 'p' (really, I did not write this!) as follows if you have the Side View dialog instance in the variable 'd':

d.nb.raise_page('pRotation')

In most sane code you would just be using the displayed tab name.

> 2) with all the more sophisticated camera movements, I am beginning to rethink lighting.  In the past I have just used defaults, maybe a few adjustments on reflectivity. Can I create more lights, or move lights?  I assume I can, but I don't want to start mucking around the code and start breaking things or create things that will be hard to maintain.

Look at the Lighting module.  It looks like you are limited to a maximum of 3 lights, but I'm guessing that's good enough.  There are functions in there for changing the lighting "mode" (1/2/3 lights, or ambient lighting only), contrast, brightness, and the color/direction of the various lights.

These last two questions will have to wait until Tom's return...

--Eric

> 3) I have noticed >50% of the time when Chimera comes up the accelerator commands are inactive requiring me to type "ac".  
> 4) after getting a basic USB-HID config I plan to go after volume rendering, as mentioned before.  A key method in structuring the transfer function is to push a square wave through the range of data, flagging thresholds that have interesting  density; from that combine them and individually adjust those thresholds in context of the group.  So I think the USB-HID will be helpful in sorting through it quickly.
> 
> thanks,
> 
> 
> Matthew Dougherty
> National Center for Macromolecular Imaging
> Baylor College of Medicine
> ________________________________________
> From: Tom Goddard
> Sent: Friday, March 08, 2013 8:40 PM
> To: Dougherty, Matthew T
> Cc: chimera-dev at cgl.ucsf.edu
> Subject: Re: [chimera-dev] 3dconnexion
> 
> Hi Matt,
> 
>  Here is Python to get the side view dialog, display it, query its size and position on the screen in pixels, reposition it, and close it.
> 
> from chimera import dialogs, viewing
> d = dialogs.find(viewing.ViewerDialog.name, create = 1) # Get the side view dialog
> d.enter()  # Display the dialog
> d.uiMaster().winfo_toplevel().wm_geometry()  # Get the current size and position
> '400x341+1186+696'
> d.uiMaster().winfo_toplevel().wm_geometry('+500+700') # set the position to 500,700
> d.Close()  # Close window
> 
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev

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


More information about the Chimera-dev mailing list