From a841bb4293aba7fff5fbf100e45aadf2f032fea9 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Thu, 15 Jun 2023 13:14:40 +0200 Subject: [PATCH] Use package structure --- main.py | 11 +++++++++++ openfm-qt.pyproject | 2 +- openfm_qt/__init__.py | 6 ++++++ mainwindow.py => openfm_qt/mainwindow.py | 14 ++------------ 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 main.py create mode 100644 openfm_qt/__init__.py rename mainwindow.py => openfm_qt/mainwindow.py (93%) diff --git a/main.py b/main.py new file mode 100644 index 0000000..1671a1b --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +# This Python file uses the following encoding: utf-8 + +from PySide6.QtWidgets import QApplication +from openfm_qt import MainWindow +import sys + +if __name__ == "__main__": + app = QApplication(sys.argv) + widget = MainWindow() + widget.show() + sys.exit(app.exec()) diff --git a/openfm-qt.pyproject b/openfm-qt.pyproject index a600b7a..c30adca 100644 --- a/openfm-qt.pyproject +++ b/openfm-qt.pyproject @@ -1,3 +1,3 @@ { - "files": ["mainwindow.py","form.ui"] + "files": ["form.ui","openfm_qt/mainwindow.py","openfm_qt/__init__.py","main.py"] } diff --git a/openfm_qt/__init__.py b/openfm_qt/__init__.py new file mode 100644 index 0000000..a39f6ab --- /dev/null +++ b/openfm_qt/__init__.py @@ -0,0 +1,6 @@ +# This Python file uses the following encoding: utf-8 + +API_URL = "https://open.fm/radio/api/v2/ofm/stations_slug.json" +DEFAULT_VOLUME = 70 + +from .mainwindow import MainWindow diff --git a/mainwindow.py b/openfm_qt/mainwindow.py similarity index 93% rename from mainwindow.py rename to openfm_qt/mainwindow.py index 02ab8a0..1ed0051 100644 --- a/mainwindow.py +++ b/openfm_qt/mainwindow.py @@ -1,8 +1,7 @@ # This Python file uses the following encoding: utf-8 -import sys from PySide6.QtCore import QUrl -from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QStyle +from PySide6.QtWidgets import QMainWindow, QMessageBox, QStyle from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput # Important: @@ -12,9 +11,7 @@ from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput from ui_form import Ui_MainWindow import json import requests - -API_URL = "https://open.fm/radio/api/v2/ofm/stations_slug.json" -DEFAULT_VOLUME = 70 +from . import API_URL, DEFAULT_VOLUME class MainWindow(QMainWindow): @@ -128,10 +125,3 @@ class MainWindow(QMainWindow): pass self.ui.playbackToolButton.setIcon(icon) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - widget = MainWindow() - widget.show() - sys.exit(app.exec())