Flet - Pythonda Electrona Harika Bir Alternatif

Merhaba ilk konuma ho┼čgeldiniz. Technopat─▒ b─▒rakd─▒m art─▒k. Buras─▒ daha g├╝zel.
Her neyse konumuza d├Ânelim. ├ľncelikle flet ile nas─▒l tan─▒┼čt─▒m. Asl─▒nda bir g├╝n ne yapaca─č─▒m─▒ bilmiyordum, ve kernelginar hocam─▒n arch beti─čini g├Ârd├╝m. Bunun ├╝zerine akl─▒ma bir arch kurulum arac─▒ yazmak geldi. Ara┼čt─▒rmaya ba┼člad─▒m. Ve ubuntunun yeni arac─▒n─▒n flutter ile yaz─▒ld─▒─č─▒n─▒ g├Ârd├╝m. Dedim bunu pythonda kullansak nas─▒l olur ve flet k├╝t├╝phanesini buldum.

Backendi yazd─▒ktan sonra i┼č frontende geldi. Biraz ara┼čt─▒rma ve kafa patlatma ile bunu yazd─▒m:


Daha bitmedi ancak, ┼čunun g├╝zelli─čine bak─▒n. Kendi icon deste─či var. Ak─▒c─▒, isterseniz web sunucusu olarak ├žal─▒┼čt─▒rabiliyorsunuz. Material Design kullan─▒lm─▒┼č. Zaten flutter Google ─▒n k├╝t├╝phanesi. Mant─▒k electronla ayn─▒ say─▒l─▒r, biraz daha farkl─▒ san─▒rsam. Ben pek iyi yapamam─▒┼č olabilirim, ama internette ├žok g├╝zel tasar─▒mlar var. E─čer ui geli┼čtirmek isteyip karar veremeyen arkada┼člar varsa bir baks─▒n. ├çok detayl─▒ bir proje. Ayr─▒ca sitesinde ileride .net gibi dillere de gelece─či yaz─▒yor. ├çok g├╝zel olur.

Bu sayfa i├žin olu┼čturdu─čum kod:

import flet
from flet import Page, UserControl, Column, Container, colors, border_radius, padding, Text, Row, ElevatedButton, icons, \
    IconButton, Dropdown, dropdown, FontWeight, AlertDialog


def inf_on_click(page: Page):
    pass


class App(UserControl):
    def __init__(self, style):
        super().__init__()
        self.style = style

    def build(self):
        return Column(
            controls=[
                Container(
                    bgcolor=self.style["bg-color"],
                    width=450,
                    height=550,
                    border_radius=self.style["border-radius"],

                    content=(
                        Column(
                            alignment=flet.MainAxisAlignment.CENTER,
                            horizontal_alignment=flet.CrossAxisAlignment.CENTER,
                            controls=[
                                Container(
                                    width=430,
                                    height=530,

                                    content=(
                                        Column(

                                            controls=[

                                                Row(

                                                    expand=True,
                                                    alignment=flet.MainAxisAlignment.CENTER,
                                                    vertical_alignment=flet.CrossAxisAlignment.START,

                                                    controls=[
                                                        Column(
                                                            expand=True,
                                                            alignment=flet.MainAxisAlignment.START,
                                                            horizontal_alignment=flet.CrossAxisAlignment.START,
                                                            controls=[
                                                                IconButton(
                                                                    icon=icons.INFO,
                                                                    scale=0.8,
                                                                    on_click=self.show_inf_dialog

                                                                )
                                                            ]
                                                        ),
                                                        Column(
                                                            expand=True,
                                                            width=175,
                                                            alignment=flet.MainAxisAlignment.START,
                                                            horizontal_alignment=flet.CrossAxisAlignment.CENTER,
                                                            controls=[
                                                                Text("Hello!",
                                                                     size=25,

                                                                     )
                                                            ]

                                                        ),
                                                        Column(
                                                            expand=True
                                                        ),

                                                    ]
                                                ),
                                                Row(
                                                    expand=True,
                                                    alignment=flet.MainAxisAlignment.CENTER,
                                                    controls=[
                                                        ElevatedButton(
                                                            text="Start Installation",
                                                            icon=icons.ARROW_RIGHT,
                                                            color=self.style["text-color"],
                                                            scale=1.2,
                                                            on_click=self.to_page2

                                                        )
                                                    ]
                                                ),
                                                Row(
                                                    expand=True,
                                                    alignment=flet.MainAxisAlignment.CENTER,
                                                    vertical_alignment=flet.CrossAxisAlignment.START,
                                                    controls=[
                                                        Column(
                                                            expand=True,
                                                            alignment=flet.MainAxisAlignment.END,
                                                            horizontal_alignment=flet.CrossAxisAlignment.START,
                                                            controls=[
                                                                IconButton(
                                                                    icon=icons.POWER_SETTINGS_NEW,
                                                                    scale=1.3,
                                                                    tooltip="Shutdown",

                                                                )
                                                            ]
                                                        ),
                                                        Column(
                                                            width=175,

                                                            alignment=flet.MainAxisAlignment.END,
                                                            horizontal_alignment=flet.CrossAxisAlignment.CENTER,
                                                            controls=[
                                                                Dropdown(
                                                                    width=200,
                                                                    height=45,

                                                                    tooltip="Select Language",
                                                                    hint_text="Select Language",
                                                                    hint_style=flet.TextStyle(size=15),

                                                                    options=[
                                                                        dropdown.Option("English")
                                                                    ]
                                                                )

                                                            ]
                                                        ),
                                                        Column(expand=True,
                                                               alignment=flet.MainAxisAlignment.END,
                                                               horizontal_alignment=flet.CrossAxisAlignment.END,
                                                               controls=[
                                                                   IconButton(
                                                                       icon=icons.ARROW_RIGHT_ALT,
                                                                       tooltip="Use arch in archiso enviroment(Live CD)",
                                                                       scale=1.3
                                                                   )
                                                               ]
                                                               ),

                                                    ]
                                                )
                                            ]
                                        )
                                    )
                                )
                            ]
                        )

                    )

                )
            ]

        )

    def show_inf_dialog(self, event):
        dlg = flet.AlertDialog(
            title=flet.Text("Easy Arch Utily Beta \nwritten by Detux"), on_dismiss=lambda e: print("Dialog dismissed!")
        )
        self.page.dialog = dlg
        dlg.open = True
        self.page.update()

    def show_dialog(self, dialog, event):
        dlg = flet.AlertDialog(
            title=flet.Text("{}".format(dialog)), on_dismiss=lambda e: print("Dialog dismissed!")
        )
        self.page.dialog = dlg
        dlg.open = True
        self.page.update()

    def to_page2(self, e):
        self.page.route = "/page2"
        self.page.update()







def route_p(e):
    print("h")

def main(page: Page):




    page.title = "EasyArch Utily"
    page.window_height = 600
    page.window_width = 500
    page.on_route_change = route_p

    style = {
        "text-color": colors.WHITE,
        "secondary-bg-color": colors.WHITE60,
        "bg-color": colors.BLACK12,
        "border-radius": 12
    }
    app = App(style)
    page.add(app)
    page.vertical_alignment = "center"
    page.horizontal_alignment = "center"

    page.update()


flet.app(main)

3 Likes

flet g├╝zel ├Âzellikle icon deste─či cok kullan─▒┼čl─▒ fakat electron daha pratik gibi.

Pythonda bence tek alternatif, ama node.js de electron daha iyi.