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