mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-22 22:31:43 +03:00
Avoid global statement for ID counter
This commit is contained in:
parent
ea0d90952a
commit
179cceed57
@ -51,7 +51,6 @@ class WindowTitleBar(Container):
|
||||
yield restore_button
|
||||
yield Button(self.CLOSE_ICON, classes="window_close")
|
||||
|
||||
id_counter = 0
|
||||
class Window(Container):
|
||||
"""A draggable window widget."""
|
||||
|
||||
@ -77,6 +76,8 @@ class Window(Container):
|
||||
("left,up", "focus_previous_button", "Focus Previous Button"),
|
||||
]
|
||||
|
||||
id_counter: ClassVar[int] = 0
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*children: Widget,
|
||||
@ -98,9 +99,8 @@ class Window(Container):
|
||||
self.last_focused_descendant: Widget | None = None
|
||||
if not self.id:
|
||||
# ID is needed for focus cycling
|
||||
global id_counter
|
||||
self.id = f"window_auto_id_{id_counter}"
|
||||
id_counter += 1
|
||||
self.id = f"window_auto_id_{Window.id_counter}"
|
||||
Window.id_counter += 1
|
||||
|
||||
def action_focus_next(self) -> None:
|
||||
"""Override action to focus the next widget only within the window."""
|
||||
|
Loading…
Reference in New Issue
Block a user