在Textual,我有一个应用程序,有3种模式.但是,我想根据用户输入切换屏幕内的模式.我怎么才能做到这一点呢? App.py:
class DemoApp(App[None]):
MODES = {
"profile": ProfileScreen,
"chat": ChatScreen,
"help": HelpScreen,
}
def on_mount(self) -> None:
"""On running"""
LOGGER.info("Starting")
self.switch_mode("chat")
class ChatScreen(Screen):
def compose(self) -> ComposeResult:
yield Button(label="Profile", variant="success", id="change_profile")
async def on_button_pressed(self) -> None:
await self.process()
async def process():
switch_mode("profile") # How do I do this?
我在谷歌上搜索了所有内容,并阅读了相关文档.但我还是找不到解决办法.