From aef131298b534bfcc6ba66ed395aaf04d46c6de4 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Sun, 11 Jun 2023 22:50:01 +0200 Subject: [PATCH] Create simple GUI --- .gitignore | 74 +++++++++++++++++++++++++++ form.ui | 119 ++++++++++++++++++++++++++++++++++++++++++++ mainwindow.py | 33 ++++++++++++ openfm-qt.pyproject | 3 ++ 4 files changed, 229 insertions(+) create mode 100644 .gitignore create mode 100644 form.ui create mode 100644 mainwindow.py create mode 100644 openfm-qt.pyproject diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a0b530 --- /dev/null +++ b/.gitignore @@ -0,0 +1,74 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/form.ui b/form.ui new file mode 100644 index 0000000..55fd116 --- /dev/null +++ b/form.ui @@ -0,0 +1,119 @@ + + + MainWindow + + + + 0 + 0 + 350 + 500 + + + + + 350 + 500 + + + + + 350 + 500 + + + + + 350 + 500 + + + + Open FM + + + + + + 9 + 9 + 331 + 461 + + + + + + + + + + + + Qt::Horizontal + + + + + + + 00:00 + + + + + + + + + + + ... + + + + + + + 0 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + 70 + + + Qt::Horizontal + + + + + + + + + + + + 0 + 0 + 350 + 22 + + + + + + + diff --git a/mainwindow.py b/mainwindow.py new file mode 100644 index 0000000..27fa7a7 --- /dev/null +++ b/mainwindow.py @@ -0,0 +1,33 @@ +# This Python file uses the following encoding: utf-8 +import sys + +from PySide6.QtWidgets import QApplication, QMainWindow + +# Important: +# You need to run the following command to generate the ui_form.py file +# pyside6-uic form.ui -o ui_form.py, or +# pyside2-uic form.ui -o ui_form.py +from ui_form import Ui_MainWindow +import json +import requests + + +class MainWindow(QMainWindow): + def __init__(self, parent=None): + super().__init__(parent) + self.ui = Ui_MainWindow() + self.ui.setupUi(self) + self.getStations() + + def getStations(self): + resp = requests.get("https://open.fm/radio/api/v2/ofm/stations_slug.json") + json_ = json.loads(resp.text) + for el in json_["groups"]: + self.ui.listWidget.addItem(el["name"]) + + +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 new file mode 100644 index 0000000..1d1f041 --- /dev/null +++ b/openfm-qt.pyproject @@ -0,0 +1,3 @@ +{ + "files": ["mainwindow.py", "form.ui"] +}