Add second listWidget to display stations

This commit is contained in:
Wiktor Zykubek 2023-06-12 20:34:50 +02:00
parent aef131298b
commit f57e1afe76
No known key found for this signature in database
GPG Key ID: 0DAA9DC01449FCA2
2 changed files with 11 additions and 4 deletions

View File

@ -43,7 +43,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="groupslistWidget"/>
</item>
<item>
<widget class="QListWidget" name="stationslistWidget"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">

View File

@ -17,13 +17,13 @@ class MainWindow(QMainWindow):
super().__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.getStations()
self.getGroups()
def getStations(self):
def getGroups(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"])
self.ui.groupslistWidget.addItem(el["name"])
if __name__ == "__main__":