Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dask_ctl/tui/tui.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,20 @@ Screen {
#prompt {
column-span: 4;
}

Splash {
layout: vertical;
align: center middle;
}

Splash>Logo {
height: 7;
content-align-horizontal: center;
}

Splash>SplashInfo {
margin: 2 0;
height: 6;
content-align-horizontal: center;
text-align: center;
}
18 changes: 18 additions & 0 deletions dask_ctl/tui/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from textual import events
from textual.binding import Binding
from textual._callback import invoke, count_parameters
from textual.screen import Screen

from ..lifecycle import get_cluster

Expand All @@ -14,9 +15,22 @@
CommandReference,
ClusterTable,
CommandPrompt,
SplashInfo,
)


class Splash(Screen):
BINDINGS = [("escape", "app.pop_screen", "Pop screen")]

def compose(self) -> ComposeResult:
yield Logo()
yield SplashInfo()

def on_mount(self) -> None:
self.set_interval(0.25, self.query_one(Logo).rotate_colors)
self.set_timer(1, self.app.pop_screen)


class DaskCtlTUI(App):
CSS_PATH = "tui.css"
COMMANDS = [
Expand All @@ -25,6 +39,9 @@ class DaskCtlTUI(App):
Binding("scale", "scale()", "Scale cluster"),
Binding("close", "close()", "Close cluster"),
]
SCREENS = {
"splash": Splash(),
}

command_prompt = CommandPrompt(id="prompt", classes="box")
cluster_table = ClusterTable(id="clusters", classes="box")
Expand All @@ -48,6 +65,7 @@ def on_mount(self) -> None:
# When the app starts, we force focus to the cluster table and then focus
# won't be lost again.
self.query_one(ClusterTable).focus()
self.push_screen("splash")

def on_focus(self) -> None:
self.log("Focus changed")
Expand Down
1 change: 1 addition & 0 deletions dask_ctl/tui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from .nbytes import NBytes
from .processing import Processing
from .taskstream import TaskStream
from .splash import SplashInfo
5 changes: 4 additions & 1 deletion dask_ctl/tui/widgets/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ def render(self) -> Text:
text.append(char, style=self.color_key.get(char, None))
return text

def on_click(self) -> None:
def rotate_colors(self) -> None:
values_deque = deque(self.color_key.values())
values_deque.rotate(-1)
self.color_key = dict(zip(self.color_key.keys(), values_deque))

def on_click(self) -> None:
self.rotate_colors()


# Demo widget
class Demo(App):
Expand Down
28 changes: 28 additions & 0 deletions dask_ctl/tui/widgets/splash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from rich.text import Text
from textual.app import App
from textual.widget import Widget

from ... import __version__


class SplashInfo(Widget):
CSS = """
text-align: center;
height: 2;
"""

def render(self) -> Text:
outs = []
outs.append(("dask-ctl\n", "bold blue"))
outs.append((__version__, "bold orange3"))
return Text.assemble(*outs)


# Demo widget
class Demo(App):
def compose(self):
yield SplashInfo()


if __name__ == "__main__":
Demo.run(title="SplashInfo")