Dear Dan, for me this sample program works:
import sys sys.path.append("/home/guido/pymol1.3/pymol-1.3r2/modules") from OpenGL.GL import * from OpenGL.GLU import * from PyQt4 import QtGui from PyQt4.QtOpenGL import * from PyQt4.Qt import Qt from PyQt4 import QtCore import pymol2 class PymolQtWidget(QGLWidget): _buttonMap = {Qt.LeftButton:0, Qt.MidButton:1, Qt.RightButton:2} def __init__(self, parent, enableUi,File=""): f = QGLFormat() f.setStencil(True) f.setRgba(True) f.setDepth(True) f.setDoubleBuffer(True) QGLWidget.__init__(self, f, parent=parent) self.setMinimumSize(500, 500) self._enableUi=enableUi self.pymol = pymol2.PyMOL()# _pymolPool.getInstance() self.pymol.start() self.cmd = self.pymol.cmd # self.toPymolName = self.pymol.toPymolName ### Attribute Error self._pymolProcess() if not self._enableUi: self.pymol.cmd.set("internal_gui",0) self.pymol.cmd.set("internal_feedback",0) self.pymol.cmd.button("double_left","None","None") self.pymol.cmd.button("single_right","None","None") self.pymol.cmd.load(File) self.pymol.reshape(self.width(),self.height()) self._timer = QtCore.QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self._pymolProcess) self.resizeGL(self.width(),self.height()) #globalSettings.settingsChanged.connect(self._updateGlobalSettings) self._updateGlobalSettings() def __del__(self): pass def _updateGlobalSettings(self): #for k,v in globalSettings.settings.iteritems(): # self.pymol.cmd.set(k, v) #self.update() return def redoSizing(self): self.resizeGL(self.width(), self.height()) def paintGL(self): glViewport(0,0,self.width(), self.height()) bottom = self.mapToGlobal(QtCore.QPoint(0,self.height())).y() #self.pymol.cmd.set("_stencil_parity", bottom & 0x1) self._doIdle() self.pymol.draw() def mouseMoveEvent(self, ev): self.pymol.drag(ev.x(), self.height()-ev.y(),0) self._pymolProcess() def mousePressEvent(self, ev): if not self._enableUi: self.pymol.cmd.button("double_left","None","None") self.pymol.cmd.button("single_right","None","None") self.pymol.button(self._buttonMap[ev.button()], 0, ev.x(), self.height()-ev.y(),0) self._pymolProcess() def mouseReleaseEvent(self, ev): self.pymol.button(self._buttonMap[ev.button()], 1, ev.x(), self.height()-ev.y(),0) self._pymolProcess() self._timer.start(0) def resizeGL(self, w, h): self.pymol.reshape(w,h, True) self._pymolProcess() def initializeGL(self): pass def _pymolProcess(self): self._doIdle() self.update() def _doIdle(self): if self.pymol.idle(): self._timer.start(0) # You don't need anything below this class PyMolWidgetDemo(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) widget = PymolQtWidget(self,True,"D2.xyz") self.setCentralWidget(widget) if __name__ == '__main__': app = QtGui.QApplication(['PyMol Widget Demo']) window = PyMolWidgetDemo() window.show() app.exec_() Best regards, Guido Zitat von Dan O'Donovan <odono...@hkl.hms.harvard.edu>: > Dear All, > > I read with interest Jason Ferrara's post concerning embedding PyMOL > in a QT app (back in January > http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg08607.html > ). I've spent a short time experimenting and have encountered a > problem or two - I was wondering if any insightful users had any > pointers for me. > > I've built pymol from the SourceForge source (1.4.1) on some Fedora > linux x86 box. I initially jumped straight into the QT code, but > experienced a few crashes. Taking things apart further, I've got a > little script that consistently crashes with a segfault: > > import sys > sys.path.append( os.path.join( os.environ['PYMOL_PATH'], 'modules' ) ) > > import pymol2 > pymol = pymol2.PyMOL() > > print 'pymol initialised' > pymol.cmd.set("internal_gui",0) > print 'we never see this' > > $ python crash.py >> pymol initialised >> Segmentation fault (core dumped) > > Should this ever work? The code is a snippet from Jason's approach. > I appreciate that it doesn't do anything, but should I expect a > crash? Getting personal with gdb the stack trace comes up with > > 0x00007fffed6830e6 in APIEnterBlocked (self=0xd3c148, args=<value > optimized out>) at layer4/Cmd.c:160 > 160 PRINTFD(G, FB_API) > > which seems relatively benign (there is a > PyThread_get_thread_ident() call there). > > Thanks for reading this far, > > Dan > > Dan O'Donovan > SBGrid Consortium > Harvard Medical School > --- Dr. Guido Wagner Institut für Anorganische und Analytische Chemie der Johann Wolfgang Goethe-Universität Frankfurt Max-von-Laue-Str. 7, D-60438 Frankfurt/Main, Germany Tel.: (+49)69-798-29414, Fax: -29417 eMail: wag...@chemie.uni-frankfurt.de ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net