etetoolkit / ete

Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
http://etetoolkit.org
GNU General Public License v3.0
782 stars 212 forks source link

QtGUI updates. Possible to use ete GUI from other application #566

Closed m-nikolaidis closed 3 years ago

m-nikolaidis commented 3 years ago

Did some minor changes in the QtGUI tree functions and added the ability to change the leaf name colors. Also made the ete QtGUI able to be called from other Qt Application without creating errors (described below). A more detailed description is below. Each change described has a reference point to each script in treeview folder

Treeview

Qt GUI changes

  1. Added the ability to ladderize a specific node (and it's children) both top to bottom and bottom to top
  2. Created better dialog to save the tree view (as PDF file)
  3. Added .newick and .nwk in the save newick dialog . Changed the QApplication widget to QMainWindow widget (explain below)

references:

  1. top to bottom: node_gui_actions.py: lines 154, 270 - 272 bottom to top: node_gui_actions.py: lines 155, 274 - 276
  2. qt4_gui.py: lines 386 - 394 & lines 401 - 409
  3. qt4_gui.py: lines 372, 374
  4. drawer.py: lines 67, 68, 95, 156, 157

    When embedding the tree.show() function inside another GUI application (as I am trying to do for a project of mine) the following error occurs. QCoreApplication::exec: The event loop is already running since an application is getting called by another application and this is fatal for the main loop.
    Exiting the first application will not close the second application, which will therefore consume system resources until manually killed. For this reason the QApplication widget can be changed with a QMainWindow widget, since the ete GUI uses only one primary window. As far as I have read the scripts there is no need for an event loop when displaying the window.
    f you think that this change is not good feel free to discuss.

Leaf name color attribute

  1. Created function to add leaf text color . Fixed code to not add default (black) text face as leaf label if one is already specified. The user may want to add a custom color on leaf labels

references:

  1. tree.py: lines 2590 - 2596
  2. qt4_render.py: lines 263 - 268
jhcepas commented 3 years ago

Thank you @Marios-Nikolaidis. We are heavily working on ete4, a refactored version of ete where we have added a new visualization module based on web/svg rendering. I guess we could still accept PRs anyways, but the idea is that the tree drawing engine and GUI based on GUI is getting unmaintained and deprecated in future versions.

Regarding the QApplication change, I understand from the Qt5 documentation that there is always a need to have one, and only one, QApplication instance. Maybe the change is ok for embedding purposes but, will the standalone GUI application work without it?

m-nikolaidis commented 3 years ago

Dear @jhcepas ,

I am glad to hear your extensive work on ete4. I will be gladly to commit there as well. I reviewed your comment and yes you are right. My method would not work on a standalone GUI. Therefore I made some other changes to the GUI functions by adding a child_app kwarg. This new approach works fine when called from script or when using the python interpreter for a standalone GUI. I will be closing this PR and creating a new one.

All the best