Replies: 22 comments 2 replies
-
The path to your image has to be a relative path to the |
Beta Was this translation helpful? Give feedback.
-
Hello, I get the same problem. When I run the app with ft.app(main), it works. However, when I run the app with ft.app(target=main, view=ft.AppView.WEB_BROWSER), nothing is displayed.” |
Beta Was this translation helpful? Give feedback.
-
@ndonkoHenri I have tried all path combinations and none are working for webview |
Beta Was this translation helpful? Give feedback.
-
As mentioned in my previous comment, remove "assets" from your |
Beta Was this translation helpful? Give feedback.
-
A similar issue, except that I'm testing my application on a mobile device, not on the web. Fonts and images aren't displaying after I updated the application from the App Store |
Beta Was this translation helpful? Give feedback.
-
Remove |
Beta Was this translation helpful? Give feedback.
-
@prasterphilipp, @Klu1d, please don't just mention having thesame error, but also attach some minimal reproducible code with the issue so we can save time and be of help. |
Beta Was this translation helpful? Give feedback.
-
You're right, sorry, I'll provide more detailed information in 20 minutes. |
Beta Was this translation helpful? Give feedback.
-
import flet as ft
imgsrc='aaa.jpg'
def main(page):
imgObj=ft.Image(src=imgsrc,width=300,fit=ft.ImageFit.COVER,expand=1)
img = ft.Container(
content=ft.Row(
expand=True,
width=float("inf"),
controls=[
imgObj,
ft.Text('Image',width=100,expand=1)
],
spacing=10
),
bgcolor="orange"
)
page.add(img)
ft.app(main, view=ft.AppView.WEB_BROWSER, assets_dir='assets') |
Beta Was this translation helpful? Give feedback.
-
Here is a Screenshot, like I said it works when u run it normal with ft.app(main) but with ft.app(main, view=ft.WEB_BROWSER) nothing is displayed. |
Beta Was this translation helpful? Give feedback.
-
I'm testing through the official Flet app in the App Store, and this issue started after updating to 0.21.1 Code:import flet as ft
def main(page: ft.Page):
page.fonts = {
"PTSerif": "./assets/font/PTSerif-Bold.ttf"
}
column = ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.Image("./assets/images/cat.jpg", width=200, height=200),
ft.Text("This text with the property font_family=PTSerif", font_family='PTSerif'),
ft.Text("This text without the font_family property",)
]
)
page.add(column)
ft.app(target=main, assets_dir='assets') When i use
|
Beta Was this translation helpful? Give feedback.
-
If I remove './assets', then I get the second option of events from my response |
Beta Was this translation helpful? Give feedback.
-
Have you examined the codes I wrote above? |
Beta Was this translation helpful? Give feedback.
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
I had the same problem : This is my version
Here is a test code:
current dir : -main.py At the time of writing this post I realized some details. When I run "python main.py" the app opens normally and the image is visible ( web browser, android and app ), but when I open it from "fleet run main.py", no image is displayed. According to chatgpt it has to do with the environment and how flet or python execute the files. I have no idea what that means. Has anyone done a deploy to find out if this error persists on servers? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Just found out the problem on my case. I was putting the image inside of a container, which had its width and height was based on the pages width and height (a percentage of page.window_width and page.window_height). Changing that to a number worked for some reason. |
Beta Was this translation helpful? Give feedback.
-
Dug a bit further, found that some web images actually work for my cases (not size related as @ranonbezerra mentioned). I looked up the browser network console. For those not working, they are associated with "CORS error". Flet browser mode should be just fine. Servers with looser CORS rule work. |
Beta Was this translation helpful? Give feedback.
-
Dear friends, I have tested the asset_dir and raw strings functionality on mobile devices, as well as the local host with local address working in the desktop app (Windows and Linux). I have also tested a single folder with main.py, which is only functional on the web. Please let me know if you have more information about this. Best regards, |
Beta Was this translation helpful? Give feedback.
-
Hello all! I solved the problem using: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Images from assets are no longer being shown on the WebView when using 0.21.1 >
Code example to reproduce the issue:
Describe the results you received:
When running the app with; app = ft.app(target=main, assets_dir='assets') then it gathers and displays the assets correctly but when running with app = ft.app(target=main, assets_dir='assets', view=ft.WEB_BROWSER) or app = ft.app(target=main, assets_dir='assets', export_asgi_app=True) then all images are not shown
This was not the case in <= 0.20
Describe the results you expected:
Images to be shown as expected
Additional information you deem important (e.g. issue happens only occasionally):
Flet version (
pip show flet
):Operating system:
Windows 11 23H2
Additional environment details:
Beta Was this translation helpful? Give feedback.
All reactions