-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4818 from Textualize/enter-bubble
enter bubble
- Loading branch information
Showing
9 changed files
with
272 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
tests/snapshot_tests/__snapshots__/test_snapshots/test_enter_or_leave.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from textual import on | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import Label | ||
from textual.widget import Widget | ||
from textual import events | ||
|
||
|
||
class MyWidget(Widget): | ||
def compose(self) -> ComposeResult: | ||
yield Label("Foo", id="foo") | ||
yield Label("Bar") | ||
|
||
@on(events.Enter) | ||
@on(events.Leave) | ||
def on_enter_or_leave(self): | ||
self.set_class(self.is_mouse_over, "-over") | ||
|
||
|
||
class EnterApp(App): | ||
CSS = """ | ||
MyWidget { | ||
padding: 2 4; | ||
background: red; | ||
height: auto; | ||
width: auto; | ||
&.-over { | ||
background: green; | ||
} | ||
Label { | ||
background: rgba(20,20,200,0.5); | ||
} | ||
} | ||
""" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield MyWidget() | ||
|
||
|
||
if __name__ == "__main__": | ||
app = EnterApp() | ||
app.run() |
Oops, something went wrong.