-
Beta Was this translation helpful? Give feedback.
Answered by
davep
Jan 19, 2023
Replies: 1 comment 2 replies
-
I wonder if, perhaps, it would make more sense to use the link styles? From what I can see you're adding your own component styling that's fighting with the builtin link styling. I sense that this might be closer to what you'er trying to do? from textual.app import App, ComposeResult
from textual.widgets import Static
from rich.table import Table
from rich.text import Text
class Grid(Static):
DEFAULT_CSS = """
Grid {
link-hover-color: red;
link-hover-background: black;
link-style: none;
}
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._table_text = None
def make_table(self):
table = Table(show_lines=False)
table.add_column("Col1", width=6, justify="center")
table.add_column("Col2", width=20, justify="center")
for key in range(5):
key_text = Text.assemble(
f"[{key}]", meta={"@click": f"some_action('{key}')", "key": key},
)
table.add_row(key_text, f"This is row {key}")
return table
def render(self):
if self._table_text is None:
self._table_text = self.make_table()
return self._table_text
class GridExample(App):
def compose(self) -> ComposeResult:
yield Grid()
if __name__ == "__main__":
app = GridExample()
app.run() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
jspv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wonder if, perhaps, it would make more sense to use the link styles? From what I can see you're adding your own component styling that's fighting with the builtin link styling. I sense that this might be closer to what you'er trying to do?