コード例 #1
0
ファイル: __init__.py プロジェクト: e-kwsm/rdkit
    def MolDraw2DFromQPainter(qpainter,
                              width=-1,
                              height=-1,
                              panelWidth=-1,
                              panelHeight=-1):
        from PyQt5.Qt import QPainter
        try:
            # Prefer the PyQt5-bundled sip
            from PyQt5 import sip
        except ImportError:
            # No bundled sip, try the standalone package
            import sip
        from rdkit.Chem.Draw import rdMolDraw2DQt

        if not isinstance(qpainter, QPainter):
            raise ValueError("argument must be a QPainter instance")
        if width <= 0:
            width = qpainter.viewport().width()
        if height <= 0:
            height = qpainter.viewport().height()
        ptr = sip.unwrapinstance(qpainter)
        d2d = rdMolDraw2DQt.MolDraw2DFromQPainter_(width, height, ptr,
                                                   panelWidth, panelWidth)
        # tie the lifetime of the QPainter to this MolDraw2D object
        d2d._qptr = qpainter
        return d2d
コード例 #2
0
ファイル: testMolDraw2DQt.py プロジェクト: Kaziaa/rdkit-1
 def testfunc():
     m = Chem.MolFromSmiles('c1ccccc1O')
     Draw.PrepareMolForDrawing(m)
     qimg = QImage(250, 200, QImage.Format_RGB32)
     with QPainter(qimg) as qptr:
         p = sip.unwrapinstance(qptr)
         d2d = rdMolDraw2DQt.MolDraw2DFromQPainter_(250, 200, p, -1, -1)
     raise ValueError("expected")
コード例 #3
0
ファイル: testMolDraw2DQt.py プロジェクト: Kaziaa/rdkit-1
 def testSIPBasics(self):
     m = Chem.MolFromSmiles('c1ccccc1O')
     Draw.PrepareMolForDrawing(m)
     qimg = QImage(250, 200, QImage.Format_RGB32)
     with QPainter(qimg) as qptr:
         p = sip.unwrapinstance(qptr)
         d2d = rdMolDraw2DQt.MolDraw2DFromQPainter_(250, 200, p)
         d2d.DrawMolecule(m)
     qimg.save("testImageFromPyQt-1.png")