Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm confused, after page. update(), page==None? #2603

Closed
laowus opened this issue Feb 11, 2024 · 15 comments
Closed

I'm confused, after page. update(), page==None? #2603

laowus opened this issue Feb 11, 2024 · 15 comments

Comments

@laowus
Copy link

laowus commented Feb 11, 2024

`
def init(self):
self.page.views.clear()
self.page.views.append(
View(
"/",
[self.appbar, self.layout],
padding=padding.all(0)
)
)
print('self.page.views', self.page.views)
self.page.update()
print(self.page.views)

`

@laowus
Copy link
Author

laowus commented Feb 11, 2024

error

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

For a class, the constructor function should be __init__ not just init. Try this and check if this solves the issue

@laowus
Copy link
Author

laowus commented Feb 11, 2024

For a class, the constructor function should be __init__ not just init. Try this and check if this solves the issue

no ,init is a class ‘s function,not __init__’ I just wrote this name as init

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

import flet as ft


def main(page: ft.Page):
    page.views.clear()
    page.views.append(ft.View("/", padding=ft.padding.all(0)))
    print("page.views - before update", page.views)
    page.update()
    print(f"page.views - after update: {page.views}")


ft.app(main)

gives

page.views - before update [View(route='/')]
page.views - after update: [View(route='/', padding='{"l":0,"t":0,"r":0,"b":0}')]

This code is working properly, I can't reproduce the error.

@laowus
Copy link
Author

laowus commented Feb 11, 2024

import flet as ft


def main(page: ft.Page):
    page.views.clear()
    page.views.append(ft.View("/", padding=ft.padding.all(0)))
    print("page.views", page.views)
    page.update()
    print(f"page.views: {page.views}")


ft.app(main)

gives

page.views [View(route='/')]
page.views: [View(route='/', padding='{"l":0,"t":0,"r":0,"b":0}')]

This code is working properly, I can't reproduce the error.

thank you! I don't know where the problem lies

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

Can you create a repo with minimal repro code? Try doing self.page.update() before first print statement. This issue shouldn't occur.

@laowus
Copy link
Author

laowus commented Feb 11, 2024

https://github.com/EmmetZ/ncm-downloader
I git this code,Maybe you can download and run it to see if it works

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

In your code, change every self.page to self.page_ in the code. This is the solution

@laowus
Copy link
Author

laowus commented Feb 11, 2024

In your code, change every self.page to self.page_ in the code. This is the solution

What is the difference? self.page and self.page_ I see many official examples using self. page

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

In your code, change every self.page to self.page_ in the code. This is the solution

What is the difference? self.page and self.page_ I see many official examples using self. page

Where?? Can you please provide me a link?

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

I think this is what some controls do set their page attribute themeselves. Maybe this is the reason. @FeodorFitsner

@laowus
Copy link
Author

laowus commented Feb 11, 2024

I think this is what some controls do set their page attribute themeselves. Maybe this is the reason. @FeodorFitsner

maybe, self.page reset the original

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

maybe, self.page reset the original

maybe

@laowus
Copy link
Author

laowus commented Feb 11, 2024

maybe, self.page reset the original

maybe

The problem is not with the self.page ,

flet-dev/examples#104

i read link then resolve it.

thank you very much!

@taaaf11
Copy link
Contributor

taaaf11 commented Feb 11, 2024

thank you very much!

No problem. Now, close the issue

@laowus laowus closed this as completed Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants