Hi Soren,
Very interesting script, thanks for sharing!
It looks like pymol2.PyMOL() doesn't work with the util module. It would need
to wrap all util functions and pass the "_self" argument with every function
call, just like pymol2.cmd2.Cmd does.
It works for me if I use pymol2.SingletonPyMOL() instead. That's what we use
with the PyQt interface. This "singleton" version uses the global pymol.cmd and
pymol.util modules as the API. You can only have one instance of the singleton.
If you want multiple instances with pymol2.PyMOL(), you'll need to do the
wrapping. For example like this:
class SelfProxy:
def __init__(self, proxied, _self):
self._self = _self
self.proxied = proxied
def __getattr__(self, key):
v = getattr(self.proxied, key)
def wrapper(*a, **k):
k['_self'] = self._self
return v(*a, **k)
return wrapper
# and after "self._pymol.start()":
import pymol.util
self._pymol.util = SelfProxy(pymol.util, self._pymol.cmd)
I've tested this and it works with the color menu.
Cheers,
Thomas
> On Feb 12, 2019, at 8:26 AM, Søren Nielsen <[email protected]>
> wrote:
>
>
> Hi,
>
> I am using pymol with a wxpython interface and everything seems to work,
> except when I try to change the color of an object using the internal gui, I
> get a NameError: name 'util' is not defined error... can you see what is the
> problem here?
>
> Best,
> Soren
--
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