restart ks on error, do not warn on ks restart when changing options
i don't see it necessary ks can be restarted while printing it will generate a bit of load but shouldn't be a problem, i've done it too many times at this point
This commit is contained in:
parent
fe06b38128
commit
741d9b654d
@ -223,7 +223,7 @@ class KlipperScreenConfig:
|
|||||||
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}]}},
|
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}]}},
|
||||||
{"theme": {
|
{"theme": {
|
||||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||||
"value": "z-bolt", "callback": screen.restart_warning, "options": [
|
"value": "z-bolt", "callback": screen.restart_ks, "options": [
|
||||||
{"name": "Z-bolt" + " " + _("(default)"), "value": "z-bolt"}]}},
|
{"name": "Z-bolt" + " " + _("(default)"), "value": "z-bolt"}]}},
|
||||||
{"print_estimate_method": {
|
{"print_estimate_method": {
|
||||||
"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
||||||
@ -243,7 +243,7 @@ class KlipperScreenConfig:
|
|||||||
"value": "True", "callback": screen.toggle_macro_shortcut}},
|
"value": "True", "callback": screen.toggle_macro_shortcut}},
|
||||||
{"font_size": {
|
{"font_size": {
|
||||||
"section": "main", "name": _("Font Size"), "type": "dropdown",
|
"section": "main", "name": _("Font Size"), "type": "dropdown",
|
||||||
"value": "medium", "callback": screen.restart_warning, "options": [
|
"value": "medium", "callback": screen.restart_ks, "options": [
|
||||||
{"name": _("Small"), "value": "small"},
|
{"name": _("Small"), "value": "small"},
|
||||||
{"name": _("Medium") + " " + _("(default)"), "value": "medium"},
|
{"name": _("Medium") + " " + _("(default)"), "value": "medium"},
|
||||||
{"name": _("Large"), "value": "large"},
|
{"name": _("Large"), "value": "large"},
|
||||||
|
39
screen.py
39
screen.py
@ -8,7 +8,7 @@ import subprocess
|
|||||||
import pathlib
|
import pathlib
|
||||||
import traceback # noqa
|
import traceback # noqa
|
||||||
import locale
|
import locale
|
||||||
|
import sys
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
@ -16,7 +16,6 @@ from gi.repository import Gtk, Gdk, GLib, Pango
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from jinja2 import Environment
|
from jinja2 import Environment
|
||||||
from signal import SIGTERM
|
from signal import SIGTERM
|
||||||
from sys import exit
|
|
||||||
|
|
||||||
from ks_includes import functions
|
from ks_includes import functions
|
||||||
from ks_includes.KlippyWebsocket import KlippyWebsocket
|
from ks_includes.KlippyWebsocket import KlippyWebsocket
|
||||||
@ -358,7 +357,9 @@ class KlipperScreen(Gtk.Window):
|
|||||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
scroll.add(message)
|
scroll.add(message)
|
||||||
|
|
||||||
help_notice = Gtk.Label(label="Provide /tmp/KlipperScreen.log when asking for help.\n")
|
help_msg = _("Provide /tmp/KlipperScreen.log when asking for help.\n")
|
||||||
|
help_msg += _("KlipperScreen will be restarted")
|
||||||
|
help_notice = Gtk.Label(label=help_msg)
|
||||||
help_notice.set_line_wrap(True)
|
help_notice.set_line_wrap(True)
|
||||||
|
|
||||||
grid = Gtk.Grid()
|
grid = Gtk.Grid()
|
||||||
@ -375,32 +376,12 @@ class KlipperScreen(Gtk.Window):
|
|||||||
|
|
||||||
def error_modal_response(self, dialog, response_id):
|
def error_modal_response(self, dialog, response_id):
|
||||||
self.gtk.remove_dialog(dialog)
|
self.gtk.remove_dialog(dialog)
|
||||||
self.reload_panels()
|
self.restart_ks()
|
||||||
|
|
||||||
def restart_warning(self, value):
|
def restart_ks(self, *args):
|
||||||
logging.debug(f"Showing restart warning because: {value}")
|
logging.debug(f"Restarting {sys.executable} {' '.join(sys.argv)}")
|
||||||
|
os.execv(sys.executable, ['python'] + sys.argv)
|
||||||
buttons = [
|
self._ws.send_method("machine.services.restart", {"service": "KlipperScreen"}) # Fallback
|
||||||
{"name": _("Cancel"), "response": Gtk.ResponseType.CANCEL},
|
|
||||||
{"name": _("Restart"), "response": Gtk.ResponseType.OK}
|
|
||||||
]
|
|
||||||
|
|
||||||
label = Gtk.Label()
|
|
||||||
label.set_markup(_("To apply %s KlipperScreen needs to be restarted") % value)
|
|
||||||
label.set_hexpand(True)
|
|
||||||
label.set_halign(Gtk.Align.CENTER)
|
|
||||||
label.set_vexpand(True)
|
|
||||||
label.set_valign(Gtk.Align.CENTER)
|
|
||||||
label.set_line_wrap(True)
|
|
||||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
|
||||||
|
|
||||||
self.gtk.Dialog(self, buttons, label, self.restart_ks)
|
|
||||||
|
|
||||||
def restart_ks(self, dialog, response_id):
|
|
||||||
self.gtk.remove_dialog(dialog)
|
|
||||||
if response_id == Gtk.ResponseType.OK:
|
|
||||||
logging.debug("Restarting")
|
|
||||||
self._ws.send_method("machine.services.restart", {"service": "KlipperScreen"})
|
|
||||||
|
|
||||||
def init_style(self):
|
def init_style(self):
|
||||||
css_data = pathlib.Path(os.path.join(klipperscreendir, "styles", "base.css")).read_text()
|
css_data = pathlib.Path(os.path.join(klipperscreendir, "styles", "base.css")).read_text()
|
||||||
@ -1016,4 +997,4 @@ if __name__ == "__main__":
|
|||||||
main()
|
main()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.exception(f"Fatal error in main loop:\n{ex}")
|
logging.exception(f"Fatal error in main loop:\n{ex}")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user