-
Hello, I'm trying to use the Dialog example form the docs in css branch and I have an issue I think. Example code : `class LoginDialog(Screen):
When clicking on the cancel button it's raising this error :
It seems that childs arre not supported since the below code raise no error : `class LoginDialog(Screen):
Mickael |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It's a little tricky to follow what you're trying here, but I take it from the above that you're taking from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.screen import Screen
from textual.widgets import Static, Header, Footer, Button, Input
class QuitScreen(Screen):
def compose(self) -> ComposeResult:
yield Grid(
Static("Are you sure you want to quit?", id="question"),
Input(placeholder="Login"),
Input(placeholder="Password"),
Button("Quit", variant="error", id="quit"),
Button("Cancel", variant="primary", id="cancel"),
id="dialog",
)
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "quit":
self.app.exit()
else:
self.app.pop_screen()
class ModalApp(App):
CSS_PATH = "modal01.css"
BINDINGS = [("q", "request_quit", "Quit")]
def compose(self) -> ComposeResult:
yield Header()
yield Footer()
def action_request_quit(self) -> None:
self.push_screen(QuitScreen())
if __name__ == "__main__":
app = ModalApp()
app.run() I suspect whatever the cause of your problem is, it may be down to changes you've made to the wider code of the example that you've not included here? It might be a good idea to provide the smallest possible self-contained example of the code that displays the problem; perhaps create a gist that shows it if it's a wee bit too large to include here. |
Beta Was this translation helpful? Give feedback.
-
Please give b7 a try. We might have a fix.
…On Mon, Oct 17, 2022 at 2:57 PM mlafois ***@***.***> wrote:
Hello,
I'm still trying to debug my problem.
I made two files : main.py (copied from your reply) and modal01.css
(copied from the docs).
I have installed textual (0.2.0b6) without viertualenv.
When I click on the cancel button, I have the same kind of error :
"NoScreen: Input() has no screen"
Here under a dirty copy of the stack error, sorry I didn't manage to paste
it in a proper way.
/home/mlafois/.local/lib/python3.10/site-packages/textual/widget.py:1853
in set_focus │
│ │
│ 1850 │ │ ╭───────── locals ─────────╮ │
│ 1851 │ │ def set_focus(widget: Widget): │ scroll_visible = True │ │
│ 1852 │ │ │ """Callback to set the focus.""" │ self = Input() │ │
│ ❱ 1853 │ │ │ widget.screen.set_focus(self,
scroll_visible=scroll_visible) │ widget = Input() │ │
│ 1854 │ │ ╰──────────────────────────╯ │
│ 1855 │ │ self.app.call_later(set_focus, self) │
│ 1856 │
│ │
│ /home/mlafois/.local/lib/python3.10/site-packages/textual/dom.py:280 in
screen │
│ │
│ 277 │ │ while node and not isinstance(node, Screen): ╭─────────────────
locals ─────────────────╮ │
│ 278 │ │ │ node = node._parent │ node = None │ │
│ 279 │ │ if not isinstance(node, Screen): │ Screen = <class
'textual.screen.Screen'> │ │
│ ❱ 280 │ │ │ raise NoScreen(f"{self} has no screen") │ self = Input() │ │
│ 281 │ │ return node ╰──────────────────────────────────────────╯ │
│ 282 │ │
│ 283 │ @Property <https://github.com/Property>
Mickael
—
Reply to this email directly, view it on GitHub
<#908 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEHLAJWJWFGEWFJHPBHDX3WDVLKZANCNFSM6AAAAAARE7X56A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Will McGugan
https://www.willmcgugan.com <http://www.willmcgugan.com>
|
Beta Was this translation helpful? Give feedback.
It's a little tricky to follow what you're trying here, but I take it from the above that you're taking
modal01.py
and trying to modify it to create an example login dialog, complete with anInput
? I've takenmodal01.py
and modified the dialog in a similar way to how you're doing here and it has the intended result: