Clicking outside of a popup window #101
Answered
by
linkfrg
seve-andre
asked this question in
Q&A
-
I know that you can close a |
Beta Was this translation helpful? Give feedback.
Answered by
linkfrg
Jan 6, 2025
Replies: 1 comment 3 replies
-
Solution №1
For example: Widget.Window(
anchor=["top", "right", "bottom", "left"],
namespace="my-window",
child=Widget.Box(
child=[
Widget.Button(
vexpand=True,
hexpand=True,
css_classes=["unset"],
on_click=lambda x: app.close_window("my-window"),
),
ACTUAL_CONTENT,
],
),
) This will put the actual content to the right, and if you click on the empty space on the left, the window will close In other layouts the code will be different, but the principle is the same Solution №2It might be easier & better for most cases
For example: Widget.Window(
namespace="my-window",
anchor=["left", "right", "top", "bottom"],
child=Widget.Overlay(
child=Widget.Button(
vexpand=True,
hexpand=True,
can_focus=False,
on_click=lambda x: app.close_window("my-window"),
),
overlays=[ACTUAL_CONTENT],
),
) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
linkfrg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution №1
anchor
to["top", "right", "bottom", "left"]
Widget.Box
as a child of the windowWidget.Button
s in the free space, seton_click=lambda x: app.close_window("WINDOW_NAME")
or something like this. Also setvexpand=True
andhexpand=True
.valign
andhalign
For example: