Using Avogadro from Python

I know that it’s possible to play around with Avogadro from the Python
terminal in Avogadro, but is it possible to control Avogadro from a
Python script running at the Windows command prompt (for example).

  • Noel

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

Marcus

2009/10/6 Marcus D. Hanwell marcus@cryos.org:

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

Is there any working example of this? This would solve my problem.

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

I don’t need this, but it would provide a way to interface with
Avogadro from other languages, e.g. Java.

Marcus

On Tue, Oct 6, 2009 at 3:01 PM, Noel O’Boyle baoilleach@gmail.com wrote:

2009/10/6 Marcus D. Hanwell marcus@cryos.org:

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

Is there any working example of this? This would solve my problem.

These are the files from the example on my blog:

standalone.py: http://pastebin.com/f31262712
mainwindow.ui: http://pastebin.com/f5fefc48f

Tim

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

I don’t need this, but it would provide a way to interface with
Avogadro from other languages, e.g. Java.

Marcus


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss

Interesting. When can compilophobic mac users try this? :slight_smile:

Jan

“Tim Vandermeersch” tim.vandermeersch@gmail.com skrev:

On Tue, Oct 6, 2009 at 3:01 PM, Noel O’Boyle baoilleach@gmail.com
wrote:

2009/10/6 Marcus D. Hanwell marcus@cryos.org:

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

Is there any working example of this? This would solve my problem.

These are the files from the example on my blog:

standalone.py: http://pastebin.com/f31262712
mainwindow.ui: http://pastebin.com/f5fefc48f

Tim

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

I don’t need this, but it would provide a way to interface with
Avogadro from other languages, e.g. Java.

Marcus


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and
stay

ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay

ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss

I couldn’t get Tim’s UI to work on Windows. This may be because rather
than using the binary releases of PyQt4 and Python, Avogadro compiles
everything itself. That seems to rule out using Avogadro externally
from Python.

  • Noel

2009/10/6 Tim Vandermeersch tim.vandermeersch@gmail.com:

On Tue, Oct 6, 2009 at 3:01 PM, Noel O’Boyle baoilleach@gmail.com wrote:

2009/10/6 Marcus D. Hanwell marcus@cryos.org:

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

Is there any working example of this? This would solve my problem.

These are the files from the example on my blog:
http://timvdm.blogspot.com/2009/05/using-avogadro-library-from-python.html

standalone.py: http://pastebin.com/f31262712
mainwindow.ui: http://pastebin.com/f5fefc48f

Tim

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

I don’t need this, but it would provide a way to interface with
Avogadro from other languages, e.g. Java.

Marcus


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss

On Fri, Oct 9, 2009 at 12:35 PM, Noel O’Boyle baoilleach@gmail.com wrote:

I couldn’t get Tim’s UI to work on Windows. This may be because rather
than using the binary releases of PyQt4 and Python, Avogadro compiles
everything itself. That seems to rule out using Avogadro externally
from Python.

I could include the python interpretor in the package. This would at
least allow you to use python + PyQt + numpy + avogadro. Additional
packages could still be installed to the avogadro directory.

Tim

  • Noel

2009/10/6 Tim Vandermeersch tim.vandermeersch@gmail.com:

On Tue, Oct 6, 2009 at 3:01 PM, Noel O’Boyle baoilleach@gmail.com wrote:

2009/10/6 Marcus D. Hanwell marcus@cryos.org:

Noel O’Boyle wrote:

2009/10/6 Karol M. Langner karol.langner@gmail.com:

On Tuesday 06 October 2009 13:25:46 Geoffrey Hutchison wrote:

On Oct 6, 2009, at 7:04 AM, Noel O’Boyle wrote:

Is it possible to control Avogadro from a
Python script running at the Windows command prompt

It’s possible to embed Avogadro in a Python script. But no, at the
moment, Avogadro does not accept “signals” or external commands from
other processes. I’m not even sure if that would be secure.

Cheers,
-Geoff

Maybe it’s worthwhile to think about. That would be so useful…

From a user’s perspective, there are two ways to go. Either “import
avogadro; avogadro.startgui(); avogadro.display(myOBMol)” or as am
currently doing with pymol (you need to start it with the -R option)
“import xmlrpclib; s = xmlrpclib.Server(“http://localhost:9123”);
s.loadfile(“myfile”)”

  • Noel

I think that the first approach is the one which works now (or did).
This is also the approach used in applications with similar Python
bindings such as VTK and ParaView. You use the embedded interpreter to
manipulate the application, or start a new instance from a shell.

Is there any working example of this? This would solve my problem.

These are the files from the example on my blog:
http://timvdm.blogspot.com/2009/05/using-avogadro-library-from-python.html

standalone.py: http://pastebin.com/f31262712
mainwindow.ui: http://pastebin.com/f5fefc48f

Tim

The second approach would be interesting, but would need some work to
set up a server. Are there many use cases not satisfied by starting a
new instance of Avogadro from a shell (or more likely, the GLWidget),
and if users want the full application too then use the embedded
interpreter?

I don’t need this, but it would provide a way to interface with
Avogadro from other languages, e.g. Java.

Marcus


Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss