diff --git a/classes/CopperPair.py b/classes/CopperPair.py index 66e5cd9..e9889c5 100644 --- a/classes/CopperPair.py +++ b/classes/CopperPair.py @@ -27,7 +27,7 @@ def __tip(pair) -> str: @property def tip_color(self) -> str: """Tip Color""" - return self.__tip(self.pair) + return self.__tip(self.base_pair) @staticmethod def __tip_hex(tip: str) -> str: @@ -71,7 +71,7 @@ def __ring(pair: int) -> str: @property def ring_color(self) -> str: """Ring Color""" - return self.__ring(self.pair) + return self.__ring(self.base_pair) @staticmethod def __ring_hex(tip: str) -> str: @@ -99,55 +99,55 @@ def ring_hex(self) -> str: def super_binder(self) -> int: """Super Binder Group""" match self.pair: - case num if 1 <= num >= 625: + case num if 1 <= num <= 625: return 1 - case num if 626 <= num >= 1250: + case num if 626 <= num <= 1250: return 2 - case num if 1251 <= num >= 1875: + case num if 1251 <= num <= 1875: return 3 - case num if 1876 <= num >= 2500: + case num if 1876 <= num <= 2500: return 4 - case num if 2501 <= num >= 3125: + case num if 2501 <= num <= 3125: return 5 - case num if 3126 <= num >= 3750: + case num if 3126 <= num <= 3750: return 6 - case num if 3751 <= num >= 4375: + case num if 3751 <= num <= 4375: return 7 - case num if 4376 <= num >= 5000: + case num if 4376 <= num <= 5000: return 8 - case num if 5001 <= num >= 5625: + case num if 5001 <= num <= 5625: return 9 - case num if 5626 <= num >= 6250: + case num if 5626 <= num <= 6250: return 10 - case num if 6251 <= num >= 6875: + case num if 6251 <= num <= 6875: return 11 - case num if 6876 <= num >= 7500: + case num if 6876 <= num <= 7500: return 12 - case num if 7501 <= num >= 8125: + case num if 7501 <= num <= 8125: return 13 - case num if 8126 <= num >= 8750: + case num if 8126 <= num <= 8750: return 14 - case num if 8751 <= num >= 9375: + case num if 8751 <= num <= 9375: return 15 - case num if 9376 <= num >= 10000: + case num if 9376 <= num <= 10000: return 16 - case num if 10001 <= num >= 10625: + case num if 10001 <= num <= 10625: return 17 - case num if 10626 <= num >= 11250: + case num if 10626 <= num <= 11250: return 18 - case num if 112551 <= num >= 11875: + case num if 112551 <= num <= 11875: return 19 - case num if 11876 <= num >= 12500: + case num if 11876 <= num <= 12500: return 20 - case num if 12501 <= num >= 13125: + case num if 12501 <= num <= 13125: return 21 - case num if 13126 <= num >= 13750: + case num if 13126 <= num <= 13750: return 22 - case num if 13751 <= num >= 14375: + case num if 13751 <= num <= 14375: return 23 - case num if 14376 <= num >= 15000: + case num if 14376 <= num <= 15000: return 24 - case num if 15001 <= num >= 15625: + case num if 15001 <= num <= 15625: return 25 case _: return 0 @@ -156,55 +156,55 @@ def super_binder(self) -> int: def binder(self) -> int: """Binder Number""" match self.base_binder_pair: - case num if 1 <= num >= 25: + case num if 1 <= num <= 25: return 1 - case num if 26 <= num >= 50: + case num if 26 <= num <= 50: return 2 - case num if 51 <= num >= 75: + case num if 51 <= num <= 75: return 3 - case num if 76 <= num >= 100: + case num if 76 <= num <= 100: return 4 - case num if 101 <= num >= 125: + case num if 101 <= num <= 125: return 5 - case num if 126 <= num >= 150: + case num if 126 <= num <= 150: return 6 - case num if 151 <= num >= 175: + case num if 151 <= num <= 175: return 7 - case num if 176 <= num >= 200: + case num if 176 <= num <= 200: return 8 - case num if 201 <= num >= 225: + case num if 201 <= num <= 225: return 9 - case num if 226 <= num >= 250: + case num if 226 <= num <= 250: return 10 - case num if 251 <= num >= 275: + case num if 251 <= num <= 275: return 11 - case num if 276 <= num >= 300: + case num if 276 <= num <= 300: return 12 - case num if 301 <= num >= 325: + case num if 301 <= num <= 325: return 13 - case num if 326 <= num >= 350: + case num if 326 <= num <= 350: return 14 - case num if 351 <= num >= 375: + case num if 351 <= num <= 375: return 15 - case num if 376 <= num >= 400: + case num if 376 <= num <= 400: return 16 - case num if 401 <= num >= 425: + case num if 401 <= num <= 425: return 17 - case num if 426 <= num >= 450: + case num if 426 <= num <= 450: return 18 - case num if 451 <= num >= 475: + case num if 451 <= num <= 475: return 19 - case num if 476 <= num >= 500: + case num if 476 <= num <= 500: return 20 - case num if 501 <= num >= 525: + case num if 501 <= num <= 525: return 21 - case num if 526 <= num >= 550: + case num if 526 <= num <= 550: return 22 - case num if 551 <= num >= 575: + case num if 551 <= num <= 575: return 23 - case num if 576 <= num >= 600: + case num if 576 <= num <= 600: return 24 - case num if 601 <= num >= 625: + case num if 601 <= num <= 625: return 25 case _: return 0 @@ -224,19 +224,19 @@ def base_binder_pair(self) -> int: @property def binder_tip_color(self) -> str: """Binder Tip Color""" - return self.__tip_hex(self.__tip(self.binder)) + return self.__tip(self.binder) @property def binder_ring_color(self) -> str: """Binder Ring Color""" - return self.__ring_hex(self.__tip(self.binder)) + return self.__ring(self.binder) @property def super_binder_tip_color(self) -> str: """Super Binder Tip Color""" - return self.__tip_hex(self.__tip(self.super_binder)) + return self.__tip(self.super_binder) @property def super_binder_ring_color(self) -> str: """Super Binder Ring Color""" - return self.__ring_hex(self.__ring(self.super_binder)) + return self.__ring(self.super_binder) diff --git a/main.py b/main.py index a97780e..4f2b231 100644 --- a/main.py +++ b/main.py @@ -38,7 +38,10 @@ def view(data: fs.Datasy): text="Static IP Instructions", on_click=data.go("/uv/statics") ), ft.PopupMenuItem( - text="Copper Pair to Color", on_click=data.go("/copper/pair_to_color") + text="Copper Pair Calculator", on_click=data.go("/copper/pair_to_color") + ), + ft.PopupMenuItem( + text="Distance Calculator", on_click=data.go("/distance_calc") ), ] ), diff --git a/views/copper.py b/views/copper.py index 982cb3c..57bcde1 100644 --- a/views/copper.py +++ b/views/copper.py @@ -30,16 +30,19 @@ def copper_color_code_page(data: fs.Datasy): horizontal_alignment="center", appbar=view.appbar, bgcolor=AppColors.BG, - scroll=ft.ScrollMode.ALWAYS + scroll=ft.ScrollMode.ALWAYS, ) + @copper.page("/pair_to_color/{pair}", title="Copper Color To Pair") @copper.page("/pair_to_color", title="Copper Color To Pair") def copper_pair_to_color_page(data: fs.Datasy, pair=""): """Copper Pair to Color Page""" + def changed_pair(): """Changed Pair""" data.page.go(f"/copper/pair_to_color/{pair_field.value}") + view = data.view title = ft.Text( value="Copper Pair Calculator", @@ -55,21 +58,19 @@ def changed_pair(): border_color=ft.colors.WHITE, width=100, value=pair, - on_change=lambda e: changed_pair() + on_change=lambda e: changed_pair(), ) if pair == "": pair_info = ft.Text( - ( - "" - ), - text_align=ft.alignment.center, - color=ft.colors.WHITE, + (""), + text_align=ft.alignment.center, + color=ft.colors.WHITE, ) else: pair_data = CopperPair(int(pair)) pair_info = ft.Text( ( - f"Pair: {pair} ({pair_data.tip_color}/{pair_data.ring_color})\n" + f"Pair: {pair_data.base_pair} ({pair_data.tip_color}/{pair_data.ring_color})\n" f"Binder: {pair_data.binder} ({pair_data.binder_tip_color}/{pair_data.binder_ring_color})\n" f"Super Binder: {pair_data.super_binder} ({pair_data.super_binder_tip_color}/{pair_data.super_binder_ring_color})\n" ), @@ -102,4 +103,3 @@ def changed_pair(): appbar=view.appbar, bgcolor=AppColors.BG, ) - \ No newline at end of file diff --git a/views/distance_calc.py b/views/distance_calc.py new file mode 100644 index 0000000..a2eb565 --- /dev/null +++ b/views/distance_calc.py @@ -0,0 +1,80 @@ +"""UVT Home""" + +import flet as ft # type: ignore +import flet_easy as fs # type: ignore +from assets.app_colors import AppColors + +copper = fs.AddPagesy() + + +@copper.page("/distance_calc", title="Distance Calculator") +def distance_calc_page(data: fs.Datasy): + """Distance Calculator Page""" + + view = data.view + title = ft.Text( + value="Distance Calculator", + text_align=ft.alignment.center, + color=ft.colors.WHITE, + ) + text = ft.Text("") + conversion_units = ft.Dropdown( + options=[ + ft.dropdown.Option("Miles to Feet", alignment=ft.alignment.center), + ft.dropdown.Option("Feet to Miles", alignment=ft.alignment.center), + ], + value="Miles to Feet", + alignment=ft.alignment.center, + color=ft.colors.WHITE, + width=100, + on_change=lambda e: changed_value(), + ) + + def changed_value(): + """Changed Value""" + units = float(pair_field.value) + if conversion_units.value == "Miles to Feet": + new_units = units * 5280 + text.value = f"{units} miles = {new_units} feet" + else: + new_units = units / 5280 + text.value = f"{units} feet = {new_units} miles" + data.page.update() + + pair_field = ft.TextField( + text_align=ft.TextAlign.CENTER, + keyboard_type=ft.KeyboardType.NUMBER, + autofocus=True, + helper_text="Pair Number", + color=ft.colors.WHITE, + border_color=ft.colors.WHITE, + width=100, + on_change=lambda e: changed_value(), + ) + + container = ft.Container( + bgcolor=AppColors.BG, + # border_radius=35, + # width=400, + # height=850, + content=ft.Stack( + controls=[ + ft.Column( + controls=[ + pair_field, + conversion_units, + ] + ) + ] + ), + # padding=50, + alignment=ft.alignment.top_center, + ) + + return ft.View( + controls=[title, container, text], + vertical_alignment="center", + horizontal_alignment="center", + appbar=view.appbar, + bgcolor=AppColors.BG, + ) diff --git a/views/home.py b/views/home.py index 62e1d4c..ea57076 100644 --- a/views/home.py +++ b/views/home.py @@ -16,7 +16,7 @@ def home_page(data: fs.Datasy): content=ft.Text( "RJ45 Wiring Scheme", text_align=ft.TextAlign.CENTER, max_lines=1, size=11 ), - image=ft.DecorationImage(src="https://img.icons8.com/color/96/000000/rj45.png"), + image=ft.DecorationImage(src="https://img.icons8.com/color/62/000000/rj45.png"), on_click=lambda e: page.go("/rj45_scheme"), ) copper_color_code_container = ft.Container( @@ -24,7 +24,7 @@ def home_page(data: fs.Datasy): "Copper Color Code", text_align=ft.TextAlign.CENTER, max_lines=1, size=12 ), image=ft.DecorationImage( - src="https://img.icons8.com/color/96/000000/color-palette.png" + src="https://img.icons8.com/color/62/000000/color-palette.png" ), on_click=lambda e: page.go("/copper/color_code"), ) @@ -33,7 +33,7 @@ def home_page(data: fs.Datasy): "Fiber Color Code", text_align=ft.TextAlign.CENTER, max_lines=1 ), image=ft.DecorationImage( - src="https://img.icons8.com/color/96/000000/color-palette.png" + src="https://img.icons8.com/color/62/000000/color-palette.png" ), on_click=lambda e: page.go("/fiber_color_code"), ) @@ -42,10 +42,29 @@ def home_page(data: fs.Datasy): "UV Static IP Calc", text_align=ft.TextAlign.CENTER, max_lines=1 ), image=ft.DecorationImage( - src="https://img.icons8.com/external-vectorslab-glyph-vectorslab/53/external-Network-Setting-machine-learning-vectorslab-glyph-vectorslab-2.png" + src="https://img.icons8.com/external-vectorslab-glyph-vectorslab/62/" + "external-Network-Setting-machine-learning-vectorslab-glyph-vectorslab-2.png" ), on_click=lambda e: page.go("/uv/statics"), ) + copper_pair_calc = ft.Container( + content=ft.Text( + "Copper Pair Calc", text_align=ft.TextAlign.CENTER, max_lines=1 + ), + image=ft.DecorationImage( + src="https://img.icons8.com/color/62/apple-calculator.png" + ), + on_click=lambda e: page.go("/uv/statics"), + ) + distance_calc = ft.Container( + content=ft.Text( + "Distance Calc", text_align=ft.TextAlign.CENTER, max_lines=1 + ), + image=ft.DecorationImage( + src="https://img.icons8.com/color/62/apple-calculator.png" + ), + on_click=lambda e: page.go("/distance_calc"), + ) images = ft.GridView( expand=1, runs_count=5, @@ -58,6 +77,8 @@ def home_page(data: fs.Datasy): copper_color_code_container, fiber_color_code_container, statics, + copper_pair_calc, + distance_calc, ], )