Python-Ref > Cheminformatics > BKChem scripting > BKChem plugins
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

BKChem plugins

How to write code snippets that can be run from BKChem menu.
A simple plugin is described here.
The following batch script can be used to add summary formula and composition below each molecule.
Expand/Shrink
<?xml version="1.0" encoding="utf-8"?>
<plugin>
  <meta>
    <author>Beda Kosata</author>
  </meta>
  <source>
    <file>bkchem1-1.py</file>
    <menu-text>Add summary formula below molecules</menu-text>
  </source>
</plugin>
Zdroj: (bkchem1-1.py)
  1   App.paper.unselect_all()
  2   
  3   for mol in App.paper.molecules:
  4     sumform = mol.get_formula_dict()
  5     txt = App.paper.new_text( 0, 0, text=sumform.get_html_repr_as_string())
  6     txt.draw()
  7     App.paper.select( mol)
  8     App.paper.place_next_to_selected( "b", "v", 10, txt)
  9     App.paper.unselect_all()
Screenshot:
Program screenshot bkchem1-1a.pngProgram screenshot bkchem1-1b.png
Doba běhu: 5.0 ms