mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 08:43:36 +05:00
refactor: add padding option to dialog
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -88,7 +88,6 @@ def print_multi_instance_warning(instances: List[Klipper]) -> None:
|
||||
"The following instances were found:",
|
||||
*_instances,
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ def update_klipper() -> None:
|
||||
"All Klipper instances will be restarted during the update process and "
|
||||
"ongoing prints WILL FAIL.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
if not get_confirm("Update Klipper now?"):
|
||||
|
||||
@@ -220,7 +220,6 @@ def check_user_groups():
|
||||
"INFO:",
|
||||
"Relog required for group assignments to take effect!",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
if not get_confirm(f"Add user '{CURRENT_USER}' to group(s) now?"):
|
||||
@@ -272,7 +271,7 @@ def handle_disruptive_system_packages() -> None:
|
||||
"Please fix the problem manually. Otherwise, this may have "
|
||||
"undesirable effects on the operation of Klipper."
|
||||
],
|
||||
end="",
|
||||
padding_bottom="",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -353,7 +353,6 @@ class KlipperSelectSDFlashBoardMenu(BaseMenu):
|
||||
"\n\n",
|
||||
"If you are unsure, stick to the default 250000!",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
self.flash_options.selected_baudrate = get_number_input(
|
||||
question="Please set the baud rate",
|
||||
|
||||
@@ -62,7 +62,6 @@ def install_klipperscreen() -> None:
|
||||
"KlipperScreens update manager configuration for Moonraker "
|
||||
"will not be added to any moonraker.conf.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
if not get_confirm(
|
||||
"Continue KlipperScreen installation?",
|
||||
|
||||
@@ -58,7 +58,6 @@ def install_mobileraker() -> None:
|
||||
"Mobileraker's companion's update manager configuration for Moonraker "
|
||||
"will not be added to any moonraker.conf.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
if not get_confirm(
|
||||
"Continue Mobileraker's companion installation?",
|
||||
|
||||
@@ -100,7 +100,6 @@ def print_install_client_config_dialog(client: BaseWebClient) -> None:
|
||||
"If you already use these macros skip this step. Otherwise you should "
|
||||
"consider to answer with 'Y' to download the recommended macros.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
|
||||
@@ -115,5 +114,4 @@ def print_ipv6_warning_dialog() -> None:
|
||||
"If you think this warning is a false alarm, and you are sure that "
|
||||
"IPv6 is disabled, you can continue with the installation.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
@@ -144,7 +144,6 @@ class SettingsMenu(BaseMenu):
|
||||
f"New {display_name} repository branch:",
|
||||
f"● {branch}",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
if get_confirm("Apply changes?", allow_go_back=True):
|
||||
|
||||
@@ -219,6 +219,5 @@ class KiauhSettings:
|
||||
"● default.kiauh.cfg",
|
||||
"● kiauh.cfg",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
kill()
|
||||
|
||||
@@ -192,7 +192,6 @@ class ObicoExtension(BaseExtension):
|
||||
"http://server_ip:port",
|
||||
"For instance, 'http://192.168.0.5:3334'.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
def _print_moonraker_instances(self, mr_instances) -> None:
|
||||
@@ -206,7 +205,6 @@ class ObicoExtension(BaseExtension):
|
||||
"\n\n",
|
||||
"The setup will apply the same names to Obico!",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
def _print_is_already_installed(self) -> None:
|
||||
@@ -221,7 +219,6 @@ class ObicoExtension(BaseExtension):
|
||||
"L) Link printer to the Obico server",
|
||||
"R) Repair installation",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
|
||||
def _get_server_url(self) -> None:
|
||||
@@ -324,7 +321,6 @@ class ObicoExtension(BaseExtension):
|
||||
"If you don't want to link the printer now, you can restart the "
|
||||
"linking process later by running this installer again.",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
if not get_confirm("Do you want to link the printers now?"):
|
||||
Logger.print_info("Linking to Obico server skipped ...")
|
||||
|
||||
@@ -150,7 +150,6 @@ def moonraker_exists(name: str = "") -> bool:
|
||||
"No Moonraker instances found!",
|
||||
f"{info}. Please install Moonraker first!",
|
||||
],
|
||||
end="",
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -90,7 +90,8 @@ class Logger:
|
||||
center_content: bool = False,
|
||||
custom_title: str = None,
|
||||
custom_color: DialogCustomColor = None,
|
||||
end: str = "\n",
|
||||
padding_top: int = 1,
|
||||
padding_bottom: int = 1,
|
||||
) -> None:
|
||||
dialog_color = Logger._get_dialog_color(title, custom_color)
|
||||
dialog_title = Logger._get_dialog_title(title, custom_title)
|
||||
@@ -99,10 +100,12 @@ class Logger:
|
||||
top = Logger._format_top_border(dialog_color)
|
||||
bottom = Logger._format_bottom_border()
|
||||
|
||||
print("\n" * padding_top)
|
||||
print(
|
||||
f"{top}{dialog_title_formatted}{dialog_content}{bottom}",
|
||||
end=end,
|
||||
end="",
|
||||
)
|
||||
print("\n" * padding_bottom)
|
||||
|
||||
@staticmethod
|
||||
def _get_dialog_title(title: DialogType, custom_title: str = None) -> str:
|
||||
@@ -120,18 +123,12 @@ class Logger:
|
||||
|
||||
@staticmethod
|
||||
def _format_top_border(color: str) -> str:
|
||||
return textwrap.dedent(
|
||||
f"""
|
||||
{color}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
"""
|
||||
)[1:-1]
|
||||
return f"{color}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
||||
|
||||
@staticmethod
|
||||
def _format_bottom_border() -> str:
|
||||
return textwrap.dedent(
|
||||
f"""
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
{RESET_FORMAT}"""
|
||||
return (
|
||||
f"\n┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛{RESET_FORMAT}"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user