-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99af16d
commit fc24db1
Showing
7 changed files
with
401 additions
and
0 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,34 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.widget import Widget | ||
from textual.widgets import Label | ||
|
||
|
||
class MyWidget(Widget): | ||
DEFAULT_CSS = """ | ||
MyWidget { | ||
height: auto; | ||
border: magenta; | ||
} | ||
Label { | ||
border: solid green; | ||
} | ||
""" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Label("foo") | ||
yield Label("bar") | ||
|
||
def on_mount(self) -> None: | ||
self.log(self.app.stylesheet.css) | ||
|
||
|
||
class MyApp(App): | ||
def compose(self) -> ComposeResult: | ||
yield MyWidget() | ||
yield MyWidget() | ||
yield Label("I should not be styled") | ||
|
||
|
||
if __name__ == "__main__": | ||
app = MyApp() | ||
app.run() |
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,35 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.widget import Widget | ||
from textual.widgets import Label | ||
|
||
|
||
class MyWidget(Widget): | ||
SCOPED_CSS = False | ||
DEFAULT_CSS = """ | ||
MyWidget { | ||
height: auto; | ||
border: magenta; | ||
} | ||
Label { | ||
border: solid green; | ||
} | ||
""" | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Label("foo") | ||
yield Label("bar") | ||
|
||
def on_mount(self) -> None: | ||
self.log(self.app.stylesheet.css) | ||
|
||
|
||
class MyApp(App): | ||
def compose(self) -> ComposeResult: | ||
yield MyWidget() | ||
yield MyWidget() | ||
yield Label("This will be styled") | ||
|
||
|
||
if __name__ == "__main__": | ||
app = MyApp() | ||
app.run() |
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