-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
93 lines (75 loc) · 2.38 KB
/
app.py
File metadata and controls
93 lines (75 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import flet
from flet import Page, Column, Container, Text, TextField
from flet.plotly_chart import PlotlyChart
import plotly.graph_objects as go
import piecash as pc
def Pie(labels, values):
labels:list[str] = labels
values:list[int|float] = values
return go.Figure(data=[go.Pie(labels= labels, values= values, textinfo='percent')])
def main(page: Page):
page.title = "Gráficos - GNUCash"
page.theme_mode = "light"
page.scroll = "adaptive"
page.padding = 10
page.window_height = 625
page.window_center()
def get_values(e):
path = text_field.value
book = pc.open_book(path, open_if_lock=True, readonly=True)
root = book.root_account
lista_names, lista_values = [], []
for acc in root.children:
lista_names.append(acc.name)
lista_values.append(acc.get_balance())
figure = Pie(lista_names, lista_values)
graph.figure = figure
graph.visible = True
page.update()
return lista_names, lista_values
text_field = TextField(
hint_text= "caminho/para/o/arquivo.gnucash",
label= "Caminho do arquivo gnucash",
label_style= flet.TextStyle(size=14),
text_style= flet.TextStyle(size=18),
# text_size= 14,
content_padding= flet.padding.only(left=10),
height= 42,
width=page.window_width,
data="",
value= r"",
on_submit= get_values
)
graph = PlotlyChart(
visible= False,
)
page.add(
Column(
controls=
[
# Header
Container(
margin= flet.margin.symmetric(horizontal=10),
content=
Column(
controls=
[
Text("Gráfico Balanço patrimônial", size= 30, weight="bold"),
text_field,
]
)
),
# Body
Container(
content=
Column(
controls=
[
graph
]
)
)
]
)
)
flet.app(target=main)