MCPcopy Create free account
hub / github.com/EBjerrum/rdeditor / MolWidget

Class MolWidget

rdeditor/molViewWidget.py:23–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22# The Viewer Class
23class MolWidget(QtSvgWidgets.QSvgWidget):
24 def __init__(self, mol=None, parent=None, moldrawoptions: rdMolDraw2D.MolDrawOptions = None):
25 # Also init the super class
26 super(MolWidget, self).__init__(parent)
27
28 # logging
29 logging.basicConfig()
30 self.logger = logging.getLogger()
31 self.loglevel = logging.WARNING
32
33 # This sets the window to delete itself when its closed, so it doesn't keep lingering in the background
34 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
35 # Private Properties
36 self._mol = None # The molecule
37 self._drawmol = None # Molecule for drawing
38 self.drawer = None # drawing object for producing SVG
39 self._selectedAtoms = [] # List of selected atoms
40 self._darkmode = False
41
42 # Color settings
43 self._unsanitizable_background_colour = None # (1, 0.75, 0.75)
44 self._last_selected_highlight_colour = (1, 0.2, 0.2)
45 self._selected_highlight_colour = (1, 0.5, 0.5)
46
47 # Sanitization Settings
48 self._kekulize = False
49 self._sanitize = False
50 self._updatepropertycache = False
51
52 # Draw options
53 if moldrawoptions is None:
54 self._moldrawoptions = rdMolDraw2D.MolDraw2DSVG(300, 300).drawOptions()
55 self._moldrawoptions.prepareMolsBeforeDrawing = True
56 self._moldrawoptions.addStereoAnnotation = True
57 self._moldrawoptions.unspecifiedStereoIsUnknown = False
58 self._moldrawoptions.fixedBondLength = 25
59 else:
60 self._moldrawoptions = moldrawoptions
61
62 # Bind signales to slots for automatic actions
63 self.molChanged.connect(self.sanitize_draw)
64 self.selectionChanged.connect(self.draw)
65 self.drawSettingsChanged.connect(self.draw)
66 self.sanitizeSignal.connect(self.changeSanitizeStatus)
67
68 # Initialize class with the mol passed
69 self.mol = mol
70
71 ##Properties and their wrappers
72 @property
73 def loglevel(self):
74 return self.logger.level
75
76 @loglevel.setter
77 def loglevel(self, loglvl):
78 self.logger.setLevel(loglvl)
79
80 @property

Callers 2

molViewWidget.pyFile · 0.85
molEditWidget.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected