RE: [PyMOL] How to send pymol command to pymol by python interpreter

2004-01-22 Thread Warren L. DeLano
Takefumi,

You only need to worry about this if you're using an external Python
interpreter with a modular build of PyMOL.  For example, after
installing a late-model linux PyMOL RPM, you run

python script.py

Where script.py contains the following sequence:

import pymol
pymol.finish_launching()

which is needed to insure that PyMOL's API in the parallel thread is
defined ready to receive messages.

The problem is that PyMOL can't launch until import pymol completes
and returns and __main__.pymol is defined.  However, that means that the
next command in your script will need to be executed before PYMOL has
had a chance to initialize itself.  So the current approach is to launch
the PyMOL thread, and then call a function which blocks until PyMOL is
all ready to go...

Cheers,
Warren

[PS If there's anyone out there with a more elegant alternative for
launching the PyMOL thread from a standalone Python script, I'd sure
like to hear it : )].

--
mailto:war...@delanoscientific.com
Warren L. DeLano, Ph.D.
Principal Scientist
DeLano Scientific LLC
Voice (650)-346-1154 
Fax   (650)-593-4020

 -Original Message-
 From: pymol-users-ad...@lists.sourceforge.net [mailto:pymol-users-
 ad...@lists.sourceforge.net] On Behalf Of Takefumi Sora
 Sent: Wednesday, January 21, 2004 10:57 PM
 To: pymol-users@lists.sourceforge.net
 Subject: RE: [PyMOL] How to send pymol command to pymol by python
 interpreter
 
 
 Hi.
 
 I appreciate your answer, Warren.
 Thank you.
 
 Please let me ask one more question.
 
 You said I need two lines first:
 import pymol
 pymol.finish_launching()
 
 As long as I use,I can't the role of
 pymol.finish_launching()
 if I don't call this, what troubles will happen ?
 
 Takefumi SORA
 
 
 
 ---
 The SF.Net email is sponsored by EclipseCon 2004
 Premiere Conference on Open Tools Development and Integration
 See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
 http://www.eclipsecon.org/osdn
 ___
 PyMOL-users mailing list
 PyMOL-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/pymol-users





RE: [PyMOL] How to send pymol command to pymol by python interpreter

2004-01-22 Thread pymol
On Thu, 22 Jan 2004, Warren L. DeLano wrote:

 Where script.py contains the following sequence:
 
 import pymol
 pymol.finish_launching()
 
 [PS If there's anyone out there with a more elegant alternative for
 launching the PyMOL thread from a standalone Python script, I'd sure
 like to hear it : )].

I don't have anything significant to contribute to a revised interface
right now, but I just wanted to say that I think it is strange that an
import statement starts doing things like launching threads. The
import should just make an interface available, and then the script
can use the interface to create a pymol object or whatever:

  import pymol

  pymolHandle = pymol.create(options like window size, parent window to create 
in)
  pymolHandle.cmd.show(sticks, someName)

The pymol.create() blocks until things are ready, so it is sort of the
same as calling pymol.finish_launching(), but it seems more natural to
this programmer. I don't expect import statements to do much. If I
import imaplib it doesn't create an interface to an IMAP server,
right? It just gives me the ability to do so.

It would be up to the application to maintain or pass around
pymolHandle to various modules/objects to get things done.

Perhaps an app could use pymol.create() to create another instance, a
second rendering window? Shared model underneath? Hmmm. . .

When I delete pymolHandle or it goes out of scope, the thread should
shut down and other resources should be released. It should NOT kill
my application as it currently does when I call cmd.quit(). It's just
a thread, it shouldn't be making decisions for my application.

-Bob

  -Original Message-
  From: pymol-users-ad...@lists.sourceforge.net [mailto:pymol-users-
  ad...@lists.sourceforge.net] On Behalf Of Takefumi Sora
  Sent: Wednesday, January 21, 2004 10:57 PM
  To: pymol-users@lists.sourceforge.net
  Subject: RE: [PyMOL] How to send pymol command to pymol by python
  interpreter
  
  
  Hi.
  
  I appreciate your answer, Warren.
  Thank you.
  
  Please let me ask one more question.
  
  You said I need two lines first:
  import pymol
  pymol.finish_launching()
  
  As long as I use,I can't the role of
  pymol.finish_launching()
  if I don't call this, what troubles will happen ?
  
  Takefumi SORA
  
  
  
  ---
  The SF.Net email is sponsored by EclipseCon 2004
  Premiere Conference on Open Tools Development and Integration
  See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
  http://www.eclipsecon.org/osdn
  ___
  PyMOL-users mailing list
  PyMOL-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/pymol-users
 
 
 
 
 ---
 The SF.Net email is sponsored by EclipseCon 2004
 Premiere Conference on Open Tools Development and Integration
 See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
 http://www.eclipsecon.org/osdn
 ___
 PyMOL-users mailing list
 PyMOL-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/pymol-users
 




RE: [PyMOL] How to send pymol command to pymol by python interpreter

2004-01-21 Thread Takefumi Sora
Hi.

I appreciate your answer, Warren.
Thank you.

Please let me ask one more question.

You said I need two lines first:
import pymol
pymol.finish_launching()

As long as I use,I can't the role of 
pymol.finish_launching()
if I don't call this, what troubles will happen ?

Takefumi SORA