Is it possible to create a graphical interface with PyQt5 and Avogadro?

I’m trying with my code "import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog
from avogadro import *

class AvogadroWindow(QMainWindow):
def init(self):
self.setWindowTitle(“Avogadro Platform”)

    # Crear instancia de Avogadro
    self.avogadro = Avogadro()

    # Configurar herramientas y funciones

    # Agregar widget de Avogadro a la ventana principal

    # Configurar acciones de menú
    open_action = self.avogadro.action("file/open")

    save_action = self.avogadro.action("file/save")

def open_file(self):
    file_name, _ = QFileDialog.getOpenFileName(self, "Open File", "", "Molecular Files (*.mol *.mol2 *.sdf *.xyz)")
    if file_name:

def save_file(self):
    file_name, _ = QFileDialog.getSaveFileName(self, "Save File", "", "Molecular Files (*.mol *.mol2 *.sdf *.xyz)")
    if file_name:

if name == “main”:
app = QApplication(sys.argv)
window = AvogadroWindow()

" but when I install Avogadro’s plugins, I have issues with Qt. the following error "qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
" I thought uninstalling Qt and reinstalling it would fix it, but it didn’t. Any suggestions or ideas?

The avogadro module currently is designed around non-GUI tasks (e.g, Jupyter)

I’d be very interested to work through more involved GUI plugins / scripts.

Let’s start at the beginning - what do you want the code to accomplish?

1 Like

I want to create a small interface with certain options of Avogadro, such as drawing, rotation, open file, and save.

1 Like

At the moment, it would take some work. We’d need to add Python interfaces (PyQt or Shiboken) for the GUI components of avogadrolibs

If this is something that interests you, I’d be happy to work with you (and others) on this … but it’ll take a while.

A little while ago I actually seriously considered trying to port avogadroapp to PySide6, with the idea that it might make the user interface easier to maintain, make it easier for others to get involved and change aesthetic/organizational things, and help resolve some of the issues relating to Python for the plugins.

I have written an app in PySide before so I am happy to help out if that (or similar) is something that others decided is worth doing.

My impression when I was thinking about how it could be done, and the reason I gave up the idea, is that an awful lot of implementation details of the GUI are to be found in avogadrolibs, or many aspects of the internal behaviour require specifically the particular graphical implementation of Avogadro, and app and libs are thus quite interdependent. What was the original idea behind the app/libs split – a separation of concerns between the interface implementation specific to Avogadro and the internals that might want to be reused in a non-graphical environment?

In which case it seemed to me that large parts of qtgui and qtplugins would belong better in avogadroapp. But such C++ refactoring is out of my ability.