Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
906 B
6
Indexable
Never
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()])
Leave a Comment