Skip to content

Commit

Permalink
ListApp info panel 3 equal columns layout
Browse files Browse the repository at this point in the history
and cleanup unused clutter.
  • Loading branch information
JOJ0 committed Nov 6, 2024
1 parent 143a2a5 commit 0d64e82
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 37 deletions.
35 changes: 22 additions & 13 deletions discodos/view/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
import asyncio
from tabulate import tabulate as tab
from textual.app import App
from textual.containers import Grid, Horizontal, Vertical
from textual.screen import Screen
from textual.widgets import (
Button,
DataTable,
Footer,
Header,
Label,
Static,
)

from textual.widgets import DataTable, Label, Footer
from textual.containers import Container, Grid, Horizontal, Vertical
#from textual.css import StyleSheet

from discodos.view import ViewCommon, ViewCommonCommandline
from discodos.model_collection import DiscogsMixin
Expand All @@ -38,6 +30,7 @@ def __init__(self):
]



class DiscodosListApp(App, DiscogsMixin):
"""Inline Textual app to view and edit dsc ls results."""
CSS_PATH = "tui_ls.tcss"
Expand All @@ -49,6 +42,7 @@ class DiscodosListApp(App, DiscogsMixin):
("e", "edit_release", "Edit release"),
("E", "edit_sale", "Edit sales listing"),
]

def __init__(self, rows, headers, discogs=None):
super().__init__()
super().discogs_connect(
Expand All @@ -66,7 +60,17 @@ def compose(self):
table.add_columns(*self.headers)
table.cursor_type = "cell"
table.zebra_stripes = True
self.details_panel = Label("Hit enter on a cell to view details here!")
# Create a 3-column container for the details panel with equal widths
self.left_column = Label("Left column data", expand=True)
self.middle_column = Label("Middle column", expand=True)
self.right_column = Label("Right column", expand=True)
# Use Horizontal to arrange the columns with equal flex (equal width)
self.details_panel = Horizontal(
self.left_column,
self.middle_column,
self.right_column,
classes="details-panel"
)
yield Horizontal(table, self.details_panel)
yield table
yield Footer()
Expand Down Expand Up @@ -99,7 +103,10 @@ def on_data_table_cell_selected(self, event):
if event.coordinate.column != 4 or event.value is None:
return
result = self.get_sales_listing_details(event.value)
self.details_panel.update(result)
# Load data into the left column
self.left_column.update(result)
self.middle_column.update("Middle column updated!") # Example update
self.right_column.update("Right column updated!") # Example update

def _load_ls_results(self):
table_widget = self.query_one(DataTable)
Expand All @@ -108,6 +115,8 @@ def _load_ls_results(self):
table_widget.add_row(*row_data, key=row_id)




class CollectionViewCommandline(
CollectionViewCommon, ViewCommonCommandline, ViewCommon
):
Expand Down
26 changes: 2 additions & 24 deletions discodos/view/tui_ls.tcss
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
QuestionDialog {
align: center middle;
}

#question-dialog {
grid-size: 2;
grid-gutter: 1 2;
grid-rows: 1fr 3;
padding: 0 1;
width: 60;
height: 11;
border: solid red;
background: $surface;
}

#question {
column-span: 2;
height: 1fr;
width: 1fr;
content-align: center middle;
}

Button {
.details-panel {
width: 100%;
}
}

0 comments on commit 0d64e82

Please sign in to comment.