[Question] Function window_center #2807
Answered
by
ingdesarr1
ingdesarr1
asked this question in
Q&A
-
QuestionGood morning. I'm trying to use the function window_center(), using the event on_window_event to detect when the window move to other position, but not working. I even use the function window_destroy, to probe if move the window works, but not working too. How can I do that? Thanks Code sampleimport flet as ft
def main(page:ft.Page):
def mover(e):
print(e.data)
if e.data == 'moved':
# print("hola")
page.window_destroy()
# page.update()
page.window_focused = True
page.window_resizable = False
page.window_movable = False
# page.window_maximized = True
page.window_maximizable = False
page.window_center()
page.theme_mode = "LIGHT"
page.on_window_event = mover
ft.app(target=main, assets_dir="assets") Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ingdesarr1
Mar 15, 2024
Replies: 1 comment 5 replies
-
very easy : def main(page: ft.Page):
x=page.window_top
y=page.window_left
def sss(e):
nonlocal x,y
if e.control.window_top!=x or e.control.window_left!=y:
print("Page moved")
x=e.control.window_top
y=e.control.window_left
page.on_window_event=sss |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found the error. there is a problem with this function:
page.window_movable = False
With this property, the page functions don't work, because I commented this line and all the functions work