From 326e344d1ef0f3a30ec5a7ab6750a70a7af18ee4 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Fri, 25 Apr 2025 15:53:17 -0500 Subject: [PATCH 1/3] move `gui_enabled` to Utils --- CommonClient.py | 5 +---- Utils.py | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index b622fb939bec..95b78d3846ec 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -24,7 +24,7 @@ from MultiServer import CommandProcessor from NetUtils import (Endpoint, decode, NetworkItem, encode, JSONtoTextParser, ClientStatus, Permission, NetworkSlot, RawJSONtoTextParser, add_json_text, add_json_location, add_json_item, JSONTypes, HintStatus, SlotType) -from Utils import Version, stream_input, async_start +from Utils import gui_enabled, Version, stream_input, async_start from worlds import network_data_package, AutoWorldRegister import os import ssl @@ -35,9 +35,6 @@ logger = logging.getLogger("Client") -# without terminal, we have to use gui mode -gui_enabled = not sys.stdout or "--nogui" not in sys.argv - @Utils.cache_argsless def get_ssl_context(): diff --git a/Utils.py b/Utils.py index 46a0d106ef85..eb232fdc0d5e 100644 --- a/Utils.py +++ b/Utils.py @@ -830,6 +830,10 @@ def run(*args: str): root.update() +# without terminal, we have to use gui mode +gui_enabled = not sys.stdout or "--nogui" not in sys.argv + + def title_sorted(data: typing.Iterable, key=None, ignore: typing.AbstractSet[str] = frozenset(("a", "the"))): """Sorts a sequence of text ignoring typical articles like "a" or "the" in the beginning.""" def sorter(element: Union[str, Dict[str, Any]]) -> str: From d49a132c626d21966c83ac30a0f31a0ab36af54e Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Fri, 25 Apr 2025 15:56:16 -0500 Subject: [PATCH 2/3] docstring --- Utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utils.py b/Utils.py index eb232fdc0d5e..04524c7dd7f4 100644 --- a/Utils.py +++ b/Utils.py @@ -830,9 +830,8 @@ def run(*args: str): root.update() -# without terminal, we have to use gui mode gui_enabled = not sys.stdout or "--nogui" not in sys.argv - +"""Checks if the user wanted no GUI mode and has a terminal to use it with.""" def title_sorted(data: typing.Iterable, key=None, ignore: typing.AbstractSet[str] = frozenset(("a", "the"))): """Sorts a sequence of text ignoring typical articles like "a" or "the" in the beginning.""" From c2f055795199d02403b509d2aec4ff041f691a55 Mon Sep 17 00:00:00 2001 From: Katelyn Gigante Date: Sun, 5 Oct 2025 15:37:53 +1100 Subject: [PATCH 3/3] If a user specified no-gui, don't use GUI messageboxes --- Utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Utils.py b/Utils.py index 6d2461d42866..75d42b549b59 100644 --- a/Utils.py +++ b/Utils.py @@ -850,6 +850,13 @@ def open_directory(title: str, suggest: str = "") -> typing.Optional[str]: def messagebox(title: str, text: str, error: bool = False) -> None: + if not gui_enabled: + if error: + logging.error(f"{title}: {text}") + else: + logging.info(f"{title}: {text}") + return + if is_kivy_running(): from kvui import MessageBox MessageBox(title, text, error).open()