File: sele_wiz.py

package info (click to toggle)
pymol 2.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 43,312 kB
  • sloc: cpp: 480,106; python: 79,860; ansic: 28,343; javascript: 6,792; sh: 47; makefile: 30; csh: 8
file content (59 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

# demonstrate how to capture PyMOL's atom selection events

from pymol.wizard import Wizard
from pymol import cmd
import pymol

sele_name = "lb" # must be set to "lb" for now...

class PickWizard(Wizard):

   def set_buttons(self):
      
      # just use selections (disable atom and bond picking)
      
      cmd.button('m','ctrl','+lb')
      cmd.button('r','ctrl','none')
      cmd.button('r','ctsh','none')
      
   def get_prompt(self):

      # returns prompt for the viewer window (optional)
      
      if sele_name in cmd.get_names('selections'):
         n_atom = cmd.count_atoms(sele_name)
      else:
         n_atom = 0
      if n_atom:
         list = cmd.identify(sele_name)
         return ["%d atoms selected..."%n_atom,str(list)]
      else:
         return ["Please select some atoms..."]

   def do_select(self,name):

      # handle mouse selection callback
      
      if not sele_name in cmd.get_names('selections'):
         cmd.select(sele_name,'none')
      cmd.enable(sele_name)
      cmd.refresh_wizard()

   def get_panel(self):
      return [
         [ 1, 'Example Wizard',''],         
         [ 2, 'Clear Selection',
           'cmd.delete("'+sele_name+'");cmd.refresh_wizard()'],
         ]

wiz = PickWizard()

# make this the active wizard

cmd.set_wizard(wiz)

# reconfigure the mouse panel

wiz.set_buttons()