I just found the pymol._ext_gui property, which seems to be None if X11 is
off and a positive number if X11 is present. Seeing as it's a private
variable, is it ok to use this to check for X11 presence?

-Spencer


On Thu, Apr 17, 2014 at 10:21 AM, Spencer Bliven <sbli...@ucsd.edu> wrote:

> Here's what I'm currently using. It seems to work so far. Looking through
> the PyMol binary I see about 50 possible names though, so it would be nice
> if there were a built-in way to detect X11.
>
> def hasTk():
>     """ Make an educated guess as to whether Tk is installed,
>     hopefully without triggering any installation on Macs
>     """
>     hasTk = True
>     if sys.platform=="darwin": #Mac
>         # Hack: check the path for entries containing 'X11'
>         hasTk = any([ "X11" in p.upper() for p in sys.path])
>
>     if hasTk:
>         try:
>             import Tkinter
>         except ImportError:
>             hasTk = False
>
>     return hasTk
>
>
> On Mon, Apr 14, 2014 at 10:46 AM, Spencer Bliven <sbli...@ucsd.edu> wrote:
>
>> I'm working on a plugin with a command line interface and a light-weight
>> tk interface through the plugins menu. This works fine on Linux, Windows,
>> and open-source Mac builds, but not on MacPyMol.app. Importing Tkinter
>> causes PyMol to quit with a prompt to install X11 (but not an ImportError,
>> as far as I can tell). If X11 is installed there are no errors, but there
>> is not a plugins menu, so I'd rather not bother loading and initializing
>> the Tk interface to the plugin.
>>
>> How can I detect whether Tk is available?
>>
>> I can think of two approaches, but haven't figured out the correct
>> commands for either. (1) Check the name that pymol was started with.
>> "MacPyMol.app" does not have Tk, while "PyMOLX11Hybrid.app" does.  I'm not
>> sure how to get the name (maybe could be guessed from sys.path?), and I
>> know there are a lot more variants than those two available. (2) Check for
>> the existence of the plugins menu. But this would have to be done without
>> importing Tk and triggering the X11 check.
>>
>> Is there a simple way to do this I'm overlooking?
>>
>> Thanks,
>> -Spencer
>>
>
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
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

Reply via email to