jrfonseca / xdot.py

Interactive viewer for graphs written in Graphviz's dot language.
GNU Lesser General Public License v3.0
862 stars 145 forks source link

wxWidgets and Qt support #9

Open jbohren opened 10 years ago

jbohren commented 10 years ago

@jrfonseca, we've been using Xdot for several years now with a wxWidgets-based fork and, more recently, a Qt-based fork. It'd be cool to unify them into a single library, and combine the common code.

Check them out here: https://github.com/jbohren/xdot/tree/indigo-devel/src/xdot

ZedThree commented 8 years ago

Since #35 has been merged, all the GUI-related code is solely in xdot.ui, which should make unifying all the forks easier. Probably even more common code could be pulled out, leaving elements.py and window.py as the only two files which depend on the exact GUI library, possibly even just window.py.

I've been trying to get my head around how to do this sensibly, and I can see two different ways of doing it:

  1. Separate submodules as distinct packages on pypi, with a common xdot-base package. You would install xdot-<gui?, which would bring in xdot-base.
  2. Different GUI libraries as backends which could be swapped at runtime, as in matplotlib.

The first way would almost certainly be easier, but managing separate packages for each GUI might be difficult. The second way seems maybe cleaner, but I'm not even sure where to begin on that.

Morwenn commented 6 years ago

I tried my hand at rebasing the Qt fork in the original question (with Python 3 and PyQt5) and the split is just short of being sufficient to abstract away the UI: in the Qt fork, Pen.dash has been updated to use the Qt attributes Qt.SolidLine and Qt.DashLine (and I added Qt.DotLine for dotted lines to complete the fork). However the assignment of a value to Pen.dash is done in the parser in handle_linestyle, making it depend on PyQt5.QtCore.Qt values in my case.

To avoid this problem, Parser.handle_linestyle should probably delegate to a Pen.handle_linestyle function so that the parser only has to forward the strings "solid", "dashed" and "dotted" to the Pen instance, and let the pen handle by itself how it inteprets those constants.

Jo-Con-El commented 5 years ago

@Morwenn, do you have your fork somewhere? It seems that you made all the work and you're just a pull request or two away from integrating it.

Morwenn commented 5 years ago

It's probably somewhere on my work computer. We didn't use the library in the end, but LGPL says that I should share the improvements anyway. I will try to find it again once I'm back from holidays.

If I'm not mistaken I had only kept the code up to the widget, and not up to the window level.