예제 #1
0
 def paintEvent(self, ev):
     self.painter = QtGui.QPainter()
     self.painter.begin(self)
     self.painter.drawText(15, 15, "Contour Example using PyQt6 ...")
     os.environ['GKSconid'] = "%x!%x" % (sip.unwrapinstance(self),
                                         sip.unwrapinstance(self.painter))
     gr.updatews()
     self.painter.end()
예제 #2
0
 def QAction_setMenu(self, menu):
     if menu is not None and not isinstance(menu, QMenu):
         raise TypeError()
     if menu is not None and isdeleted(menu):
         raise RuntimeError()
     if isdeleted(self):
         raise RuntimeError()
     self.__QAction_menu = menu
     _QAction_setMenuObject(unwrapinstance(self),
                            unwrapinstance(menu) if menu is not None else 0)
예제 #3
0
  def MolDraw2DFromQPainter(qpainter, width=-1, height=-1, panelWidth=-1, panelHeight=-1):
    from rdkit.Chem.Draw import rdMolDraw2DQt
    if rdMolDraw2DQt.rdkitQtVersion.startswith('6'):
      from PyQt6.QtGui import QPainter
    else:
      from PyQt5.Qt import QPainter
    try:
      # Prefer the PyQt-bundled sip
      if rdMolDraw2DQt.rdkitQtVersion.startswith('6'):
        from PyQt6 import sip
      else:
        from PyQt5 import sip
    except ImportError:
      # No bundled sip, try the standalone package
      import sip

    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
예제 #4
0
 def testfunc():
     m = Chem.MolFromSmiles('c1ccccc1O')
     Draw.PrepareMolForDrawing(m)
     qimg = QImage(250, 200, Format_RGB32)
     with QPainter(qimg) as qptr:
         p = sip.unwrapinstance(qptr)
         d2d = rdMolDraw2DQt.MolDraw2DFromQPainter_(250, 200, p, -1, -1)
     raise ValueError("expected")
예제 #5
0
 def QAction_menu(self):
     if isdeleted(self):
         raise RuntimeError()
     ptr = _QAction_menuObject(unwrapinstance(self))
     if ptr is None:
         return None
     menu = wrapinstance(ptr, QMenu)
     return menu
예제 #6
0
 def testSIPBasics(self):
     m = Chem.MolFromSmiles('c1ccccc1O')
     Draw.PrepareMolForDrawing(m)
     qimg = QImage(250, 200, 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")