Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyadev committed Jan 16, 2023
1 parent 15fa1e2 commit 13159a7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 17 deletions.
1 change: 1 addition & 0 deletions gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .title_bar import Titlebar
from .add_account_dialog import AddAccountDialog
from .log_display import LogDisplay
from .progress import Progress
34 changes: 34 additions & 0 deletions gui/progress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import flet as ft


class Progress(ft.UserControl):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.progressCircle = ft.ProgressRing(width=120, height=120, stroke_width=10)
self.progressText = ft.Text("0%")

def populate(self, new_value: float):
self.progressText.value = f"{new_value * 100:.0f}%"
self.progressCircle.value = new_value
self.progressCircle.update()
self.progressText.update()

def build(self):
return ft.Stack(
controls=[
ft.Column(
[
ft.Container(
width=45,
height=45,
content=self.progressText,
border_radius=50,
alignment=ft.alignment.center
)
],
left=37,
top=37,
),
self.progressCircle,
]
)
51 changes: 35 additions & 16 deletions gui/title_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,43 @@


class Titlebar(ft.UserControl):
def __init__(self, window_title: str = "", visible: bool = True, *args, **kwargs):
def __init__(
self,
window_title: str = "",
closable: bool = True,
hidden: bool = False,
visible: bool = True,
*args,
**kwargs
):
super().__init__(*args, **kwargs)
self.window_title = window_title
self.visible = visible
self.closable = closable
self.hidden = hidden

def build(self):
return ft.Row(
[
ft.WindowDragArea(
ft.Container(
ft.Row(
[
ft.IconButton(icon=ft.icons.GENERATING_TOKENS, disabled=True),
ft.Text(f"{self.window_title}")
]
), bgcolor=ft.colors.TRANSPARENT, padding=10, margin=0), expand=True
),
ft.IconButton(ft.icons.CLOSE, on_click=lambda _: self.page.window_close()),
],
visible=self.visible
)
if self.hidden:
return ft.Row(
[
ft.WindowDragArea(
ft.Container(bgcolor=ft.colors.TRANSPARENT, padding=10, margin=0), expand=True),
]
)
else:
return ft.Row(
[
ft.WindowDragArea(
ft.Container(
ft.Row(
[
ft.IconButton(icon=ft.icons.GENERATING_TOKENS, disabled=True),
ft.Text(f"{self.window_title}")
]
), bgcolor=ft.colors.TRANSPARENT, padding=10, margin=0), expand=True
),
ft.IconButton(ft.icons.CLOSE, on_click=lambda _: self.page.window_close())
if self.closable else ft.Container(),
],
visible=self.visible
)
2 changes: 1 addition & 1 deletion scripts/sort_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def exec_file(file: str):


if __name__ == '__main__':
dirs = ["custom_logging", "database", "util", "tests", "gui", "error_reporting"]
dirs = ["custom_logging", "database", "util", "tests", "gui", "error_reporting", "update"]
files = ["main.py", ]

for d in track(dirs, "running"):
Expand Down

0 comments on commit 13159a7

Please sign in to comment.