Hi Ed,
The tutorial doesn't consider that the "dialog" variable must not go out of
scope. It needs an additional reference to keep it alive, e.g. a global will
work:
dialog = None
def run_plugin_gui():
from pymol.Qt import QtWidgets
global dialog
if dialog is None:
dialog = QtWidgets.QDialog()
# TODO: FILL DIALOG WITH WIDGETS HERE
dialog.show()
The full example plugin on github doesn't suffer from this problem, it's kept
alive by circular references - at least until you run the Python garbage
collector (ouch!).
Cheers,
Thomas
On Wed, Jun 12, 2019 at 7:02 PM Edward Lowe <[email protected]> wrote:
>
> Hello,
>
> I'm trying to create what I think should be a fairly simple plugin to
> use pymol to showcase structures for a University Open day - all it
> needs to do is load up coordinate files and maps and present a very
> simple GUI that visitors can use to move between pre-defined scenes.
>
> I've constructed a PyQt plugin following the tutorial on pymolwiki
> which works up to a point...
> If I display the window using dialog.show() as in the tutorial example,
> the window disappears immediately on opening.
> If I change this to using dialog.exec() my widget opens correctly and
> everything works - but since this is now a modal window it is not
> possible to return to the main pymol gui and interact with the
> structure. This was the point of the exercise an why I'm not just
> making a movie!
>
> Does anyone have any advice on what could be done to fix this
> behaviour? It probably goes without saying that I am very much a
> novice at this!
>
> Thanks,
> Ed.
> --
> Dr. E.D. Lowe [email protected]
> Department of Biochemistry Tel: ++44 (0)1865 (2)75392
> University of Oxford
> Oxford UK, OX1 3QU
>
>
> _______________________________________________
> PyMOL-users mailing list
> Archives: http://www.mail-archive.com/[email protected]
> Unsubscribe:
> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/[email protected]
Unsubscribe:
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe