trying to use tabs and stuff, maybe will try screens

This commit is contained in:
JISAUAY committed 2025-01-22 15:18:56 -06:00
1 parent 51c0e43add
commit f20d89af5b
2 files changed
+84 -117

No files matched your search

+83 -46
View File
@@ -17,7 +17,7 @@ import SubSonic
from textual import on, events
from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, OptionList, DataTable
from textual.widgets import Footer, Header, OptionList, DataTable, Tabs, Tab, TabbedContent, TabPane
from textual.widgets.option_list import Option
u = 'pseudo'
@@ -35,9 +35,9 @@ class Menus(Enum):
class TextualSubpyPlayer(App):
BINDINGS = [
('backspace', 'menu_back()', 'Go back a menu')
]
# BINDINGS = [
# ('backspace', 'menu_back()', 'Go back a menu')
# ]
artists: list[SubSonic.Artist]
selectedArtist: SubSonic.Artist
@@ -47,35 +47,72 @@ class TextualSubpyPlayer(App):
currentMenu: Menus
lastMenu: Menus
last_menu_type: any
def compose(self) -> ComposeResult:
self.currentMenu = Menus.MAIN
self.lastMenu = Menus.MAIN
yield OptionList(
Option("Browse Artists", id="BrowseArtists"),
Option("Browse Albums"),
Option("Browse Songs"),
Option("Browse Playlists"),
id=Menus.MAIN.value
)
self.last_menu_type = None
async def action_menu_back(self) -> None:
logging.debug('Menu Back Called')
match self.lastMenu:
case Menus.MAIN:
logging.debug("Moving back to the main menu")
await self.main_menu()
case Menus.ARTISTALBUMS:
logging.debug("Moving back to Artist Albums")
await self.selectArtistAlbumView(self.selectedArtist.id)
case Menus.ARTISTS:
logging.debug("Moving backt to artists")
await self.selectArtistsView()
case _:
logging.debug(f"Last Menu unknown, {self.lastMenu}")
with TabbedContent(initial="Artists"):
with TabPane("Artists", id="Artists"):
yield OptionList(id="Artists")
yield Footer()
# yield OptionList(
# Option("Browse Artists", id="BrowseArtists"),
# Option("Browse Albums"),
# Option("Browse Songs"),
# Option("Browse Playlists"),
# id=Menus.MAIN.value
# )
# def on_mount(self) -> None:
# self.query_one(Tabs).allow_focus(False)
# async def action_menu_back(self) -> None:
# logging.debug('Menu Back Called')
# match self.lastMenu:
# case Menus.MAIN:
# logging.debug("Moving back to the main menu")
# await self.main_menu()
# case Menus.ARTISTALBUMS:
# logging.debug("Moving back to Artist Albums")
# await self.selectArtistAlbumView(self.selectedArtist.id)
# case Menus.ARTISTS:
# logging.debug("Moving backt to artists")
# await self.selectArtistsView()
# case _:
# logging.debug(f"Last Menu unknown, {self.lastMenu}")
def on_key(self, event: events.Key) -> None:
logging.debug(f'Key Pressed {event.name}')
# def on_tabs_tab_activated(self, event: Tabs.TabActivated) -> None:
# logging.debug(f'{event.tab.id} selected')
@on(Tabs.TabActivated)
async def artists_tab(self, event: Tabs.TabActivated) -> None:
if self.last_menu_type:
await self.query_one(self.last_menu_type).remove()
self.last_menu_type = None
logging.debug(f'{event.tab.name} tab selected')
id = event.tab.id
match id:
case "Artists":
artistList: OptionList = await self._getArtistMenu()
await self.mount(artistList)
for artist in self.artists:
artistList.add_option(Option(artist.name, artist.id))
self.last_menu_type = OptionList
def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
@@ -90,34 +127,34 @@ class TextualSubpyPlayer(App):
return OptionList(id=Menus.ARTISTS.value)
@on(OptionList.OptionSelected, f'#{Menus.MAIN.value}')
async def selectMainMenu(self, event: OptionList.OptionSelected) -> None:
match event.option_id:
case "BrowseArtists":
logging.debug('View Artists Selected')
await self.selectArtistsView()
# @on(OptionList.OptionSelected, f'#{Menus.MAIN.value}')
# async def selectMainMenu(self, event: OptionList.OptionSelected) -> None:
# match event.option_id:
# case "BrowseArtists":
# logging.debug('View Artists Selected')
# await self.selectArtistsView()
@on(OptionList.OptionSelected, f"#{Menus.ARTISTS.value}")
async def artistSelected(self, event: OptionList.OptionSelected) -> None:
logging.debug(f'Artist {event.option.prompt} Selected')
self.lastMenu = Menus.ARTISTS
# @on(OptionList.OptionSelected, f"#{Menus.ARTISTS.value}")
# async def artistSelected(self, event: OptionList.OptionSelected) -> None:
# logging.debug(f'Artist {event.option.prompt} Selected')
# self.lastMenu = Menus.ARTISTS
for artist in self.artists:
if event.option_id == artist.id:
self.selectedArtist = artist
# for artist in self.artists:
# if event.option_id == artist.id:
# self.selectedArtist = artist
await self.selectArtistAlbumView(self.selectedArtist.id)
# await self.selectArtistAlbumView(self.selectedArtist.id)
@on(DataTable.RowSelected, "#ArtistAlbums")
async def ArtistAlbumSelected(self, event: DataTable.RowSelected) -> None:
self.lastMenu = Menus.ARTISTALBUMS
row_key = event.row_key
row = event.data_table.get_row(row_key)
logging.debug(f'Album {row[0]} Selected')
# @on(DataTable.RowSelected, "#ArtistAlbums")
# async def ArtistAlbumSelected(self, event: DataTable.RowSelected) -> None:
# self.lastMenu = Menus.ARTISTALBUMS
# row_key = event.row_key
# row = event.data_table.get_row(row_key)
# logging.debug(f'Album {row[0]} Selected')
await self.selectAlbumSongsView(row_key.value)
# await self.selectAlbumSongsView(row_key.value)
async def selectAlbumSongsView(self, album_id: str) -> None:
logging.debug("Setting up album songs DataTable")
+1 -71
View File
@@ -1,71 +1 @@
[2025-01-21 09:35:07,989] DEBUG in selector_events: Using selector: EpollSelector
[2025-01-21 09:35:08,547] DEBUG in textual-test: Key Pressed enter
[2025-01-21 09:35:08,548] DEBUG in textual-test: View Artists Selected
[2025-01-21 09:35:08,550] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:08,732] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=a97d230d3166610b05dd3a30bb673f32&s=AOT38T3U&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-21 09:35:09,360] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:09,601] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:09,775] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:10,338] DEBUG in textual-test: Key Pressed backspace
[2025-01-21 09:35:10,339] DEBUG in textual-test: Menu Back Called
[2025-01-21 09:35:10,339] DEBUG in textual-test: Moving back to the main menu
[2025-01-21 09:35:11,388] DEBUG in textual-test: Key Pressed enter
[2025-01-21 09:35:11,389] DEBUG in textual-test: View Artists Selected
[2025-01-21 09:35:11,399] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:11,572] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=a28d65a7ebd5359e9c2ec2b8fa30478b&s=ZWOC8KFV&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-21 09:35:12,120] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,620] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,656] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,680] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,711] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,742] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,772] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,803] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,834] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,864] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,895] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,926] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:12,956] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:13,209] DEBUG in textual-test: Key Pressed backspace
[2025-01-21 09:35:13,210] DEBUG in textual-test: Menu Back Called
[2025-01-21 09:35:13,210] DEBUG in textual-test: Moving back to the main menu
[2025-01-21 09:35:13,779] DEBUG in textual-test: Key Pressed enter
[2025-01-21 09:35:13,780] DEBUG in textual-test: View Artists Selected
[2025-01-21 09:35:13,781] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:13,968] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=2931ef5d69cd6d656d7f9c20b2968f1b&s=RYEHVX5N&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-21 09:35:14,284] DEBUG in textual-test: Key Pressed backspace
[2025-01-21 09:35:14,284] DEBUG in textual-test: Menu Back Called
[2025-01-21 09:35:14,284] DEBUG in textual-test: Moving back to the main menu
[2025-01-21 09:35:15,494] DEBUG in textual-test: Key Pressed enter
[2025-01-21 09:35:15,495] DEBUG in textual-test: View Artists Selected
[2025-01-21 09:35:15,496] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:15,678] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=0463fa3d1d9c1537d395eb7fc64a8b24&s=IMVSYTQU&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-21 09:35:15,792] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,291] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,322] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,353] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,383] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,413] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,444] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,474] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,505] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,542] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,565] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,596] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,626] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:16,911] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:17,093] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:17,252] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:17,663] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:17,950] DEBUG in textual-test: Key Pressed enter
[2025-01-21 09:35:17,951] DEBUG in textual-test: Artist Daft Punk Selected
[2025-01-21 09:35:17,951] DEBUG in textual-test: Setting up album DataTable
[2025-01-21 09:35:17,957] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:18,134] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getMusicDirectory?u=pseudo&t=306fc4f8690b4c90a4502e59d3e985f1&s=GKUV4BSR&v=1.16.1&c=testing&id=39bfe262546e5598284a148b1eb59d4a HTTP/1.1" 200 816
[2025-01-21 09:35:19,063] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:19,223] DEBUG in textual-test: Key Pressed down
[2025-01-21 09:35:19,805] DEBUG in textual-test: Key Pressed backspace
[2025-01-21 09:35:19,805] DEBUG in textual-test: Menu Back Called
[2025-01-21 09:35:19,805] DEBUG in textual-test: Moving backt to artists
[2025-01-21 09:35:19,807] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-21 09:35:19,989] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=151c6db8f37e0b900d3ca7c6384de338&s=SPHUFUL3&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-22 14:48:12,080] DEBUG in proactor_events: Using proactor: IocpProactor