Question:
I created a “Images” folder in “files” tab,
and uploaded my file.
I copied the file path to my script.
However, when I run my script, the photo does not appear!
Repl link/Link to where the bug appears:
https://replit.com/@fotografiadmd/Testes
Screenshots, links, or other helpful context:
import flet as ft
dir='Imagens/logo-3.jpg'
def main(page: ft.Page):
page.title = "Images Example"
page.theme_mode = ft.ThemeMode.LIGHT
page.padding = 50
page.update()
img = ft.Image(
src=dir,
width=80,
height=80,
fit=ft.ImageFit.CONTAIN,
border_radius=1,
)
texto = ft.Text(
' Atelier Dalci',
font_family='tahoma',
size=30,
color=ft.colors.BROWN_700,
)
cabeçalho = ft.Row(controls=[img, texto])
page.add(cabeçalho)
page.update()
ft.app(target=main, view=ft.AppView.WEB_BROWSER)
You made a typo in your code.
fotografiadmd:
dir='Imagens/logo-3.jpg'
Should be
dir = 'Images/logo-3.jpg'
3 Likes
I created this folder.
" Imagens" means “Images” in portuguese.
1 Like
I solved the thing !
import flet as ft
from pathlib import Path
assets = f'{Path(__file__).parent}'
print(assets)
logo = 'Imagens/logo-4.jpg'
print(dir)
def main(page: ft.Page):
page.title = "Images Example"
page.theme_mode = ft.ThemeMode.LIGHT
page.padding = 50
page.update()
img = ft.Image(
src=logo,
width=80,
height=80,
fit=ft.ImageFit.CONTAIN,
border_radius=1,
)
texto = ft.Text(
'Atelier Tesoura Mágica',
font_family='tahoma',
size=20,
color=ft.colors.PINK,
)
#cabeçalho=ft.Row(controls=[img,texto])
cabecalho = ft.ResponsiveRow([
ft.Column(col={
"xs": 4,
"sm": 3,
"md": 2,
"xl": 1
}, controls=[img]),
ft.Column(col={
"xs": 8,
"sm": 6,
"md": 5,
"xl": 4
}, controls=[texto]),
],
vertical_alignment=ft.CrossAxisAlignment.CENTER,
alignment='left')
page.add(cabecalho)
page.update()
#ft.app(target=main)
ft.app(target=main, view=ft.AppView.WEB_BROWSER, assets_dir=assets)
1 Like
Oh, OK. In your original topic, you said the folder was called “Images”.
system
Closed
March 21, 2024, 6:34pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.