Author Topic: Possible to embed OVITO in PyQt GUI?  (Read 107 times)

anne101

  • Newbie
  • *
  • Posts: 2
Possible to embed OVITO in PyQt GUI?
« on: August 01, 2019, 04:44:33 PM »
Hello,

I currently have an existing GUI programmed using PyQt/PyQwt. I am interested in embedding an OVITO viewport into the GUI as a widget. The only interaction with OVITO that I need is to update the input file and view periodically.

Is this possible, and if so, what steps should I take?

Thank you,
Anne

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Possible to embed OVITO in PyQt GUI?
« Reply #1 on: August 02, 2019, 01:04:53 PM »
Hi Anne,

Currently, the Python programming interface doesn't cover the GUI-related functions and classes of OVITO. Even though it is possible to create a Viewport non-visual object from Python, it is not yet possible to create or access a corresponding widget for the viewport that could be embedded in a windowing user interface.

Let me check how much effort it would be to extend the Python bindings of OVITO in such a way that a PyQt widget could be created from a Viewport object. Your requirements seem to be quite simple.

Just a question: Are you running you PyQt GUI application through a standard Python interpreter? Is it possible for you to use the ovitos interpreter instead?

-Alex

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: Possible to embed OVITO in PyQt GUI?
« Reply #2 on: August 05, 2019, 09:19:53 AM »
Hi Anne,

I've now extended Python programming interface of OVITO by adding the new Viewport.create_widget() method (still undocumented). It allows creating a QWidget from an existing Viewport object, which can be embedded into a PyQt5 user interface. You can find a example script demonstrating this here:

https://gitlab.com/stuko/ovito/blob/master/tests/scripts/viewport_widget.py

Note however that this will only work when running your PyQt5 application through a standard Python interpreter. Please see this section of the user manual how to make the Ovito modules available in a standard Python interpreter. It typically requires building them from source.

-Alex

anne101

  • Newbie
  • *
  • Posts: 2
Re: Possible to embed OVITO in PyQt GUI?
« Reply #3 on: September 04, 2019, 04:08:19 AM »
Hi Alex,

Thank you so much for your response; sorry for my delayed response, I was having problems getting the ovitos interpreter working and then got off track for a while.

Again really appreciate the response and will look into the script you sent.

Anne