From c83c545c43fe85d3053f216fca87288bccf2820a Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 20 Jul 2023 10:44:24 +0200 Subject: [PATCH] Act as an app. --- birdvisu/__main__.py | 4 ++++ poor_mans_visualisation.py => birdvisu/ui.py | 24 ++++++++++++-------- pyproject.toml | 3 +++ visu.py | 4 ++++ 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100755 birdvisu/__main__.py rename poor_mans_visualisation.py => birdvisu/ui.py (95%) mode change 100755 => 100644 create mode 100755 visu.py diff --git a/birdvisu/__main__.py b/birdvisu/__main__.py new file mode 100755 index 0000000..0397d55 --- /dev/null +++ b/birdvisu/__main__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + +from birdvisu.ui import main +main() diff --git a/poor_mans_visualisation.py b/birdvisu/ui.py old mode 100755 new mode 100644 similarity index 95% rename from poor_mans_visualisation.py rename to birdvisu/ui.py index eec131d..3d9c275 --- a/poor_mans_visualisation.py +++ b/birdvisu/ui.py @@ -1,4 +1,11 @@ -#!/usr/bin/env python3 +"""This module contains the UI. Most of interfacing Qt happens here, especially if not related to the Graphics view framework + +The MainWindow class acts as the coordinator for the whole project. Apart from +it, there is at least one dialog window used by the MainWindow. + +The function :func:main can be used as the entrypoint to the program, if run in +standalone mode. +""" from birdvisu.annotations import AnnotatedTopology, AnnotatorID from birdvisu.annotations.analysis import TopologyDifference, ShortestPathTree @@ -16,8 +23,6 @@ from PySide6.QtCore import Slot, QObject from random import randint import sys -app = QtWidgets.QApplication([]) - class BirdTopologyLoader(QtWidgets.QDialog): def __init__(self, *a, **kwa): super().__init__(*a, **kwa) @@ -140,7 +145,7 @@ class MainWindow(QtWidgets.QMainWindow): self.statusbar.showMessage('Hello!') self.create_menus() self.edgeWeightMode() - self.autoLoad() + #self.autoLoad() #Hack @Slot() @@ -331,8 +336,9 @@ class MainWindow(QtWidgets.QMainWindow): def create_edge(self, edge): return EdgeGraphicsItem(edge, self) - - -main_window = MainWindow() -main_window.show() -app.exec() + +def main(): + app = QtWidgets.QApplication([]) + main_window = MainWindow() + main_window.show() + app.exec() diff --git a/pyproject.toml b/pyproject.toml index 12b8607..1664ac1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,9 @@ dependencies = [ 'PySide6', ] +[project.gui-scripts] +visu = "birdvisu.ui:main" + [build-system] requires = ["flit_core >=3.2,<4"] build-backend = "flit_core.buildapi" diff --git a/visu.py b/visu.py new file mode 100755 index 0000000..0397d55 --- /dev/null +++ b/visu.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + +from birdvisu.ui import main +main()