Untitled
unknown
python
8 months ago
2.1 kB
12
Indexable
Never
import flet as ft import json import random import logging class CardObj(ft.UserControl): def __init__(self, user_id, user_photo): self.user_id = user_id self.user_photo = user_photo print(self.user_id, self.user_photo) super().__init__() def build(self): return ft.Card(content=ft.ListTile(title=ft.Text(f"Kullanıcı | {self.user_id}"), leading=ft.CircleAvatar( foreground_image_url=self.user_photo, radius=25 ), on_click=lambda _: self.page.go(f"/data{self.user_id}"))) class MainPage(ft.UserControl): def __init__(self): super().__init__() def build(self): with open("data.json") as f: data = json.load(f) return ft.ListView([CardObj(userid, pp["pp"]) for userid, pp in data.items()]) def main(page: ft.Page): page.title = "PanelGram" def route_change(e): page.views.clear() page.views.append( ft.View( route="/", controls=[ ft.AppBar( title=ft.Text("TeleGram"), bgcolor="blue" ), MainPage() ] ) ) page.views[0].scroll = "HIDDEN" if page.route.startswith("/data"): page.views.append( ft.View( route=page.route, controls=[ ft.AppBar( title=ft.Text("Telegram - Bilgi"), bgcolor="blue" ), ft.ElevatedButton(text="Geri Dön", on_click=lambda _: page.go("/")) ] ) ) def view_pop(e): page.views.pop() top = page.views[-1] page.go(top.route) page.on_route_change = route_change page.on_view_pop = view_pop page.go(page.route) ft.app(target=main)
Leave a Comment