Skip to content

Commit

Permalink
text resized
Browse files Browse the repository at this point in the history
  • Loading branch information
ositoMalvado committed Jul 29, 2024
1 parent 069d14b commit 135196e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
test.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Expand Down
27 changes: 17 additions & 10 deletions Tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def __init__(self):
self.text = "Franquicias"
self.mi_data_table = ft.DataTable(
columns=[
ft.DataColumn(ft.Text(size=24,expand=True,value="Tipo de Vehículo", weight=ft.FontWeight.BOLD), tooltip="Tipo de Vehículo"),
ft.DataColumn(ft.Text(size=24,expand=True,value="% Suma Asegurada", weight=ft.FontWeight.BOLD), tooltip="% Suma Asegurada"),
ft.DataColumn(ft.Text(size=24,expand=True,value="Monto mínimo de Franquicia", weight=ft.FontWeight.BOLD), tooltip="Monto mínimo de Franquicia"),
ft.DataColumn(ft.Text(expand=True,value="Tipo de Vehículo", weight=ft.FontWeight.BOLD), tooltip="Tipo de Vehículo"),
ft.DataColumn(ft.Text(expand=True,value="% Suma Asegurada", weight=ft.FontWeight.BOLD), tooltip="% Suma Asegurada"),
ft.DataColumn(ft.Text(expand=True,value="Monto mínimo de Franquicia", weight=ft.FontWeight.BOLD), tooltip="Monto mínimo de Franquicia"),
],
rows=[],
expand=True,
Expand All @@ -31,9 +31,9 @@ def __init__(self):
self.mi_data_table.rows.append(
ft.DataRow(
cells=[
ft.DataCell(Zoomtainer(ft.Text(franquicia["tipo"], weight=ft.FontWeight.BOLD,size=20), zoom=1.5)),
ft.DataCell(Zoomtainer(ft.Text(franquicia["porcentaje"],size=20), zoom=1.5)),
ft.DataCell(Zoomtainer(ft.Text(franquicia["Monto"],size=20), zoom=1.5)),
ft.DataCell(Zoomtainer(ft.Text(franquicia["tipo"], weight=ft.FontWeight.BOLD), zoom=1.5)),
ft.DataCell(Zoomtainer(ft.Text(franquicia["porcentaje"]), zoom=1.5)),
ft.DataCell(Zoomtainer(ft.Text(franquicia["Monto"]), zoom=1.5)),
],
color=ft.colors.BLACK12 if i % 2 == 0 else None
)
Expand All @@ -54,6 +54,13 @@ def __init__(self):
scroll="auto",
expand=True
)
from test import PlanillaCobranza
class TabGeneralCobranza(ft.Tab):

def __init__(self):
super().__init__()
self.text = "Cobranza"
self.content = PlanillaCobranza()

class TabGeneralPatentes(ft.Tab):

Expand Down Expand Up @@ -103,17 +110,17 @@ def __init__(self):
self.text = "Año de auto por patente"
self.mi_data_table = ft.DataTable(
columns=[
ft.DataColumn(ft.Text("Patente", size=20, weight=ft.FontWeight.BOLD), tooltip="Patente"),
ft.DataColumn(ft.Text("Año", size=20, weight=ft.FontWeight.BOLD), tooltip="Año"),
ft.DataColumn(ft.Text("Patente", weight=ft.FontWeight.BOLD), tooltip="Patente"),
ft.DataColumn(ft.Text("Año", weight=ft.FontWeight.BOLD), tooltip="Año"),
],
rows=[],
)
for i, patente in enumerate(self.patentes):
self.mi_data_table.rows.append(
ft.DataRow(
cells=[
ft.DataCell(Zoomtainer(ft.Text(patente, weight=ft.FontWeight.BOLD, size=14), zoom=1.2)),
ft.DataCell(Zoomtainer(ft.Text(self.patentes[patente], size=14), zoom=1.2)),
ft.DataCell(Zoomtainer(ft.Text(patente, weight=ft.FontWeight.BOLD), zoom=1.2)),
ft.DataCell(Zoomtainer(ft.Text(self.patentes[patente]), zoom=1.2)),
],
color=ft.colors.BLACK12 if i % 2 == 0 else None
)
Expand Down
69 changes: 47 additions & 22 deletions Widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def update_premio(self, e):
return
self.intervalo_display.value = "$" + str(int(self.intervalo_slider.value))
self.intervalo_display.update()
self.cuotas_display.value = str(int(self.cuotas_slider.value))
self.cuotas_display.update()
if self.text_field_premio.value == '':
return

Expand All @@ -45,18 +47,24 @@ def update_premio(self, e):

# Asegurarse de que el valor redondeado no sea menor que el valor descontado
final_value = max(rounded_value, math.ceil(discounted_value))

self.valor_final.value = str(int(final_value))
self.premio_display.value = "$" + str(int(final_value))
self.premio_display.update()
self.valor_final.value = str(int(self.cuotas)) + " cuotas de " + str(int(final_value/self.cuotas))
self.valor_final.update()

def slider_handle(self, e):
self.descuento = self.slider.value
self.descuento_display.value = str(int(self.slider.value)) + "%"
self.descuento_display.update()
if e.control.data == "descuento":
self.slider.label = "Descuento: " + str(int(self.slider.value)) + "%"
self.descuento = self.slider.value
self.descuento_display.value = str(int(self.descuento)) + "%"
self.descuento_display.update()
self.slider.label = "Descuento: " + str(int(self.descuento)) + "%"
self.slider.update()
elif e.control.data == "cuotas":
self.cuotas = self.cuotas_slider.value
self.cuotas_slider.label = "Cuotas: " + str(int(self.cuotas))
self.cuotas_slider.update()
else:
self.intervalo = self.intervalo_slider.value
self.intervalo_slider.label = "Intervalo: $" + str(int(self.intervalo_slider.value))
self.intervalo_slider.update()
self.update_premio(e)
Expand Down Expand Up @@ -98,23 +106,14 @@ def __init__(self):
data="descuento",
)

self.valor_final = ft.Text("0", size=40, expand=True, text_align=ft.TextAlign.CENTER)
self.valor_final = ft.Text("0", expand=True, text_align=ft.TextAlign.CENTER)

self.text_field_premio = ft.TextField(
label="Premio",
prefix_icon=ft.icons.ATTACH_MONEY_ROUNDED,
hint_text="Ingresa el premio",
# height=100,
content_padding=ft.padding.all(5),
text_style=ft.TextStyle(
size=24,
),
hint_style=ft.TextStyle(
size=24,
),
label_style=ft.TextStyle(
size=24,
),
on_change=self.update_premio,
input_filter = ft.InputFilter(
regex_string=r"[1-9][0-9]*",
Expand All @@ -134,7 +133,7 @@ def __init__(self):
on_click=self.copy_premio,
)

self.descuento_display = ft.Text(str(self.descuento) + "%", weight=ft.FontWeight.BOLD, size=20)
self.descuento_display = ft.Text(str(self.descuento) + "%", weight=ft.FontWeight.BOLD)

self.intervalo = 300
self.intervalo_slider = ft.Slider(
Expand All @@ -146,28 +145,54 @@ def __init__(self):
label="Intervalo: 300",
data="intervalo"
)
self.intervalo_display = ft.Text("$" + str(self.intervalo), weight=ft.FontWeight.BOLD, size=20)
self.intervalo_display = ft.Text("$" + str(self.intervalo), weight=ft.FontWeight.BOLD)

self.cuotas = 3
self.cuotas_display = ft.Text(str(self.cuotas), weight=ft.FontWeight.BOLD)
self.premio_display = ft.Text("$0", weight=ft.FontWeight.BOLD)
self.cuotas_slider = ft.Slider(
value=self.cuotas,
min=1,
max=6,
divisions=5,
on_change=self.slider_handle,
label="Cuotas: " + str(self.cuotas),
data="cuotas"
)

self.content = ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.Text("Calculadora de Premio", size=30, weight=ft.FontWeight.BOLD),
ft.Text("Calculadora de Premio", weight=ft.FontWeight.BOLD),
self.text_field_premio,
ft.Row(
[
ft.Text("Descuento: ", weight=ft.FontWeight.BOLD, size=18),
ft.Text("Descuento: ", weight=ft.FontWeight.BOLD),
self.descuento_display,
]
),
self.slider,
ft.Row(
[
ft.Text("Intervalo: ", weight=ft.FontWeight.BOLD, size=18),
ft.Text("Intervalo: ", weight=ft.FontWeight.BOLD),
self.intervalo_display,
]
),
self.intervalo_slider,
ft.Text("Premio con descuento: ", weight=ft.FontWeight.BOLD, size=18),
ft.Row(
[
ft.Text("Cuotas: ", weight=ft.FontWeight.BOLD),
self.cuotas_display,
]
),
self.cuotas_slider,

ft.Row(
[
ft.Text("Premio con descuento: ", weight=ft.FontWeight.BOLD),
self.premio_display,
]
),
self.boton_copiar
],
spacing=2,
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def main(page: ft.Page):
text="General",
content=ft.Tabs(
[
TabGeneralPatentes()
TabGeneralPatentes(),
TabGeneralCobranza()
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True,
Expand Down

0 comments on commit 135196e

Please sign in to comment.