-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmachine_id.py
More file actions
29 lines (25 loc) · 962 Bytes
/
Copy pathmachine_id.py
File metadata and controls
29 lines (25 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import copykitten
from copykitten import CopykittenError
from textual import on
from textual.app import ComposeResult
from textual.containers import Grid
from textual.screen import ModalScreen
from textual.widgets import Button, Label
from subscription import get_device_id
class MachineId(ModalScreen):
def compose(self) -> ComposeResult:
with Grid():
yield Label("Your device ID", id="id-label")
yield Label(get_device_id(), id="id-value")
yield Button(
"Close", variant="error", id="close-button", action="app.pop_screen"
)
yield Button("Copy", variant="primary", id="copy-button")
@on(Button.Pressed, "#copy-button")
def copy(self):
try:
copykitten.copy(get_device_id())
except CopykittenError:
self.app.notify("Failed to copy ID", severity="error")
else:
self.app.notify("ID copied to clipboard")