mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
accidental check in
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Footer
|
||||
|
||||
|
||||
class MyWidget(Widget):
|
||||
def __init__(self):
|
||||
self.button = Button()
|
||||
super().__init__()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield self.button
|
||||
|
||||
|
||||
class MyApp(App):
|
||||
|
||||
BINDINGS = [("s", "show_button", "Show Button")]
|
||||
|
||||
def __init__(self):
|
||||
self.my_widget = None
|
||||
super().__init__()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Footer()
|
||||
|
||||
async def action_show_button(self) -> None:
|
||||
if self.my_widget is None:
|
||||
self.my_widget = MyWidget()
|
||||
else:
|
||||
await self.my_widget.remove()
|
||||
await self.mount(self.my_widget)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = MyApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user