-
Two quick questions as I finally finish my textual app :D
.switch--slider {
color: rgb(168,253,87);
}
|
Beta Was this translation helpful? Give feedback.
Answered by
davep
Sep 20, 2023
Replies: 2 comments 4 replies
-
For question 1, something like this should do the trick: from textual.app import App, ComposeResult
from textual.widgets import Switch
class SwitchSliderColourApp(App[None]):
CSS = """
Switch > .switch--slider {
color: red;
}
Switch.-on > .switch--slider {
color: yellow;
}
"""
def compose(self) -> ComposeResult:
yield Switch()
if __name__ == "__main__":
SwitchSliderColourApp().run() |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jessebot
-
For question 2, the tabs can include Rich markup: from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label
from itertools import cycle
class TabColourApp(App[None]):
def compose(self) -> ComposeResult:
colours = cycle(["red", "green", "blue"])
with TabbedContent():
for n in range(10):
colour = next(colours)
with TabPane(f"[{colour}]Tab {n}[/]", id=f"tab-{n}"):
yield Label(f"This is tab {n}")
if __name__ == "__main__":
TabColourApp().run() |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For question 1, something like this should do the trick: