Update code style
This commit is contained in:
1 parent
98cb3ef743
commit
70d8315539
35 files changed
+735
-736
No files matched your search
+23
-23
@@ -1,35 +1,35 @@
|
||||
class KlippyGcodes:
|
||||
|
||||
HOME = "G28"
|
||||
HOME_X = "G28 X"
|
||||
HOME_Y = "G28 Y"
|
||||
HOME_Z = "G28 Z"
|
||||
HOME = "G28"
|
||||
HOME_X = "G28 X"
|
||||
HOME_Y = "G28 Y"
|
||||
HOME_Z = "G28 Z"
|
||||
|
||||
MOVE = "G1"
|
||||
MOVE_ABSOLUTE = "G90"
|
||||
MOVE_RELATIVE = "G91"
|
||||
MOVE = "G1"
|
||||
MOVE_ABSOLUTE = "G90"
|
||||
MOVE_RELATIVE = "G91"
|
||||
|
||||
EXTRUDE_ABS = "M82"
|
||||
EXTRUDE_REL = "M83"
|
||||
EXTRUDE_ABS = "M82"
|
||||
EXTRUDE_REL = "M83"
|
||||
|
||||
SET_EXT_TEMP = "M104"
|
||||
MAX_EXT_TEMP = 450
|
||||
SET_EXT_TEMP = "M104"
|
||||
MAX_EXT_TEMP = 450
|
||||
|
||||
SET_BED_TEMP = "M140"
|
||||
MAX_BED_TEMP = 150
|
||||
SET_BED_TEMP = "M140"
|
||||
MAX_BED_TEMP = 150
|
||||
|
||||
SET_EXT_FACTOR = "M221"
|
||||
SET_FAN_SPEED = "M106"
|
||||
SET_SPD_FACTOR = "M220"
|
||||
SET_EXT_FACTOR = "M221"
|
||||
SET_FAN_SPEED = "M106"
|
||||
SET_SPD_FACTOR = "M220"
|
||||
|
||||
PROBE_CALIBRATE = "PROBE_CALIBRATE"
|
||||
PROBE_MOVE = "TESTZ Z="
|
||||
PROBE_ABORT = "ABORT"
|
||||
PROBE_ACCEPT = "ACCEPT"
|
||||
PROBE_MOVE = "TESTZ Z="
|
||||
PROBE_ABORT = "ABORT"
|
||||
PROBE_ACCEPT = "ACCEPT"
|
||||
|
||||
SAVE_CONFIG = "SAVE_CONFIG"
|
||||
RESTART = "RESTART"
|
||||
FIRMWARE_RESTART= "FIRMWARE_RESTART"
|
||||
SAVE_CONFIG = "SAVE_CONFIG"
|
||||
RESTART = "RESTART"
|
||||
FIRMWARE_RESTART = "FIRMWARE_RESTART"
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -46,7 +46,7 @@ class KlippyGcodes:
|
||||
|
||||
@staticmethod
|
||||
def set_fan_speed(speed):
|
||||
speed = str( int(float(int(speed) % 101)/100*255) )
|
||||
speed = str(int(float(int(speed) % 101)/100*255))
|
||||
return "%s S%s" % (KlippyGcodes.SET_FAN_SPEED, speed)
|
||||
|
||||
@staticmethod
|
||||
|
||||
+23
-24
@@ -62,10 +62,10 @@ class KlippyGtk:
|
||||
return (self.width - self.get_action_bar_width()) * self.keyboard_ratio
|
||||
|
||||
def Label(self, label, style=None):
|
||||
l = Gtk.Label(label)
|
||||
if style != None and style != False:
|
||||
l.get_style_context().add_class(style)
|
||||
return l
|
||||
la = Gtk.Label(label)
|
||||
if style is not None and style is not False:
|
||||
la.get_style_context().add_class(style)
|
||||
return la
|
||||
|
||||
def ImageLabel(self, image_name, text, size=20, style=False, width_scale=.32, height_scale=.32):
|
||||
box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||
@@ -80,7 +80,7 @@ class KlippyGtk:
|
||||
box1.add(image)
|
||||
box1.add(label)
|
||||
|
||||
if style != False:
|
||||
if style is not False:
|
||||
ctx = box1.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
@@ -94,31 +94,31 @@ class KlippyGtk:
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
def ImageFromFile(self, filename, style=False, width_scale=1, height_scale=1):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename,
|
||||
int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filename, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
def PixbufFromFile(self, filename, style=False, width_scale=1, height_scale=1):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, int(round(self.img_width * width_scale)),
|
||||
int(round(self.img_height * height_scale)), True)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filename, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return pixbuf
|
||||
|
||||
def PixbufFromHttp(self, resource, style=False, width_scale=1, height_scale=1):
|
||||
response = self.screen.apiclient.get_thumbnail_stream(resource)
|
||||
if response == False:
|
||||
if response is False:
|
||||
return None
|
||||
stream = Gio.MemoryInputStream.new_from_data(response, None)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(round(self.img_width * width_scale)),
|
||||
int(round(self.img_height * height_scale)), True)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
|
||||
stream, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return pixbuf
|
||||
|
||||
def ProgressBar(self, style=False):
|
||||
bar = Gtk.ProgressBar()
|
||||
|
||||
if style != False:
|
||||
if style is not False:
|
||||
ctx = bar.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
@@ -131,13 +131,13 @@ class KlippyGtk:
|
||||
b.set_can_focus(False)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != None:
|
||||
if style is not None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
def ButtonImage(self, image_name, label=None, style=None, width_scale=1.38, height_scale=1.38,
|
||||
position=Gtk.PositionType.TOP, word_wrap=True):
|
||||
position=Gtk.PositionType.TOP, word_wrap=True):
|
||||
filename = "%s/styles/%s/images/%s.svg" % (klipperscreendir, self.theme, str(image_name))
|
||||
if not os.path.exists(filename):
|
||||
logging.error("Unable to find button image (theme, image): (%s, %s)" % (self.theme, str(image_name)))
|
||||
@@ -168,10 +168,10 @@ class KlippyGtk:
|
||||
child = b.get_children()[0].get_children()[0].get_children()[1]
|
||||
child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
child.set_line_wrap(True)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if style != None:
|
||||
if style is not None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
@@ -222,7 +222,6 @@ class KlippyGtk:
|
||||
img = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
b = Gtk.ToggleButton(label=label)
|
||||
#b.props.relief = Gtk.RELIEF_NONE
|
||||
b.set_image(img)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
@@ -231,7 +230,7 @@ class KlippyGtk:
|
||||
b.set_always_show_image(True)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != False:
|
||||
if style is not False:
|
||||
ctx = b.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
@@ -241,7 +240,7 @@ class KlippyGtk:
|
||||
g = Gtk.Grid()
|
||||
g.set_row_homogeneous(True)
|
||||
g.set_column_homogeneous(True)
|
||||
if width != None and height != None:
|
||||
if width is not None and height is not None:
|
||||
g.set_size_request(width, height)
|
||||
return g
|
||||
|
||||
@@ -263,12 +262,12 @@ class KlippyGtk:
|
||||
def formatTimeString(self, seconds):
|
||||
time = int(seconds)
|
||||
text = ""
|
||||
if int(time/3600) !=0:
|
||||
if int(time/3600) != 0:
|
||||
text += str(int(time/3600))+"h "
|
||||
text += str(int(time/60)%60)+"m "+str(time%60)+"s"
|
||||
text += str(int(time/60) % 60)+"m "+str(time % 60)+"s"
|
||||
return text
|
||||
|
||||
def formatTemperatureString(self, temp, target):
|
||||
if (target > temp-2 and target < temp+2) or round(target,0) == 0:
|
||||
return str(round(temp,1)) + "°C" #°C →"
|
||||
if (target > temp-2 and target < temp+2) or round(target, 0) == 0:
|
||||
return str(round(temp, 1)) + "°C" # °C →"
|
||||
return str(round(temp)) + " → " + str(round(target)) + "°C"
|
||||
@@ -13,7 +13,7 @@ class KlippyRest:
|
||||
|
||||
def get_oneshot_token(self):
|
||||
r = self.send_request("access/oneshot_token")
|
||||
if r == False:
|
||||
if r is False:
|
||||
return False
|
||||
return r['result']
|
||||
|
||||
@@ -31,18 +31,18 @@ class KlippyRest:
|
||||
def send_request(self, method):
|
||||
url = "http://%s:%s/%s" % (self.ip, self.port, method)
|
||||
logging.debug("Sending request to %s" % url)
|
||||
headers = {} if self.api_key == False else {"x-api-key":self.api_key}
|
||||
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
|
||||
try:
|
||||
r = requests.get(url, headers=headers)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
if r.status_code != 200:
|
||||
return False
|
||||
|
||||
#TODO: Try/except
|
||||
# TODO: Try/except
|
||||
try:
|
||||
data = json.loads(r.content)
|
||||
except:
|
||||
except Exception:
|
||||
logging.exception("Unable to parse response from moonraker:\n %s" % r.content)
|
||||
return False
|
||||
|
||||
|
||||
@@ -14,12 +14,10 @@ gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
|
||||
#f = open("/home/pi/.moonraker_api_key", "r")
|
||||
api_key = "" #f.readline()
|
||||
#f.close()
|
||||
api_key = ""
|
||||
|
||||
api = {
|
||||
"printer_info": {
|
||||
"printer_info": {
|
||||
"url": "/printer/info",
|
||||
"method": "get_printer_info"
|
||||
},
|
||||
@@ -48,33 +46,32 @@ class KlippyWebsocket(threading.Thread):
|
||||
|
||||
def initial_connect(self):
|
||||
# Enable a timeout so that way if moonraker is not running, it will attempt to reconnect
|
||||
if self.timeout == None:
|
||||
if self.timeout is None:
|
||||
self.timeout = GLib.timeout_add(500, self.reconnect)
|
||||
self.connect()
|
||||
|
||||
def connect (self):
|
||||
def connect(self):
|
||||
def ws_on_close(ws, a=None, b=None):
|
||||
self.on_close(ws)
|
||||
|
||||
def ws_on_error(ws, msg):
|
||||
self.on_error(ws, msg)
|
||||
|
||||
def ws_on_message(ws, msg):
|
||||
self.on_message(ws, msg)
|
||||
|
||||
def ws_on_open(ws):
|
||||
self.on_open(ws)
|
||||
|
||||
try:
|
||||
token = self._screen.apiclient.get_oneshot_token()
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Unable to get oneshot token")
|
||||
return False
|
||||
|
||||
self.ws_url = "ws://%s/websocket?token=%s" % (self._url, token)
|
||||
self.ws = websocket.WebSocketApp(self.ws_url,
|
||||
on_close = ws_on_close,
|
||||
on_error = ws_on_error,
|
||||
on_message = ws_on_message,
|
||||
on_open = ws_on_open
|
||||
)
|
||||
self.ws = websocket.WebSocketApp(
|
||||
self.ws_url, on_close=ws_on_close, on_error=ws_on_error, on_message=ws_on_message, on_open=ws_on_open)
|
||||
|
||||
self._wst = threading.Thread(target=self.ws.run_forever)
|
||||
self._wst.daemon = True
|
||||
@@ -115,11 +112,11 @@ class KlippyWebsocket(threading.Thread):
|
||||
return
|
||||
|
||||
def send_method(self, method, params={}, callback=None, *args):
|
||||
if self.is_connected() == False:
|
||||
if self.is_connected() is False:
|
||||
return False
|
||||
|
||||
self._req_id += 1
|
||||
if callback != None:
|
||||
if callback is not None:
|
||||
self.callback_table[self._req_id] = [callback, method, params, [*args]]
|
||||
|
||||
data = {
|
||||
@@ -135,7 +132,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
logging.info("Moonraker Websocket Open")
|
||||
logging.info("Self.connected = %s" % self.is_connected())
|
||||
self.connected = True
|
||||
if self.timeout != None:
|
||||
if self.timeout is not None:
|
||||
GLib.source_remove(self.timeout)
|
||||
self.timeout = None
|
||||
if "on_connect" in self._callback:
|
||||
@@ -145,18 +142,18 @@ class KlippyWebsocket(threading.Thread):
|
||||
)
|
||||
|
||||
def on_close(self, ws):
|
||||
if self.is_connected() == False:
|
||||
if self.is_connected() is False:
|
||||
logging.debug("Connection already closed")
|
||||
return
|
||||
|
||||
if self.closing == True:
|
||||
if self.closing is True:
|
||||
logging.debug("Closing websocket")
|
||||
self.ws.stop()
|
||||
return
|
||||
|
||||
logging.info("Moonraker Websocket Closed")
|
||||
self.connected = False
|
||||
if self.timeout == None:
|
||||
if self.timeout is None:
|
||||
self.timeout = GLib.timeout_add(500, self.reconnect)
|
||||
|
||||
if "on_close" in self._callback:
|
||||
@@ -179,7 +176,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
logging.debug("Websocket error: %s" % error)
|
||||
|
||||
class MoonrakerApi:
|
||||
def __init__ (self, ws):
|
||||
def __init__(self, ws):
|
||||
self._ws = ws
|
||||
|
||||
def emergency_stop(self):
|
||||
@@ -207,7 +204,6 @@ class MoonrakerApi:
|
||||
)
|
||||
|
||||
def get_file_list(self, callback=None, *args):
|
||||
#Commenting this log for being too noisy
|
||||
logging.debug("Sending server.files.list")
|
||||
return self._ws.send_method(
|
||||
"server.files.list",
|
||||
@@ -217,7 +213,6 @@ class MoonrakerApi:
|
||||
)
|
||||
|
||||
def get_file_metadata(self, filename, callback=None, *args):
|
||||
#logging.debug("Sending server.files.metadata: %s", filename)
|
||||
return self._ws.send_method(
|
||||
"server.files.metadata",
|
||||
{"filename": filename},
|
||||
@@ -300,13 +295,14 @@ class MoonrakerApi:
|
||||
*args
|
||||
)
|
||||
else:
|
||||
logging.debug("Sending printer.gcode.script: %s",
|
||||
KlippyGcodes.set_ext_temp(target, heater.replace("tool","")))
|
||||
#TODO: Add max/min limits
|
||||
logging.debug(
|
||||
"Sending printer.gcode.script: %s",
|
||||
KlippyGcodes.set_ext_temp(target, heater.replace("tool", "")))
|
||||
# TODO: Add max/min limits
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{
|
||||
"script": KlippyGcodes.set_ext_temp(target, heater.replace("tool",""))
|
||||
"script": KlippyGcodes.set_ext_temp(target, heater.replace("tool", ""))
|
||||
},
|
||||
callback,
|
||||
*args
|
||||
|
||||
+66
-63
@@ -11,12 +11,12 @@ from io import StringIO
|
||||
from os import path
|
||||
|
||||
SCREEN_BLANKING_OPTIONS = [
|
||||
"300", #5 Minutes
|
||||
"900", #15 Minutes
|
||||
"1800", #30 Minutes
|
||||
"3600", #1 Hour
|
||||
"7200", #2 Hours
|
||||
"14400", #4 Hours
|
||||
"300", # 5 Minutes
|
||||
"900", # 15 Minutes
|
||||
"1800", # 30 Minutes
|
||||
"3600", # 1 Hour
|
||||
"7200", # 2 Hours
|
||||
"14400", # 4 Hours
|
||||
]
|
||||
|
||||
class ConfigError(Exception):
|
||||
@@ -44,9 +44,9 @@ class KlipperScreenConfig:
|
||||
|
||||
includes = [i[8:] for i in self.defined_config.sections() if i.startswith("include ")]
|
||||
for include in includes:
|
||||
self._include_config("/".join(self.config_path.split("/")[:-1]),include)
|
||||
self._include_config("/".join(self.config_path.split("/")[:-1]), include)
|
||||
|
||||
for i in ['menu __main','menu __print','menu __splashscreen','preheat']:
|
||||
for i in ['menu __main', 'menu __print', 'menu __splashscreen', 'preheat']:
|
||||
for j in self.defined_config.sections():
|
||||
if j.startswith(i):
|
||||
for k in list(self.config.sections()):
|
||||
@@ -56,12 +56,12 @@ class KlipperScreenConfig:
|
||||
|
||||
self.log_config(self.defined_config)
|
||||
self.config.read_string(user_def)
|
||||
if saved_def != None:
|
||||
if saved_def is not None:
|
||||
self.config.read_string(saved_def)
|
||||
logging.info("====== Saved Def ======\n%s\n=======================" % saved_def)
|
||||
except KeyError:
|
||||
raise ConfigError(f"Error reading config: {self.config_path}")
|
||||
except:
|
||||
except Exception:
|
||||
logging.exception("Unknown error with config")
|
||||
|
||||
printers = sorted([i for i in self.config.sections() if i.startswith("printer ")])
|
||||
@@ -92,10 +92,10 @@ class KlipperScreenConfig:
|
||||
logging.debug("Configured printers: %s" % json.dumps(conf_printers_debug, indent=2))
|
||||
|
||||
lang = self.get_main_config_option("language", None)
|
||||
lang = [lang] if lang != None and lang != "default" else None
|
||||
lang = [lang] if lang is not None and lang != "default" else None
|
||||
logging.info("Detected language: %s" % lang)
|
||||
self.lang = gettext.translation('KlipperScreen', localedir='ks_includes/locales', languages=lang,
|
||||
fallback=True)
|
||||
fallback=True)
|
||||
|
||||
self._create_configurable_options(screen)
|
||||
|
||||
@@ -108,55 +108,57 @@ class KlipperScreenConfig:
|
||||
{"invert_y": {"section": "main", "name": _("Invert Y"), "type": "binary", "value": "False"}},
|
||||
{"invert_z": {"section": "main", "name": _("Invert Z"), "type": "binary", "value": "False"}},
|
||||
{"language": {"section": "main", "name": _("Language"), "type": "dropdown", "value": "system_lang",
|
||||
"callback": screen.restart_warning, "options":[
|
||||
{"name": "System Default", "value": "system_lang"}
|
||||
"callback": screen.restart_warning, "options": [
|
||||
{"name": "System Default", "value": "system_lang"}
|
||||
]}},
|
||||
{"move_speed": {"section": "main", "name": _("Move Speed (mm/s)"), "type": "scale", "value": "20",
|
||||
"range": [5,100], "step": 1
|
||||
}},
|
||||
{"move_speed": {
|
||||
"section": "main", "name": _("Move Speed (mm/s)"), "type": "scale", "value": "20",
|
||||
"range": [5, 100], "step": 1}},
|
||||
{"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}},
|
||||
{"print_estimate_method": {"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
||||
"value": "file","options":[
|
||||
{"print_estimate_method": {
|
||||
"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
||||
"value": "file", "options": [
|
||||
{"name": _("File Estimation (default)"), "value": "file"},
|
||||
{"name": _("Duration Only"), "value": "duration"},
|
||||
{"name": _("Filament Used"), "value": "filament"},
|
||||
{"name": _("Slicer"), "value": "slicer"}
|
||||
]}},
|
||||
{"screen_blanking": {"section": "main", "name": _("Screen Power Off Time"), "type": "dropdown",
|
||||
"value": "3600", "callback": screen.set_screenblanking_timeout, "options":[
|
||||
{"name": _("Off"), "value": "off"}
|
||||
]}},
|
||||
{"theme": {"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"value": "z-bolt", "callback": screen.restart_warning, "options":[
|
||||
{"name": _("Slicer"), "value": "slicer"}]}},
|
||||
{"screen_blanking": {
|
||||
"section": "main", "name": _("Screen Power Off Time"), "type": "dropdown",
|
||||
"value": "3600", "callback": screen.set_screenblanking_timeout, "options": [
|
||||
{"name": _("Off"), "value": "off"}]
|
||||
}},
|
||||
{"theme": {
|
||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"value": "z-bolt", "callback": screen.restart_warning, "options": [
|
||||
{"name": _("Z-bolt (default)"), "value": "z-bolt"},
|
||||
{"name": _("Colorized"), "value": "colorized"}
|
||||
]}},
|
||||
{"name": _("Colorized"), "value": "colorized"}]}},
|
||||
{"24htime": {"section": "main", "name": _("24 Hour Time"), "type": "binary", "value": "True"}},
|
||||
{"side_macro_shortcut": {"section": "main", "name": _("Macro shortcut on sidebar"), "type": "binary",
|
||||
{"side_macro_shortcut": {
|
||||
"section": "main", "name": _("Macro shortcut on sidebar"), "type": "binary",
|
||||
"value": "True", "callback": screen.toggle_macro_shortcut}},
|
||||
{"font_size": {"section": "main", "name": _("Font Size"), "type": "dropdown",
|
||||
"value": "medium", "callback": screen.restart_warning, "options":[
|
||||
{"font_size": {
|
||||
"section": "main", "name": _("Font Size"), "type": "dropdown",
|
||||
"value": "medium", "callback": screen.restart_warning, "options": [
|
||||
{"name": _("Small"), "value": "small"},
|
||||
{"name": _("Medium (default)"), "value": "medium"},
|
||||
{"name": _("Large"), "value": "large"},
|
||||
]}},
|
||||
#{"": {"section": "main", "name": _(""), "type": ""}}
|
||||
{"name": _("Large"), "value": "large"}]}},
|
||||
# {"": {"section": "main", "name": _(""), "type": ""}}
|
||||
]
|
||||
|
||||
lang_path = os.path.join(os.getcwd(), 'ks_includes/locales')
|
||||
langs = [d for d in os.listdir(lang_path) if not os.path.isfile(os.path.join(lang_path,d))]
|
||||
langs = [d for d in os.listdir(lang_path) if not os.path.isfile(os.path.join(lang_path, d))]
|
||||
langs.sort()
|
||||
lang_opt = self.configurable_options[3]['language']['options']
|
||||
|
||||
for l in langs:
|
||||
lang_opt.append({"name": l, "value": l})
|
||||
for lang in langs:
|
||||
lang_opt.append({"name": lang, "value": lang})
|
||||
|
||||
index = self.configurable_options.index(
|
||||
[i for i in self.configurable_options if list(i)[0]=="screen_blanking"][0])
|
||||
[i for i in self.configurable_options if list(i)[0] == "screen_blanking"][0])
|
||||
for num in SCREEN_BLANKING_OPTIONS:
|
||||
hour = int(int(num)/3600)
|
||||
if hour > 0:
|
||||
name = str(hour) + " " + _n("hour","hours", hour)
|
||||
name = str(hour) + " " + _n("hour", "hours", hour)
|
||||
else:
|
||||
name = str(int(int(num)/60)) + " " + _("minutes")
|
||||
self.configurable_options[index]['screen_blanking']['options'].append({
|
||||
@@ -183,7 +185,7 @@ class KlipperScreenConfig:
|
||||
logging.info("Config Error: Directory %s does not exist" % parent_dir)
|
||||
return
|
||||
files = os.listdir(parent_dir)
|
||||
regex = "^%s$" % file.replace('*','.*')
|
||||
regex = "^%s$" % file.replace('*', '.*')
|
||||
for file in files:
|
||||
if re.match(regex, file):
|
||||
parse_files.append(os.path.join(parent_dir, file))
|
||||
@@ -211,17 +213,17 @@ class KlipperScreenConfig:
|
||||
return [None, None]
|
||||
with open(config_path) as file:
|
||||
for line in file:
|
||||
line = line.replace('\n','')
|
||||
line = line.replace('\n', '')
|
||||
if line == self.do_not_edit_line:
|
||||
found_saved = True
|
||||
saved_def = []
|
||||
continue
|
||||
if found_saved == False:
|
||||
user_def.append(line.replace('\n',''))
|
||||
if found_saved is False:
|
||||
user_def.append(line.replace('\n', ''))
|
||||
else:
|
||||
if line.startswith(self.do_not_edit_prefix):
|
||||
saved_def.append(line[(len(self.do_not_edit_prefix)+1):])
|
||||
return ["\n".join(user_def), None if saved_def == None else "\n".join(saved_def)]
|
||||
return ["\n".join(user_def), None if saved_def is None else "\n".join(saved_def)]
|
||||
|
||||
def get_config_file_location(self, file):
|
||||
logging.info("Passed config file: %s" % file)
|
||||
@@ -305,23 +307,23 @@ class KlipperScreenConfig:
|
||||
opt = item[name]
|
||||
curval = self.config[opt['section']].get(name)
|
||||
if curval != opt["value"] or (
|
||||
self.defined_config != None and opt['section'] in self.defined_config.sections() and
|
||||
self.defined_config[opt['section']].get(name,None) not in (None, curval)):
|
||||
self.defined_config is not None and opt['section'] in self.defined_config.sections() and
|
||||
self.defined_config[opt['section']].get(name, None) not in (None, curval)):
|
||||
if opt['section'] not in save_config.sections():
|
||||
save_config.add_section(opt['section'])
|
||||
save_config.set(opt['section'], name, str(curval))
|
||||
|
||||
macro_sections = [i for i in self.config.sections() if i.startswith("displayed_macros")]
|
||||
for macro_sec in macro_sections:
|
||||
for item in self.config.options(macro_sec):
|
||||
value = self.config[macro_sec].getboolean(item, fallback=True)
|
||||
if value == False or (self.defined_config != None and
|
||||
macro_sec in self.defined_config.sections() and
|
||||
self.defined_config[macro_sec].getboolean(item, fallback=True) == False and
|
||||
self.defined_config[macro_sec].getboolean(item, fallback=True) != value):
|
||||
if macro_sec not in save_config.sections():
|
||||
save_config.add_section(macro_sec)
|
||||
save_config.set(macro_sec, item, str(value))
|
||||
for item in self.config.options(macro_sec):
|
||||
value = self.config[macro_sec].getboolean(item, fallback=True)
|
||||
if value is False or (self.defined_config is not None and
|
||||
macro_sec in self.defined_config.sections() and
|
||||
self.defined_config[macro_sec].getboolean(item, fallback=True) is False and
|
||||
self.defined_config[macro_sec].getboolean(item, fallback=True) != value):
|
||||
if macro_sec not in save_config.sections():
|
||||
save_config.add_section(macro_sec)
|
||||
save_config.set(macro_sec, item, str(value))
|
||||
|
||||
save_output = self._build_config_string(save_config).split("\n")
|
||||
for i in range(len(save_output)):
|
||||
@@ -333,24 +335,25 @@ class KlipperScreenConfig:
|
||||
else:
|
||||
user_def, saved_def = self.separate_saved_config(self.config_path)
|
||||
|
||||
extra_lb = "\n" if saved_def != None else ""
|
||||
contents = "%s\n%s%s\n%s\n%s\n%s\n" % (user_def, self.do_not_edit_line, extra_lb,
|
||||
self.do_not_edit_prefix, "\n".join(save_output), self.do_not_edit_prefix)
|
||||
extra_lb = "\n" if saved_def is not None else ""
|
||||
contents = "%s\n%s%s\n%s\n%s\n%s\n" % (
|
||||
user_def, self.do_not_edit_line, extra_lb, self.do_not_edit_prefix, "\n".join(save_output),
|
||||
self.do_not_edit_prefix)
|
||||
|
||||
if self.config_path != self.default_config_path:
|
||||
path = self.config_path
|
||||
else:
|
||||
path = os.path.expanduser("~/")
|
||||
if os.path.exists(path+"klipper_config/"):
|
||||
path = path + "klipper_config/KlipperScreen.conf"
|
||||
path = path + "klipper_config/KlipperScreen.conf"
|
||||
else:
|
||||
path = path + "KlipperScreen.conf"
|
||||
path = path + "KlipperScreen.conf"
|
||||
|
||||
try:
|
||||
file = open(path, 'w')
|
||||
file.write(contents)
|
||||
file.close()
|
||||
except:
|
||||
except Exception:
|
||||
logging.error("Error writing configuration file in %s" % path)
|
||||
|
||||
def set(self, section, name, value):
|
||||
@@ -390,7 +393,7 @@ class KlipperScreenConfig:
|
||||
|
||||
try:
|
||||
item["params"] = json.loads(cfg.get("params", "{}"))
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Unable to parse parameters for [%s]" % name)
|
||||
item["params"] = {}
|
||||
|
||||
|
||||
+10
-10
@@ -34,7 +34,7 @@ class KlippyFiles():
|
||||
|
||||
def _callback(self, result, method, params):
|
||||
if method == "server.files.list":
|
||||
if "result" in result and isinstance(result['result'],list):
|
||||
if "result" in result and isinstance(result['result'], list):
|
||||
newfiles = []
|
||||
deletedfiles = self.filelist.copy()
|
||||
for item in result['result']:
|
||||
@@ -67,7 +67,7 @@ class KlippyFiles():
|
||||
self.run_callbacks(newfiles)
|
||||
elif method == "server.files.metadata":
|
||||
if "error" in result.keys():
|
||||
logging.debug("Error in getting metadata for %s. Retrying in 6 seconds" %(params['filename']))
|
||||
logging.debug("Error in getting metadata for %s. Retrying in 6 seconds" % (params['filename']))
|
||||
return
|
||||
|
||||
for x in result['result']:
|
||||
@@ -77,14 +77,14 @@ class KlippyFiles():
|
||||
|
||||
for thumbnail in self.files[params['filename']]['thumbnails']:
|
||||
thumbnail['local'] = False
|
||||
if self.gcodes_path != None:
|
||||
if self.gcodes_path is not None:
|
||||
fpath = os.path.join(self.gcodes_path, params['filename'])
|
||||
fdir = os.path.dirname(fpath)
|
||||
path = os.path.join(fdir, thumbnail['relative_path'])
|
||||
if os.access(path, os.R_OK):
|
||||
thumbnail['local'] = True
|
||||
thumbnail['path'] = path
|
||||
if thumbnail['local'] == False:
|
||||
if thumbnail['local'] is False:
|
||||
fdir = os.path.dirname(params['filename'])
|
||||
thumbnail['path'] = os.path.join(fdir, thumbnail['relative_path'])
|
||||
self.run_callbacks(mods=[params['filename']])
|
||||
@@ -107,13 +107,13 @@ class KlippyFiles():
|
||||
"modified": item['modified']
|
||||
}
|
||||
self.request_metadata(filename)
|
||||
if notify == True:
|
||||
if notify is True:
|
||||
self.run_callbacks(newfiles=[filename])
|
||||
|
||||
def add_file_callback(self, callback):
|
||||
try:
|
||||
self.callbacks.append(callback)
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Callback not found: %s" % callback)
|
||||
|
||||
def process_update(self, data):
|
||||
@@ -150,7 +150,7 @@ class KlippyFiles():
|
||||
return None
|
||||
|
||||
thumb = self.files[filename]['thumbnails'][0]
|
||||
if thumb['local'] == False:
|
||||
if thumb['local'] is False:
|
||||
return ['http', thumb['path']]
|
||||
return ['file', thumb['path']]
|
||||
|
||||
@@ -174,10 +174,10 @@ class KlippyFiles():
|
||||
self.filelist.remove(filename)
|
||||
self.files.pop(filename, None)
|
||||
|
||||
if notify == True:
|
||||
if notify is True:
|
||||
self.run_callbacks(deletedfiles=[filename])
|
||||
|
||||
def ret_file_data (self, filename):
|
||||
def ret_file_data(self, filename):
|
||||
print("Getting file info for %s" % (filename))
|
||||
self._screen._ws.klippy.get_file_metadata(filename, self._callback)
|
||||
|
||||
@@ -195,6 +195,6 @@ class KlippyFiles():
|
||||
|
||||
def get_file_info(self, filename):
|
||||
if filename not in self.files:
|
||||
return {"path":None,"modified":0,"size":0}
|
||||
return {"path": None, "modified": 0, "size": 0}
|
||||
|
||||
return self.files[filename]
|
||||
@@ -46,15 +46,15 @@ try:
|
||||
libXext.XCloseDisplay(display)
|
||||
return state
|
||||
dpms_loaded = True
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_network_interfaces():
|
||||
stream = os.popen("ip addr | grep ^'[0-9]' | cut -d ' ' -f 2 | grep -o '[a-zA-Z0-9\.]*'")
|
||||
stream = os.popen("ip addr | grep ^'[0-9]' | cut -d ' ' -f 2 | grep -o '[a-zA-Z0-9\\.]*'")
|
||||
return [i for i in stream.read().strip().split('\n') if not i.startswith('lo')]
|
||||
|
||||
def get_wireless_interfaces():
|
||||
p = subprocess.Popen(["which","iwconfig"], stdout=subprocess.PIPE)
|
||||
p = subprocess.Popen(["which", "iwconfig"], stdout=subprocess.PIPE)
|
||||
|
||||
while p.poll() is None:
|
||||
time.sleep(.1)
|
||||
@@ -64,12 +64,12 @@ def get_wireless_interfaces():
|
||||
try:
|
||||
p = subprocess.Popen(["iwconfig"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
result = p.stdout.read().decode('ascii').split('\n')
|
||||
except:
|
||||
except Exception:
|
||||
logging.info("Error with running iwconfig command")
|
||||
return None
|
||||
interfaces = []
|
||||
for line in result:
|
||||
match = re.search('^(\S+)\s+.*$', line)
|
||||
match = re.search('^(\\S+)\\s+.*$', line)
|
||||
if match:
|
||||
interfaces.append(match.group(1))
|
||||
|
||||
@@ -99,15 +99,17 @@ def patch_threading_excepthook():
|
||||
Inspired by https://bugs.python.org/issue1230540
|
||||
"""
|
||||
old_init = threading.Thread.__init__
|
||||
|
||||
def new_init(self, *args, **kwargs):
|
||||
old_init(self, *args, **kwargs)
|
||||
old_run = self.run
|
||||
|
||||
def run_with_excepthook(*args, **kwargs):
|
||||
try:
|
||||
old_run(*args, **kwargs)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
except Exception:
|
||||
sys.excepthook(*sys.exc_info(), thread_identifier=threading.get_ident())
|
||||
self.run = run_with_excepthook
|
||||
threading.Thread.__init__ = new_init
|
||||
@@ -160,7 +162,8 @@ def setup_logging(log_file, software_version):
|
||||
listener.start()
|
||||
|
||||
def logging_exception_handler(type, value, tb, thread_identifier=None):
|
||||
logging.exception("Uncaught exception %s: %s\nTraceback: %s" % (type, value, "\n".join(traceback.format_tb(tb))))
|
||||
logging.exception(
|
||||
"Uncaught exception %s: %s\nTraceback: %s" % (type, value, "\n".join(traceback.format_tb(tb))))
|
||||
sys.excepthook = logging_exception_handler
|
||||
logging.captureWarnings(True)
|
||||
|
||||
|
||||
+11
-11
@@ -2,7 +2,7 @@ import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gdk, GLib
|
||||
from gi.repository import Gdk, GLib
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class Printer:
|
||||
r['min_x'] = float(r['min_x'])
|
||||
r['max_y'] = float(r['max_y'])
|
||||
r['min_y'] = float(r['min_y'])
|
||||
r['points'] = [[float(j.strip()) for j in i.split(",")] for i in r['points'].strip().split("\n")]
|
||||
r['points'] = [[float(j.strip()) for j in i.split(",")] for i in r['points'].strip().split("\n")]
|
||||
self.process_update(data)
|
||||
|
||||
logging.info("Klipper version: %s", self.klipper['version'])
|
||||
@@ -109,9 +109,9 @@ class Printer:
|
||||
return updates
|
||||
|
||||
def evaluate_state(self):
|
||||
wh_state = self.data['webhooks']['state'].lower() # possible values: startup, ready, shutdown, error
|
||||
idle_state = self.data['idle_timeout']['state'].lower() # possible values: Idle, printing, ready
|
||||
print_state = self.data['print_stats']['state'].lower() # possible values: complete, paused, printing, standby
|
||||
wh_state = self.data['webhooks']['state'].lower() # possible values: startup, ready, shutdown, error
|
||||
idle_state = self.data['idle_timeout']['state'].lower() # possible values: Idle, printing, ready
|
||||
print_state = self.data['print_stats']['state'].lower() # possible values: complete, paused, printing, standby
|
||||
|
||||
if wh_state == "ready":
|
||||
new_state = "ready"
|
||||
@@ -120,7 +120,7 @@ class Printer:
|
||||
elif idle_state == "printing":
|
||||
if print_state == "complete":
|
||||
new_state = "ready"
|
||||
elif print_state != "printing": # Not printing a file, toolhead moving
|
||||
elif print_state != "printing": # Not printing a file, toolhead moving
|
||||
new_state = "busy"
|
||||
else:
|
||||
new_state = "printing"
|
||||
@@ -141,7 +141,7 @@ class Printer:
|
||||
logging.debug("Changing state from '%s' to '%s'" % (self.state, state))
|
||||
prev_state = self.state
|
||||
self.state = state
|
||||
if self.state_callbacks[state] != None:
|
||||
if self.state_callbacks[state] is not None:
|
||||
logging.debug("Adding callback for state: %s" % state)
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
@@ -213,7 +213,7 @@ class Printer:
|
||||
}
|
||||
}
|
||||
|
||||
sections = ["bed_mesh","bltouch","probe","quad_gantry_level","z_tilt"]
|
||||
sections = ["bed_mesh", "bltouch", "probe", "quad_gantry_level", "z_tilt"]
|
||||
for section in sections:
|
||||
if self.config_section_exists(section):
|
||||
data["printer"][section] = self.get_config_section(section).copy()
|
||||
@@ -231,10 +231,10 @@ class Printer:
|
||||
return
|
||||
return self.power_devices[device]['status']
|
||||
|
||||
def get_stat(self, stat, substat = None):
|
||||
def get_stat(self, stat, substat=None):
|
||||
if stat not in self.data:
|
||||
return {}
|
||||
if substat != None:
|
||||
if substat is not None:
|
||||
if substat in self.data[stat]:
|
||||
return self.data[stat][substat]
|
||||
return {}
|
||||
@@ -246,7 +246,7 @@ class Printer:
|
||||
def set_dev_temps(self, dev, temp, target=None):
|
||||
if dev in self.devices:
|
||||
self.devices[dev]['temperature'] = temp
|
||||
if target != None:
|
||||
if target is not None:
|
||||
self.devices[dev]['target'] = target
|
||||
|
||||
def get_dev_stats(self, dev):
|
||||
|
||||
@@ -24,7 +24,7 @@ class ScreenPanel:
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
|
||||
action_bar_width = self._gtk.get_action_bar_width() if action_bar == True else 0
|
||||
action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0
|
||||
self.content = Gtk.Box(spacing=0)
|
||||
|
||||
def initialize(self, panel_name):
|
||||
@@ -45,7 +45,7 @@ class ScreenPanel:
|
||||
return None
|
||||
|
||||
loc = self._files.get_thumbnail_location(filename)
|
||||
if loc == None:
|
||||
if loc is None:
|
||||
return None
|
||||
if loc[0] == "file":
|
||||
return self._gtk.PixbufFromFile(loc[1], None, width, height)
|
||||
@@ -60,23 +60,22 @@ class ScreenPanel:
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
|
||||
def menu_item_clicked(self, widget, panel, item):
|
||||
print("### Creating panel "+ item['panel'] + " : %s %s" % (panel, item))
|
||||
print("### Creating panel " + item['panel'] + " : %s %s" % (panel, item))
|
||||
if "items" in item:
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + panel, item['panel'], item['name'],
|
||||
1, False, items=item['items'])
|
||||
1, False, items=item['items'])
|
||||
return
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + panel, item['panel'], item['name'],
|
||||
1, False)
|
||||
1, False)
|
||||
|
||||
def menu_return(self, widget, home=False):
|
||||
if home == False:
|
||||
if home is False:
|
||||
self._screen._menu_go_back()
|
||||
return
|
||||
self._screen._menu_go_home()
|
||||
|
||||
def set_title(self, title):
|
||||
self.title = title
|
||||
#self.title.set_label(title)
|
||||
|
||||
def show_all(self):
|
||||
self._screen.show_all()
|
||||
@@ -87,7 +86,7 @@ class ScreenPanel:
|
||||
|
||||
def update_temp(self, dev, temp, target, name=None):
|
||||
if dev in self.labels:
|
||||
if name == None:
|
||||
if name is None:
|
||||
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
else:
|
||||
self.labels[dev].set_label("%s\n%s" % (name, self._gtk.formatTemperatureString(temp, target)))
|
||||
+74
-73
@@ -1,4 +1,5 @@
|
||||
import os, signal
|
||||
import os
|
||||
import signal
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
@@ -57,7 +58,7 @@ class WifiManager():
|
||||
self.soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
self.soc.bind(KS_SOCKET_FILE)
|
||||
self.soc.connect("/var/run/wpa_supplicant/%s" % interface)
|
||||
except:
|
||||
except Exception:
|
||||
logging.info("Error connecting to wifi socket: %s" % interface)
|
||||
return
|
||||
|
||||
@@ -77,15 +78,15 @@ class WifiManager():
|
||||
def add_network(self, ssid, psk):
|
||||
for id in list(self.supplicant_networks):
|
||||
if self.supplicant_networks[id]['ssid'] == ssid:
|
||||
#Modify network
|
||||
# Modify network
|
||||
return
|
||||
|
||||
# TODO: Add wpa_cli error checking
|
||||
network_id = self.wpa_cli("ADD_NETWORK")
|
||||
commands = [
|
||||
'ENABLE_NETWORK %s' % (network_id),
|
||||
'SET_NETWORK %s ssid "%s"' % (network_id, ssid.replace('"','\"')),
|
||||
'SET_NETWORK %s psk "%s"' % (network_id, psk.replace('"','\"'))
|
||||
'SET_NETWORK %s ssid "%s"' % (network_id, ssid.replace('"', '\"')),
|
||||
'SET_NETWORK %s psk "%s"' % (network_id, psk.replace('"', '\"'))
|
||||
]
|
||||
self.wpa_cli_batch(commands)
|
||||
|
||||
@@ -96,7 +97,7 @@ class WifiManager():
|
||||
id = i
|
||||
break
|
||||
|
||||
if id == None:
|
||||
if id is None:
|
||||
logging.info("Error adding network")
|
||||
return False
|
||||
|
||||
@@ -118,7 +119,7 @@ class WifiManager():
|
||||
id = netid
|
||||
break
|
||||
|
||||
if id == None:
|
||||
if id is None:
|
||||
logging.info("Wifi network is not defined in wpa_supplicant")
|
||||
return False
|
||||
|
||||
@@ -134,7 +135,7 @@ class WifiManager():
|
||||
id = i
|
||||
break
|
||||
|
||||
if id == None:
|
||||
if id is None:
|
||||
logging.debug("Unable to find network in wpa_supplicant")
|
||||
return
|
||||
self.wpa_cli("REMOVE_NETWORK %s" % id)
|
||||
@@ -243,7 +244,7 @@ class WifiManager():
|
||||
|
||||
aps = []
|
||||
for res in results:
|
||||
match = re.match("^([a-f0-9:]+)\s+([0-9]+)\s+([\-0-9]+)\s+(\S+)\s+(.+)?", res)
|
||||
match = re.match("^([a-f0-9:]+)\\s+([0-9]+)\\s+([\\-0-9]+)\\s+(\\S+)\\s+(.+)?", res)
|
||||
if match:
|
||||
net = {
|
||||
"mac": match.group(1),
|
||||
@@ -286,10 +287,10 @@ class WifiManager():
|
||||
cb, new_networks, deleted_networks)
|
||||
|
||||
def wpa_cli(self, command, wait=True):
|
||||
if wait == False:
|
||||
if wait is False:
|
||||
self.wpa_thread.skip_command()
|
||||
self.soc.send(command.encode())
|
||||
if wait == True:
|
||||
if wait is True:
|
||||
resp = self.queue.get()
|
||||
return resp
|
||||
|
||||
@@ -299,7 +300,7 @@ class WifiManager():
|
||||
|
||||
|
||||
class WpaSocket(Thread):
|
||||
def __init__ (self, wm, queue, callback):
|
||||
def __init__(self, wm, queue, callback):
|
||||
super().__init__()
|
||||
self.queue = queue
|
||||
self.callback = callback
|
||||
@@ -311,10 +312,10 @@ class WpaSocket(Thread):
|
||||
def run(self):
|
||||
event = threading.Event()
|
||||
logging.debug("Setting up wifi event loop")
|
||||
while self._stop_loop == False:
|
||||
while self._stop_loop is False:
|
||||
try:
|
||||
msg = self.soc.recv(4096).decode().strip()
|
||||
except:
|
||||
except Exception:
|
||||
# TODO: Socket error
|
||||
continue
|
||||
if msg.startswith("<"):
|
||||
@@ -322,7 +323,7 @@ class WpaSocket(Thread):
|
||||
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.wm.scan_results)
|
||||
elif "CTRL-EVENT-DISCONNECTED" in msg:
|
||||
self.callback("connecting_status", msg)
|
||||
match = re.match('<3>CTRL-EVENT-DISCONNECTED bssid=(\S+) reason=3 locally_generated=1', msg)
|
||||
match = re.match('<3>CTRL-EVENT-DISCONNECTED bssid=(\\S+) reason=3 locally_generated=1', msg)
|
||||
if match:
|
||||
for net in self.wm.networks:
|
||||
if self.wm.networks[net]['mac'] == match.group(1):
|
||||
@@ -353,117 +354,117 @@ class WifiChannels:
|
||||
@staticmethod
|
||||
def lookup(freq):
|
||||
if freq == "2412":
|
||||
return ("2.4","1")
|
||||
return ("2.4", "1")
|
||||
if freq == "2417":
|
||||
return ("2.4","2")
|
||||
return ("2.4", "2")
|
||||
if freq == "2422":
|
||||
return ("2.4","3")
|
||||
return ("2.4", "3")
|
||||
if freq == "2427":
|
||||
return ("2.4","4")
|
||||
return ("2.4", "4")
|
||||
if freq == "2432":
|
||||
return ("2.4","5")
|
||||
return ("2.4", "5")
|
||||
if freq == "2437":
|
||||
return ("2.4","6")
|
||||
return ("2.4", "6")
|
||||
if freq == "2442":
|
||||
return ("2.4","7")
|
||||
return ("2.4", "7")
|
||||
if freq == "2447":
|
||||
return ("2.4","8")
|
||||
return ("2.4", "8")
|
||||
if freq == "2452":
|
||||
return ("2.4","9")
|
||||
return ("2.4", "9")
|
||||
if freq == "2457":
|
||||
return ("2.4","10")
|
||||
return ("2.4", "10")
|
||||
if freq == "2462":
|
||||
return ("2.4","11")
|
||||
return ("2.4", "11")
|
||||
if freq == "2467":
|
||||
return ("2.4","12")
|
||||
return ("2.4", "12")
|
||||
if freq == "2472":
|
||||
return ("2.4","13")
|
||||
return ("2.4", "13")
|
||||
if freq == "2484":
|
||||
return ("2.4","14")
|
||||
return ("2.4", "14")
|
||||
if freq == "5035":
|
||||
return ("5","7")
|
||||
return ("5", "7")
|
||||
if freq == "5040":
|
||||
return ("5","8")
|
||||
return ("5", "8")
|
||||
if freq == "5045":
|
||||
return ("5","9")
|
||||
return ("5", "9")
|
||||
if freq == "5055":
|
||||
return ("5","11")
|
||||
return ("5", "11")
|
||||
if freq == "5060":
|
||||
return ("5","12")
|
||||
return ("5", "12")
|
||||
if freq == "5080":
|
||||
return ("5","16")
|
||||
return ("5", "16")
|
||||
if freq == "5170":
|
||||
return ("5","34")
|
||||
return ("5", "34")
|
||||
if freq == "5180":
|
||||
return ("5","36")
|
||||
return ("5", "36")
|
||||
if freq == "5190":
|
||||
return ("5","38")
|
||||
return ("5", "38")
|
||||
if freq == "5200":
|
||||
return ("5","40")
|
||||
return ("5", "40")
|
||||
if freq == "5210":
|
||||
return ("5","42")
|
||||
return ("5", "42")
|
||||
if freq == "5220":
|
||||
return ("5","44")
|
||||
return ("5", "44")
|
||||
if freq == "5230":
|
||||
return ("5","46")
|
||||
return ("5", "46")
|
||||
if freq == "5240":
|
||||
return ("5","48")
|
||||
return ("5", "48")
|
||||
if freq == "5260":
|
||||
return ("5","52")
|
||||
return ("5", "52")
|
||||
if freq == "5280":
|
||||
return ("5","56")
|
||||
return ("5", "56")
|
||||
if freq == "5300":
|
||||
return ("5","60")
|
||||
return ("5", "60")
|
||||
if freq == "5320":
|
||||
return ("5","64")
|
||||
return ("5", "64")
|
||||
if freq == "5500":
|
||||
return ("5","100")
|
||||
return ("5", "100")
|
||||
if freq == "5520":
|
||||
return ("5","104")
|
||||
return ("5", "104")
|
||||
if freq == "5540":
|
||||
return ("5","108")
|
||||
return ("5", "108")
|
||||
if freq == "5560":
|
||||
return ("5","112")
|
||||
return ("5", "112")
|
||||
if freq == "5580":
|
||||
return ("5","116")
|
||||
return ("5", "116")
|
||||
if freq == "5600":
|
||||
return ("5","120")
|
||||
return ("5", "120")
|
||||
if freq == "5620":
|
||||
return ("5","124")
|
||||
return ("5", "124")
|
||||
if freq == "5640":
|
||||
return ("5","128")
|
||||
return ("5", "128")
|
||||
if freq == "5660":
|
||||
return ("5","132")
|
||||
return ("5", "132")
|
||||
if freq == "5680":
|
||||
return ("5","136")
|
||||
return ("5", "136")
|
||||
if freq == "5700":
|
||||
return ("5","140")
|
||||
return ("5", "140")
|
||||
if freq == "5720":
|
||||
return ("5","144")
|
||||
return ("5", "144")
|
||||
if freq == "5745":
|
||||
return ("5","149")
|
||||
return ("5", "149")
|
||||
if freq == "5765":
|
||||
return ("5","153")
|
||||
return ("5", "153")
|
||||
if freq == "5785":
|
||||
return ("5","157")
|
||||
return ("5", "157")
|
||||
if freq == "5805":
|
||||
return ("5","161")
|
||||
return ("5", "161")
|
||||
if freq == "5825":
|
||||
return ("5","165")
|
||||
return ("5", "165")
|
||||
if freq == "4915":
|
||||
return ("5","183")
|
||||
return ("5", "183")
|
||||
if freq == "4920":
|
||||
return ("5","184")
|
||||
return ("5", "184")
|
||||
if freq == "4925":
|
||||
return ("5","185")
|
||||
return ("5", "185")
|
||||
if freq == "4935":
|
||||
return ("5","187")
|
||||
return ("5", "187")
|
||||
if freq == "4940":
|
||||
return ("5","188")
|
||||
return ("5", "188")
|
||||
if freq == "4945":
|
||||
return ("5","189")
|
||||
return ("5", "189")
|
||||
if freq == "4960":
|
||||
return ("5","192")
|
||||
return ("5", "192")
|
||||
if freq == "4980":
|
||||
return ("5","196")
|
||||
return None;
|
||||
return ("5", "196")
|
||||
return None
|
||||
+23
-23
@@ -26,7 +26,7 @@ class BasePanel(ScreenPanel):
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
|
||||
action_bar_width = self._gtk.get_action_bar_width() if action_bar == True else 0
|
||||
action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0
|
||||
|
||||
self.control_grid = self._gtk.HomogeneousGrid()
|
||||
self.control_grid.set_size_request(action_bar_width - 2, self._screen.height)
|
||||
@@ -69,7 +69,7 @@ class BasePanel(ScreenPanel):
|
||||
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1)
|
||||
|
||||
if len(self._config.get_printers()) > 1:
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0,2))
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, 2))
|
||||
self.control_grid.attach(self.control['printer_select'], 0, 2, 1, 1)
|
||||
self.control_grid.attach(self.control['estop'], 0, 4, 1, 1)
|
||||
|
||||
@@ -78,7 +78,7 @@ class BasePanel(ScreenPanel):
|
||||
env.install_gettext_translations(self.lang)
|
||||
j2_temp = env.from_string(title)
|
||||
title = j2_temp.render()
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Error parsing jinja for title: %s" % title)
|
||||
|
||||
self.titlelbl = Gtk.Label()
|
||||
@@ -91,7 +91,7 @@ class BasePanel(ScreenPanel):
|
||||
self.content = Gtk.VBox(spacing=0)
|
||||
self.content.set_size_request(self._screen.width - action_bar_width, self._screen.height - self.title_spacing)
|
||||
|
||||
if action_bar == True:
|
||||
if action_bar is True:
|
||||
self.layout.put(self.control_grid, 0, 0)
|
||||
|
||||
self.control['time_box'] = Gtk.Box()
|
||||
@@ -124,19 +124,19 @@ class BasePanel(ScreenPanel):
|
||||
for extruder in self._printer.get_tools():
|
||||
self.labels[extruder + '_box'] = Gtk.Box(spacing=0)
|
||||
self.labels[extruder] = Gtk.Label(label="")
|
||||
#self.labels[extruder].get_style_context().add_class("printing-info")
|
||||
# self.labels[extruder].get_style_context().add_class("printing-info")
|
||||
if i <= 4:
|
||||
ext_img = self._gtk.Image("extruder-%s.svg" % i, None, .4, .4)
|
||||
self.labels[extruder + '_box'].pack_start(ext_img, True, 3, 3)
|
||||
self.labels[extruder + '_box'].pack_start(self.labels[extruder], True, 3, 3)
|
||||
i += 1
|
||||
self.current_extruder = self._printer.get_stat("toolhead","extruder")
|
||||
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
|
||||
self.control['temp_box'].pack_start(self.labels["%s_box" % self.current_extruder], True, 5, 5)
|
||||
|
||||
if self._printer.has_heated_bed():
|
||||
heater_bed = self._gtk.Image("bed.svg", None, .4, .4)
|
||||
self.labels['heater_bed'] = Gtk.Label(label="20 C")
|
||||
#self.labels['heater_bed'].get_style_context().add_class("printing-info")
|
||||
# self.labels['heater_bed'].get_style_context().add_class("printing-info")
|
||||
heater_bed_box = Gtk.Box(spacing=0)
|
||||
heater_bed_box.pack_start(heater_bed, True, 5, 5)
|
||||
heater_bed_box.pack_start(self.labels['heater_bed'], True, 3, 3)
|
||||
@@ -158,7 +158,7 @@ class BasePanel(ScreenPanel):
|
||||
self.content.add(panel.get_content())
|
||||
|
||||
def back(self, widget):
|
||||
if self.current_panel == None:
|
||||
if self.current_panel is None:
|
||||
return
|
||||
|
||||
if self._screen.is_keyboard_showing():
|
||||
@@ -174,13 +174,13 @@ class BasePanel(ScreenPanel):
|
||||
return self.layout
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update" or self._printer == None:
|
||||
if action != "notify_status_update" or self._printer is None:
|
||||
return
|
||||
|
||||
if self._printer.has_heated_bed():
|
||||
self.labels["heater_bed"].set_label("%02d°" % self._printer.get_dev_stat("heater_bed","temperature"))
|
||||
self.labels["heater_bed"].set_label("%02d°" % self._printer.get_dev_stat("heater_bed", "temperature"))
|
||||
for x in self._printer.get_tools():
|
||||
self.labels[x].set_label("%02d°" % self._printer.get_dev_stat(x,"temperature"))
|
||||
self.labels[x].set_label("%02d°" % self._printer.get_dev_stat(x, "temperature"))
|
||||
|
||||
if "toolhead" in data and "extruder" in data["toolhead"]:
|
||||
if data["toolhead"]["extruder"] != self.current_extruder:
|
||||
@@ -194,15 +194,15 @@ class BasePanel(ScreenPanel):
|
||||
self.content.remove(widget)
|
||||
|
||||
def show_back(self, show=True):
|
||||
if show == True and self.buttons_showing['back'] == False:
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0,0))
|
||||
if show is True and self.buttons_showing['back'] is False:
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, 0))
|
||||
self.control_grid.attach(self.control['back'], 0, 0, 1, 1)
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0,1))
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, 1))
|
||||
self.control_grid.attach(self.control['home'], 0, 1, 1, 1)
|
||||
self.buttons_showing['back'] = True
|
||||
elif show == False and self.buttons_showing['back'] == True:
|
||||
for i in range(0,2):
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0,i))
|
||||
elif show is False and self.buttons_showing['back'] is True:
|
||||
for i in range(0, 2):
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, i))
|
||||
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1)
|
||||
self.buttons_showing['back'] = False
|
||||
self.control_grid.show()
|
||||
@@ -211,8 +211,8 @@ class BasePanel(ScreenPanel):
|
||||
if show == "True":
|
||||
show = True
|
||||
|
||||
if show == True and self.buttons_showing['macros_shortcut'] == False:
|
||||
if len(self._config.get_printers()) > 1 and mod_row == True:
|
||||
if show is True and self.buttons_showing['macros_shortcut'] is False:
|
||||
if len(self._config.get_printers()) > 1 and mod_row is True:
|
||||
self.control_grid.insert_row(self.locations['macro_shortcut'])
|
||||
else:
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
|
||||
@@ -220,10 +220,10 @@ class BasePanel(ScreenPanel):
|
||||
self.control_grid.remove(self.control['space%s' % self.locations['macro_shortcut']])
|
||||
self.control_grid.attach(self.control['macro_shortcut'], 0, self.locations['macro_shortcut'], 1, 1)
|
||||
self.buttons_showing['macros_shortcut'] = True
|
||||
elif show != True and self.buttons_showing['macros_shortcut'] == True:
|
||||
elif show is not True and self.buttons_showing['macros_shortcut'] is True:
|
||||
if ('space%s' % self.locations['macro_shortcut']) not in self.control:
|
||||
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
|
||||
if len(self._config.get_printers()) > 1 and mod_row == True:
|
||||
if len(self._config.get_printers()) > 1 and mod_row is True:
|
||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
|
||||
self.control_grid.remove(self.control['macro_shortcut'])
|
||||
self.control_grid.remove_row(self.locations['macro_shortcut'])
|
||||
@@ -232,7 +232,7 @@ class BasePanel(ScreenPanel):
|
||||
if ('space%s' % self.locations['macro_shortcut']) not in self.control:
|
||||
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
|
||||
self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']],
|
||||
0, self.locations['macro_shortcut'], 1, 1)
|
||||
0, self.locations['macro_shortcut'], 1, 1)
|
||||
self.buttons_showing['macros_shortcut'] = False
|
||||
self._screen.show_all()
|
||||
|
||||
@@ -242,7 +242,7 @@ class BasePanel(ScreenPanel):
|
||||
env.install_gettext_translations(self.lang)
|
||||
j2_temp = env.from_string(title)
|
||||
title = j2_temp.render()
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Error parsing jinja for title: %s" % title)
|
||||
|
||||
self.titlelbl.set_label("%s | %s" % (self._screen.connected_printer, title))
|
||||
|
||||
+12
-11
@@ -29,15 +29,15 @@ class BedLevelPanel(ScreenPanel):
|
||||
elif "bed_screws" in self._screen.printer.get_config_section_list():
|
||||
config_section_name = "bed_screws"
|
||||
|
||||
if config_section_name != None:
|
||||
if config_section_name is not None:
|
||||
config_section = self._screen.printer.get_config_section(config_section_name)
|
||||
for item in config_section:
|
||||
logging.debug("Screws section: %s" % config_section[item])
|
||||
result = re.match(r"([\-0-9\.]+)\s*,\s*([\-0-9\.]+)", config_section[item])
|
||||
if result:
|
||||
screws.append([
|
||||
round(float(result.group(1)),2),
|
||||
round(float(result.group(2)),2)
|
||||
round(float(result.group(1)), 2),
|
||||
round(float(result.group(2)), 2)
|
||||
])
|
||||
|
||||
screws = sorted(screws, key=lambda x: (float(x[1]), float(x[0])))
|
||||
@@ -54,8 +54,8 @@ class BedLevelPanel(ScreenPanel):
|
||||
new_screws = []
|
||||
for screw in screws:
|
||||
new_screws.append([
|
||||
round(float(screw[0]) + self.x_offset,2),
|
||||
round(float(screw[1]) + self.y_offset,2)
|
||||
round(float(screw[0]) + self.x_offset, 2),
|
||||
round(float(screw[1]) + self.y_offset, 2)
|
||||
])
|
||||
screws = new_screws
|
||||
|
||||
@@ -99,7 +99,7 @@ class BedLevelPanel(ScreenPanel):
|
||||
grid.attach(self.labels['fl'], 2, 1, 1, 1)
|
||||
grid.attach(self.labels['fr'], 1, 1, 1, 1)
|
||||
|
||||
self.labels['home'] = self._gtk.ButtonImage("home",_("Home All"),"color2")
|
||||
self.labels['home'] = self._gtk.ButtonImage("home", _("Home All"), "color2")
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
self.labels['dm'] = self._gtk.ButtonImage("motor-off", _("Disable XY"), "color3")
|
||||
@@ -109,7 +109,7 @@ class BedLevelPanel(ScreenPanel):
|
||||
grid.attach(self.labels['dm'], 0, 1, 1, 1)
|
||||
|
||||
if self._printer.config_section_exists("screws_tilt_adjust"):
|
||||
self.labels['screws'] = self._gtk.ButtonImage("refresh",_("Screws Adjust"),"color4")
|
||||
self.labels['screws'] = self._gtk.ButtonImage("refresh", _("Screws Adjust"), "color4")
|
||||
self.labels['screws'].connect("clicked", self.screws_tilt_calculate)
|
||||
grid.attach(self.labels['screws'], 3, 0, 1, 1)
|
||||
|
||||
@@ -140,21 +140,22 @@ class BedLevelPanel(ScreenPanel):
|
||||
|
||||
def disable_motors(self, widget):
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"M18" # Disable motors
|
||||
"M18" # Disable motors
|
||||
)
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action == "notify_gcode_response":
|
||||
result = re.match(
|
||||
"^// (.*) : [xX= ]+([\-0-9\.]+), [yY= ]+([\-0-9\.]+), [zZ= ]+[\-0-9\.]+ : (Adjust ->|adjust) ([CW]+ [0-9:]+)",
|
||||
"^// (.*) : [xX= ]+([\\-0-9\\.]+), [yY= ]+([\\-0-9\\.]+), [zZ= ]+[\\-0-9\\.]+ :" +
|
||||
" (Adjust ->|adjust) ([CW]+ [0-9:]+)",
|
||||
data
|
||||
)
|
||||
if result:
|
||||
screw_labels = ['fl','fr','bl','br']
|
||||
screw_labels = ['fl', 'fr', 'bl', 'br']
|
||||
x = int(float(result.group(2)) + self.x_offset)
|
||||
y = int(float(result.group(3)) + self.y_offset)
|
||||
logging.debug(data)
|
||||
logging.debug("X: %s Y: %s" % (x,y))
|
||||
logging.debug("X: %s Y: %s" % (x, y))
|
||||
for i in range(len(self.screws)):
|
||||
logging.debug(self.screws[i])
|
||||
if x == int(float(self.screws[i][0])) and y == int(float(self.screws[i][1])):
|
||||
|
||||
+41
-40
@@ -36,10 +36,10 @@ class BedMeshPanel(ScreenPanel):
|
||||
scroll.add(self.labels['profiles'])
|
||||
|
||||
|
||||
addprofile = self._gtk.ButtonImage("increase"," %s" % _("Add bed mesh profile"),
|
||||
"color1", .5, .5, Gtk.PositionType.LEFT, False)
|
||||
addprofile = self._gtk.ButtonImage("increase", " %s" % _("Add bed mesh profile"),
|
||||
"color1", .5, .5, Gtk.PositionType.LEFT, False)
|
||||
addprofile.connect("clicked", self.show_create_profile)
|
||||
addprofile.set_size_request(60,0)
|
||||
addprofile.set_size_request(60, 0)
|
||||
addprofile.set_hexpand(False)
|
||||
addprofile.set_halign(Gtk.Align.END)
|
||||
abox = Gtk.Box(spacing=0)
|
||||
@@ -63,7 +63,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels['main_box'])
|
||||
|
||||
am = self._screen.printer.get_stat("bed_mesh","profile_name")
|
||||
am = self._screen.printer.get_stat("bed_mesh", "profile_name")
|
||||
self.activate_mesh(am)
|
||||
|
||||
def activate_mesh(self, profile):
|
||||
@@ -74,12 +74,12 @@ class BedMeshPanel(ScreenPanel):
|
||||
if profile != self.active_mesh:
|
||||
if profile not in self.profiles:
|
||||
self.add_profile(profile)
|
||||
if self.active_mesh != None and self.active_mesh in self.profiles:
|
||||
if self.active_mesh is not None and self.active_mesh in self.profiles:
|
||||
a = self.profiles[self.active_mesh]
|
||||
a['buttons'].remove(a['refresh'])
|
||||
a['buttons'].pack_start(a['load'], False, False, 0)
|
||||
self.active_mesh = profile
|
||||
if self.active_mesh != None:
|
||||
if self.active_mesh is not None:
|
||||
a = self.profiles[profile]
|
||||
a['buttons'].remove(a['load'])
|
||||
a['buttons'].pack_start(a['refresh'], False, False, 0)
|
||||
@@ -89,7 +89,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
|
||||
name = Gtk.Label()
|
||||
name.set_markup("<big><b>%s</b></big>" % (profile))
|
||||
@@ -99,39 +99,39 @@ class BedMeshPanel(ScreenPanel):
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
load = self._gtk.ButtonImage("load",_("Load"),"color2")
|
||||
load = self._gtk.ButtonImage("load", _("Load"), "color2")
|
||||
load.connect("clicked", self.send_load_mesh, profile)
|
||||
load.set_size_request(60,0)
|
||||
load.set_size_request(60, 0)
|
||||
load.set_hexpand(False)
|
||||
load.set_halign(Gtk.Align.END)
|
||||
|
||||
refresh = self._gtk.ButtonImage("refresh",_("Calibrate"),"color4")
|
||||
refresh = self._gtk.ButtonImage("refresh", _("Calibrate"), "color4")
|
||||
refresh.connect("clicked", self.calibrate_mesh)
|
||||
refresh.set_size_request(60,0)
|
||||
refresh.set_size_request(60, 0)
|
||||
refresh.set_hexpand(False)
|
||||
refresh.set_halign(Gtk.Align.END)
|
||||
|
||||
view = self._gtk.ButtonImage("bed-level",_("View Mesh"),"color1")
|
||||
view = self._gtk.ButtonImage("bed-level", _("View Mesh"), "color1")
|
||||
view.connect("clicked", self.show_mesh, profile)
|
||||
view.set_size_request(60,0)
|
||||
view.set_size_request(60, 0)
|
||||
view.set_hexpand(False)
|
||||
view.set_halign(Gtk.Align.END)
|
||||
|
||||
info = self._gtk.ButtonImage("info",None,"color3")
|
||||
info = self._gtk.ButtonImage("info", None, "color3")
|
||||
info.connect("clicked", self.show_mesh, profile)
|
||||
info.set_size_request(60,0)
|
||||
info.set_size_request(60, 0)
|
||||
info.set_hexpand(False)
|
||||
info.set_halign(Gtk.Align.END)
|
||||
|
||||
save = self._gtk.ButtonImage("sd",_("Save"),"color3")
|
||||
save = self._gtk.ButtonImage("sd", _("Save"), "color3")
|
||||
save.connect("clicked", self.send_save_mesh, profile)
|
||||
save.set_size_request(60,0)
|
||||
save.set_size_request(60, 0)
|
||||
save.set_hexpand(False)
|
||||
save.set_halign(Gtk.Align.END)
|
||||
|
||||
delete = self._gtk.ButtonImage("cancel",_("Delete"),"color3")
|
||||
delete = self._gtk.ButtonImage("cancel", _("Delete"), "color3")
|
||||
delete.connect("clicked", self.send_remove_mesh, profile)
|
||||
delete.set_size_request(60,0)
|
||||
delete.set_size_request(60, 0)
|
||||
delete.set_hexpand(False)
|
||||
delete.set_halign(Gtk.Align.END)
|
||||
|
||||
@@ -153,7 +153,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
buttons.pack_start(refresh, False, False, 0)
|
||||
else:
|
||||
buttons.pack_start(load, False, False, 0)
|
||||
#buttons.pack_end(info, False, False, 0)
|
||||
# buttons.pack_end(info, False, False, 0)
|
||||
|
||||
if profile != "default":
|
||||
buttons.pack_end(save, False, False, 0)
|
||||
@@ -173,10 +173,10 @@ class BedMeshPanel(ScreenPanel):
|
||||
"view": view,
|
||||
}
|
||||
|
||||
l = list(self.profiles)
|
||||
if "default" in l:
|
||||
l.remove('default')
|
||||
profiles = sorted(l)
|
||||
pl = list(self.profiles)
|
||||
if "default" in pl:
|
||||
pl.remove('default')
|
||||
profiles = sorted(pl)
|
||||
pos = profiles.index(profile)+1 if profile != "default" else 0
|
||||
|
||||
self.labels['profiles'].insert_row(pos)
|
||||
@@ -184,7 +184,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
self.labels['profiles'].show_all()
|
||||
|
||||
def back(self):
|
||||
if self.show_create == True:
|
||||
if self.show_create is True:
|
||||
self.remove_create()
|
||||
return True
|
||||
return False
|
||||
@@ -215,7 +215,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
self.activate_mesh(data['bed_mesh']['profile_name'])
|
||||
|
||||
def remove_create(self):
|
||||
if self.show_create == False:
|
||||
if self.show_create is False:
|
||||
return
|
||||
|
||||
self._screen.remove_keyboard()
|
||||
@@ -230,10 +230,10 @@ class BedMeshPanel(ScreenPanel):
|
||||
if profile not in self.profiles:
|
||||
return
|
||||
|
||||
l = list(self.profiles)
|
||||
if "default" in l:
|
||||
l.remove('default')
|
||||
profiles = sorted(l)
|
||||
pl = list(self.profiles)
|
||||
if "default" in pl:
|
||||
pl.remove('default')
|
||||
profiles = sorted(pl)
|
||||
pos = profiles.index(profile)+1 if profile != "default" else 0
|
||||
self.labels['profiles'].remove_row(pos)
|
||||
del self.profiles[profile]
|
||||
@@ -266,23 +266,23 @@ class BedMeshPanel(ScreenPanel):
|
||||
|
||||
box = Gtk.Box(spacing=5)
|
||||
box.set_size_request(self._gtk.get_content_width(), self._gtk.get_content_height() -
|
||||
self._screen.keyboard_height - 20)
|
||||
self._screen.keyboard_height - 20)
|
||||
box.set_hexpand(True)
|
||||
box.set_vexpand(False)
|
||||
self.labels['create_profile'].add(box)
|
||||
|
||||
l = self._gtk.Label(_("Profile Name:"))
|
||||
l.set_hexpand(False)
|
||||
pl = self._gtk.Label(_("Profile Name:"))
|
||||
pl.set_hexpand(False)
|
||||
entry = Gtk.Entry()
|
||||
entry.set_hexpand(True)
|
||||
|
||||
save = self._gtk.ButtonImage("sd",_("Save"),"color3")
|
||||
save = self._gtk.ButtonImage("sd", _("Save"), "color3")
|
||||
save.set_hexpand(False)
|
||||
save.connect("clicked", self.create_profile)
|
||||
|
||||
|
||||
self.labels['profile_name'] = entry
|
||||
box.pack_start(l, False, False, 5)
|
||||
box.pack_start(pl, False, False, 5)
|
||||
box.pack_start(entry, True, True, 5)
|
||||
box.pack_start(save, False, False, 5)
|
||||
|
||||
@@ -297,20 +297,20 @@ class BedMeshPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
bm = self._printer.get_config_section("bed_mesh %s" % profile)
|
||||
if bm == False:
|
||||
if bm is False:
|
||||
logging.info("Unable to load profile: %s" % profile)
|
||||
return
|
||||
|
||||
if profile == self.active_mesh:
|
||||
abm = self._printer.get_stat("bed_mesh")
|
||||
if abm == None:
|
||||
if abm is None:
|
||||
logging.info("Unable to load active mesh: %s" % profile)
|
||||
return
|
||||
x_range = [int(abm['mesh_min'][0]), int(abm['mesh_max'][0])]
|
||||
y_range = [int(abm['mesh_min'][1]), int(abm['mesh_max'][1])]
|
||||
z_range = [min(min(abm['mesh_matrix'])), max(max(abm['mesh_matrix']))]
|
||||
counts = [len(abm['mesh_matrix'][0]), len(abm['mesh_matrix'])]
|
||||
deltas = [(x_range[1] - x_range[0] )/ (counts[0]-1), (y_range[1] - y_range[0]) / (counts[1]-1)]
|
||||
deltas = [(x_range[1] - x_range[0]) / (counts[0]-1), (y_range[1] - y_range[0]) / (counts[1]-1)]
|
||||
x = [(i*deltas[0])+x_range[0] for i in range(counts[0])]
|
||||
y = [(i*deltas[0])+y_range[0] for i in range(counts[1])]
|
||||
x, y = np.meshgrid(x, y)
|
||||
@@ -319,14 +319,15 @@ class BedMeshPanel(ScreenPanel):
|
||||
x_range = [int(bm['min_x']), int(bm['max_x'])]
|
||||
y_range = [int(bm['min_y']), int(bm['max_y'])]
|
||||
z_range = [min(min(bm['points'])), max(max(bm['points']))]
|
||||
deltas = [(x_range[1] - x_range[0] )/ (int(bm['x_count'])-1), (y_range[1] - y_range[0]) / (int(bm['y_count'])-1)]
|
||||
deltas = [(x_range[1] - x_range[0]) / (int(bm['x_count'])-1),
|
||||
(y_range[1] - y_range[0]) / (int(bm['y_count'])-1)]
|
||||
x = [(i*deltas[0])+x_range[0] for i in range(bm['x_count'])]
|
||||
y = [(i*deltas[0])+y_range[0] for i in range(bm['y_count'])]
|
||||
x, y = np.meshgrid(x, y)
|
||||
z = np.asarray(bm['points'])
|
||||
|
||||
rc('axes', edgecolor="#fff", labelcolor="#fff")
|
||||
rc(('xtick','ytick'), color="#fff")
|
||||
rc(('xtick', 'ytick'), color="#fff")
|
||||
fig = plt.figure()
|
||||
fig.patch.set_facecolor("black")
|
||||
ax = Axes3D(fig, auto_add_to_figure=False)
|
||||
|
||||
+10
-7
@@ -12,6 +12,7 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
def create_panel(*args):
|
||||
return ConsolePanel(*args)
|
||||
|
||||
|
||||
COLORS = {
|
||||
"command": "#bad8ff",
|
||||
"error": "#ff6975",
|
||||
@@ -24,7 +25,7 @@ class ConsolePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
gcodes = self._screen._ws.send_method("server.gcode_store",{"count": 100}, self.gcode_response)
|
||||
gcodes = self._screen._ws.send_method("server.gcode_store", {"count": 100}, self.gcode_response)
|
||||
|
||||
vbox = Gtk.VBox()
|
||||
vbox.set_hexpand(True)
|
||||
@@ -53,10 +54,10 @@ class ConsolePanel(ScreenPanel):
|
||||
|
||||
enter = self._gtk.Button("Send")
|
||||
enter.set_hexpand(False)
|
||||
enter.connect("clicked",self._send_command)
|
||||
enter.connect("clicked", self._send_command)
|
||||
|
||||
ebox.add(entry) #, True, 0, 0)
|
||||
ebox.add(enter) #, True, 0, 0)
|
||||
ebox.add(entry) # , True, 0, 0)
|
||||
ebox.add(enter) # , True, 0, 0)
|
||||
|
||||
self.labels.update({
|
||||
"entry": entry,
|
||||
@@ -83,11 +84,13 @@ class ConsolePanel(ScreenPanel):
|
||||
|
||||
message = '<span color="%s">%s</span>' % (color, message)
|
||||
|
||||
message = message.replace('\n','\n ')
|
||||
message = message.replace('\n', '\n ')
|
||||
|
||||
self.labels['tb'].insert_markup(self.labels['tb'].get_end_iter(),
|
||||
self.labels['tb'].insert_markup(
|
||||
self.labels['tb'].get_end_iter(),
|
||||
'\n<span color="%s">%s</span> %s' % (COLORS['time'], datetime.fromtimestamp(time).strftime("%H:%M:%S"),
|
||||
message), -1)
|
||||
message), -1
|
||||
)
|
||||
|
||||
def gcode_response(self, result, method, params):
|
||||
if method != "server.gcode_store":
|
||||
|
||||
+20
-19
@@ -12,7 +12,7 @@ def create_panel(*args):
|
||||
|
||||
class ExtrudePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['1','5','10','25']
|
||||
distances = ['1', '5', '10', '25']
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@@ -31,9 +31,9 @@ class ExtrudePanel(ScreenPanel):
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
i = 0
|
||||
self.current_extruder = self._printer.get_stat("toolhead","extruder")
|
||||
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
|
||||
for extruder in self._printer.get_tools():
|
||||
self.labels[extruder] = self._gtk.ButtonImage("extruder-%s" % i,_("Tool") + " %s" %str(i),"color1")
|
||||
self.labels[extruder] = self._gtk.ButtonImage("extruder-%s" % i, _("Tool") + " %s" % str(i), "color1")
|
||||
self.labels[extruder].connect("clicked", self.change_extruder, extruder)
|
||||
if extruder == self.current_extruder:
|
||||
self.labels[extruder].get_style_context().add_class("button_active")
|
||||
@@ -41,11 +41,11 @@ class ExtrudePanel(ScreenPanel):
|
||||
grid.attach(self.labels[extruder], i, 0, 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels['extrude'] = self._gtk.ButtonImage("extrude",_("Extrude"),"color3")
|
||||
self.labels['extrude'] = self._gtk.ButtonImage("extrude", _("Extrude"), "color3")
|
||||
self.labels['extrude'].connect("clicked", self.extrude, "+")
|
||||
self.labels['retract'] = self._gtk.ButtonImage("retract",_("Retract"),"color2")
|
||||
self.labels['retract'] = self._gtk.ButtonImage("retract", _("Retract"), "color2")
|
||||
self.labels['retract'].connect("clicked", self.extrude, "-")
|
||||
self.labels['temperature'] = self._gtk.ButtonImage("heat-up",_("Temperature"),"color4")
|
||||
self.labels['temperature'] = self._gtk.ButtonImage("heat-up", _("Temperature"), "color4")
|
||||
self.labels['temperature'].connect("clicked", self.menu_item_clicked, "temperature", {
|
||||
"name": "Temperature",
|
||||
"panel": "temperature"
|
||||
@@ -57,16 +57,16 @@ class ExtrudePanel(ScreenPanel):
|
||||
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.distances:
|
||||
self.labels["dist"+str(i)] = self._gtk.ToggleButton(i)
|
||||
self.labels["dist"+str(i)].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels["dist"+str(i)].get_style_context()
|
||||
if ((self._screen.lang_ltr == True and j == 0) or
|
||||
(self._screen.lang_ltr == False and j == len(self.distances)-1)):
|
||||
if ((self._screen.lang_ltr is True and j == 0) or
|
||||
(self._screen.lang_ltr is False and j == len(self.distances)-1)):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif ((self._screen.lang_ltr == False and j == 0) or
|
||||
(self._screen.lang_ltr == True and j == len(self.distances)-1)):
|
||||
elif ((self._screen.lang_ltr is False and j == 0) or
|
||||
(self._screen.lang_ltr is True and j == len(self.distances)-1)):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@@ -77,16 +77,16 @@ class ExtrudePanel(ScreenPanel):
|
||||
self.labels["dist1"].set_active(True)
|
||||
|
||||
speedgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.speeds:
|
||||
self.labels["speed"+str(i)] = self._gtk.ToggleButton(_(i))
|
||||
self.labels["speed"+str(i)].connect("clicked", self.change_speed, i)
|
||||
ctx = self.labels["speed"+str(i)].get_style_context()
|
||||
if ((self._screen.lang_ltr == True and j == 0) or
|
||||
(self._screen.lang_ltr == False and j == len(self.speeds)-1)):
|
||||
if ((self._screen.lang_ltr is True and j == 0) or
|
||||
(self._screen.lang_ltr is False and j == len(self.speeds)-1)):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif ((self._screen.lang_ltr == False and j == 0) or
|
||||
(self._screen.lang_ltr == True and j == len(self.speeds)-1)):
|
||||
elif ((self._screen.lang_ltr is False and j == 0) or
|
||||
(self._screen.lang_ltr is True and j == len(self.speeds)-1)):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@@ -110,9 +110,10 @@ class ExtrudePanel(ScreenPanel):
|
||||
return
|
||||
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
self.update_temp(
|
||||
x,
|
||||
self._printer.get_dev_stat(x, "temperature"),
|
||||
self._printer.get_dev_stat(x, "target")
|
||||
)
|
||||
|
||||
if ("toolhead" in data and "extruder" in data["toolhead"] and
|
||||
|
||||
+7
-6
@@ -10,7 +10,8 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
def create_panel(*args):
|
||||
return FanPanel(*args)
|
||||
|
||||
CHANGEABLE_FANS = ["fan","fan_generic"]
|
||||
|
||||
CHANGEABLE_FANS = ["fan", "fan_generic"]
|
||||
|
||||
class FanPanel(ScreenPanel):
|
||||
fan_speed = {}
|
||||
@@ -50,7 +51,7 @@ class FanPanel(ScreenPanel):
|
||||
def update_fan_speed(self, fan, speed):
|
||||
if fan not in self.devices:
|
||||
return
|
||||
if self.devices[fan]['changeable'] == True:
|
||||
if self.devices[fan]['changeable'] is True:
|
||||
if self.devices[fan]['scale'].has_grab():
|
||||
return
|
||||
self.fan_speed[fan] = round(float(speed) * 100)
|
||||
@@ -70,7 +71,7 @@ class FanPanel(ScreenPanel):
|
||||
break
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
try:
|
||||
@@ -92,7 +93,7 @@ class FanPanel(ScreenPanel):
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
adj = Gtk.Adjustment(0, 0, 100, 1, 5, 0)
|
||||
if changeable == True:
|
||||
if changeable is True:
|
||||
self.fan_speed[fan] = round(self.fan_speed[fan] * 100)
|
||||
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
|
||||
scale.set_value(self.fan_speed[fan])
|
||||
@@ -106,7 +107,7 @@ class FanPanel(ScreenPanel):
|
||||
scale.set_fraction(self.fan_speed[fan])
|
||||
scale.set_show_text(True)
|
||||
scale.set_hexpand(True)
|
||||
#scale.get_style_context().add_class("fan_slider")
|
||||
# scale.get_style_context().add_class("fan_slider")
|
||||
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
@@ -149,4 +150,4 @@ class FanPanel(ScreenPanel):
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.set_fan_speed(value))
|
||||
else:
|
||||
f = " ".join(fan.split(" ")[1:])
|
||||
self._screen._ws.klippy.gcode_script("SET_FAN_SPEED FAN=%s SPEED=%s" % (f, float(value)/100))
|
||||
self._screen._ws.klippy.gcode_script("SET_FAN_SPEED FAN=%s SPEED=%s" % (f, float(value)/100))
|
||||
+6
-6
@@ -16,9 +16,9 @@ class FineTunePanel(ScreenPanel):
|
||||
|
||||
bs = 0
|
||||
bs_delta = "0.05"
|
||||
bs_deltas = ["0.01","0.05"]
|
||||
bs_deltas = ["0.01", "0.05"]
|
||||
percent_delta = 1
|
||||
percent_deltas = ['1','5','10','25']
|
||||
percent_deltas = ['1', '5', '10', '25']
|
||||
fan = 100
|
||||
|
||||
extrusion = 0
|
||||
@@ -33,7 +33,7 @@ class FineTunePanel(ScreenPanel):
|
||||
|
||||
print_cfg = self._config.get_printer_config(self._screen.connected_printer)
|
||||
if print_cfg is not None:
|
||||
bs = print_cfg.get("z_babystep_values","0.01, 0.05")
|
||||
bs = print_cfg.get("z_babystep_values", "0.01, 0.05")
|
||||
if re.match(r'^[0-9,\.\s]+$', bs):
|
||||
bs = [str(i.strip()) for i in bs.split(',')]
|
||||
if len(bs) <= 2:
|
||||
@@ -77,7 +77,7 @@ class FineTunePanel(ScreenPanel):
|
||||
|
||||
# babystepping grid
|
||||
bsgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.bs_deltas:
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_bs_delta, i)
|
||||
@@ -96,7 +96,7 @@ class FineTunePanel(ScreenPanel):
|
||||
|
||||
# Grid for percentage
|
||||
deltgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.percent_deltas:
|
||||
self.labels[i] = self._gtk.ToggleButton("%s%%" % i)
|
||||
self.labels[i].connect("clicked", self.change_percent_delta, i)
|
||||
@@ -116,7 +116,7 @@ class FineTunePanel(ScreenPanel):
|
||||
|
||||
grid.attach(deltgrid, 1, 3, 2, 1)
|
||||
|
||||
#self.panel = grid
|
||||
# self.panel = grid
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class MacroPanel(ScreenPanel):
|
||||
def add_gcode_macro(self, macro):
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
@@ -51,7 +51,7 @@ class MacroPanel(ScreenPanel):
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
open = self._gtk.ButtonImage("resume",None,"color3")
|
||||
open = self._gtk.ButtonImage("resume", None, "color3")
|
||||
open.connect("clicked", self.run_gcode_macro, macro)
|
||||
open.set_hexpand(False)
|
||||
open.set_halign(Gtk.Align.END)
|
||||
@@ -82,7 +82,7 @@ class MacroPanel(ScreenPanel):
|
||||
def load_gcode_macros(self):
|
||||
macros = self._screen.printer.get_gcode_macros()
|
||||
section_name = "displayed_macros %s" % self._screen.connected_printer
|
||||
logging.info("Macro section name [%s]" % section_name)
|
||||
logging.info("Macro section name [%s]" % section_name)
|
||||
|
||||
for x in macros:
|
||||
macro = x[12:].strip()
|
||||
|
||||
+68
-79
@@ -60,9 +60,9 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels['lcdmessage'].set_ellipsize(True)
|
||||
self.labels['lcdmessage'].set_ellipsize(Pango.EllipsizeMode.END)
|
||||
|
||||
fi_box.add(self.labels['file']) #, True, True, 0)
|
||||
fi_box.add(self.labels['status']) #, True, True, 0)
|
||||
fi_box.add(self.labels['lcdmessage']) #, True, True, 0)
|
||||
fi_box.add(self.labels['file'])
|
||||
fi_box.add(self.labels['status'])
|
||||
fi_box.add(self.labels['lcdmessage'])
|
||||
fi_box.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
@@ -101,7 +101,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
i += 1
|
||||
|
||||
temp_grid = self._gtk.HomogeneousGrid()
|
||||
self.current_extruder = self._printer.get_stat("toolhead","extruder")
|
||||
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
|
||||
temp_grid.attach(self.labels[self.current_extruder + '_box'], 0, 0, 1, 1)
|
||||
if self._printer.has_heated_bed():
|
||||
heater_bed = self._gtk.Image("bed.svg", None, .6, .6)
|
||||
@@ -210,7 +210,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
def on_draw(self, da, ctx):
|
||||
w = da.get_allocated_width()
|
||||
h = da.get_allocated_height()
|
||||
r = min(w,h)*.4
|
||||
r = min(w, h)*.4
|
||||
|
||||
ctx.set_source_rgb(0.6, 0.6, 0.6)
|
||||
ctx.set_line_width(self._gtk.get_font_size() * .75)
|
||||
@@ -226,10 +226,10 @@ class JobStatusPanel(ScreenPanel):
|
||||
def activate(self):
|
||||
_ = self.lang.gettext
|
||||
self.progress = 0
|
||||
self.enable_button("pause","cancel","resume")
|
||||
self.enable_button("pause", "cancel", "resume")
|
||||
|
||||
state = "printing"
|
||||
self.update_text("status",_("Printing"))
|
||||
self.update_text("status", _("Printing"))
|
||||
|
||||
ps = self._printer.get_stat("print_stats")
|
||||
logging.debug("Act State: %s" % ps['state'])
|
||||
@@ -237,7 +237,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
self.show_buttons_for_state()
|
||||
|
||||
if self.timeout == None:
|
||||
if self.timeout is None:
|
||||
GLib.timeout_add(500, self.state_check)
|
||||
|
||||
def add_labels(self):
|
||||
@@ -246,13 +246,6 @@ class JobStatusPanel(ScreenPanel):
|
||||
for child in self.labels['i2_box'].get_children():
|
||||
self.labels['i2_box'].remove(child)
|
||||
|
||||
#if self.file_metadata == None:
|
||||
# self.labels['i1_box'].add(self.labels['temp_grid'])
|
||||
# self.labels['i1_box'].add(self.labels['pos_box'])
|
||||
# self.labels['i1_box'].add(self.labels['sfe_grid'])
|
||||
# self.labels['i2_box'].add(self.labels['it_box'])
|
||||
# self.labels['i2_box'].add(self.labels['itl_box'])
|
||||
#else:
|
||||
self.labels['i1_box'].add(self.labels['thumbnail'])
|
||||
self.labels['i2_box'].add(self.labels['temp_grid'])
|
||||
self.labels['i2_box'].add(self.labels['pos_box'])
|
||||
@@ -263,21 +256,21 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
def create_buttons(self):
|
||||
_ = self.lang.gettext
|
||||
self.labels['cancel'] = self._gtk.ButtonImage("stop",_("Cancel"),"color2")
|
||||
self.labels['cancel'] = self._gtk.ButtonImage("stop", _("Cancel"), "color2")
|
||||
self.labels['cancel'].connect("clicked", self.cancel)
|
||||
self.labels['control'] = self._gtk.ButtonImage("settings",_("Settings"),"color3")
|
||||
self.labels['control'] = self._gtk.ButtonImage("settings", _("Settings"), "color3")
|
||||
self.labels['control'].connect("clicked", self._screen._go_to_submenu, "")
|
||||
self.labels['fine_tune'] = self._gtk.ButtonImage("fine-tune",_("Fine Tuning"),"color4")
|
||||
self.labels['fine_tune'].connect("clicked", self.menu_item_clicked, "fine_tune",{
|
||||
self.labels['fine_tune'] = self._gtk.ButtonImage("fine-tune", _("Fine Tuning"), "color4")
|
||||
self.labels['fine_tune'].connect("clicked", self.menu_item_clicked, "fine_tune", {
|
||||
"panel": "fine_tune", "name": _("Fine Tuning")})
|
||||
self.labels['menu'] = self._gtk.ButtonImage("complete",_("Main Menu"),"color4")
|
||||
self.labels['menu'] = self._gtk.ButtonImage("complete", _("Main Menu"), "color4")
|
||||
self.labels['menu'].connect("clicked", self.close_panel)
|
||||
self.labels['pause'] = self._gtk.ButtonImage("pause",_("Pause"),"color1" )
|
||||
self.labels['pause'].connect("clicked",self.pause)
|
||||
self.labels['restart'] = self._gtk.ButtonImage("refresh",_("Restart"),"color3")
|
||||
self.labels['pause'] = self._gtk.ButtonImage("pause", _("Pause"), "color1")
|
||||
self.labels['pause'].connect("clicked", self.pause)
|
||||
self.labels['restart'] = self._gtk.ButtonImage("refresh", _("Restart"), "color3")
|
||||
self.labels['restart'].connect("clicked", self.restart)
|
||||
self.labels['resume'] = self._gtk.ButtonImage("resume",_("Resume"),"color1")
|
||||
self.labels['resume'].connect("clicked",self.resume)
|
||||
self.labels['resume'] = self._gtk.ButtonImage("resume", _("Resume"), "color1")
|
||||
self.labels['resume'].connect("clicked", self.resume)
|
||||
|
||||
def restart(self, widget):
|
||||
if self.filename != "none":
|
||||
@@ -286,16 +279,14 @@ class JobStatusPanel(ScreenPanel):
|
||||
for to in self.close_timeouts:
|
||||
GLib.source_remove(to)
|
||||
self.close_timeouts.remove(to)
|
||||
if self.timeout == None:
|
||||
if self.timeout is None:
|
||||
self.timeout = GLib.timeout_add(500, self.state_check)
|
||||
|
||||
def resume(self, widget):
|
||||
#self.disable_button("resume","cancel")
|
||||
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
def pause(self, widget):
|
||||
#self.disable_button("pause","cancel")
|
||||
self._screen._ws.klippy.print_pause(self._response_callback, "enable_button", "resume", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
@@ -317,17 +308,17 @@ class JobStatusPanel(ScreenPanel):
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, label, self.cancel_confirm)
|
||||
self.disable_button("pause","cancel")
|
||||
self.disable_button("pause", "cancel")
|
||||
|
||||
def cancel_confirm(self, widget, response_id):
|
||||
widget.destroy()
|
||||
|
||||
if response_id == Gtk.ResponseType.CANCEL:
|
||||
self.enable_button("pause","cancel")
|
||||
self.enable_button("pause", "cancel")
|
||||
return
|
||||
|
||||
logging.debug("Canceling print")
|
||||
self.disable_button("pause","resume","cancel")
|
||||
self.disable_button("pause", "resume", "cancel")
|
||||
self._screen._ws.klippy.print_cancel(self._response_callback)
|
||||
|
||||
def _response_callback(self, response, method, params, func=None, *args):
|
||||
@@ -352,16 +343,16 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels[arg].set_sensitive(False)
|
||||
|
||||
def _callback_metadata(self, newfiles, deletedfiles, modifiedfiles):
|
||||
if bool(self.file_metadata) == False and self.filename in modifiedfiles:
|
||||
if bool(self.file_metadata) is False and self.filename in modifiedfiles:
|
||||
self.update_file_metadata()
|
||||
self._files.remove_file_callback(self._callback_metadata)
|
||||
|
||||
def new_print(self):
|
||||
if self.state in ["cancelled","cancelling","complete","error"]:
|
||||
if self.state in ["cancelled", "cancelling", "complete", "error"]:
|
||||
for to in self.close_timeouts:
|
||||
GLib.source_remove(to)
|
||||
self.close_timeouts.remove(to)
|
||||
if self.timeout == None:
|
||||
if self.timeout is None:
|
||||
GLib.timeout_add(500, self.state_check)
|
||||
self._screen.wake_screen()
|
||||
self.state_check()
|
||||
@@ -378,24 +369,28 @@ class JobStatusPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if self._printer.has_heated_bed():
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
self.update_temp(
|
||||
"heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed", "temperature"),
|
||||
self._printer.get_dev_stat("heater_bed", "target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
self.update_temp(
|
||||
x,
|
||||
self._printer.get_dev_stat(x, "temperature"),
|
||||
self._printer.get_dev_stat(x, "target")
|
||||
)
|
||||
|
||||
ps = self._printer.get_stat("print_stats")
|
||||
vsd = self._printer.get_stat("virtual_sdcard")
|
||||
if 'display_status' in data and 'message' in data['display_status']:
|
||||
self.update_message()
|
||||
self.update_message()
|
||||
|
||||
if "print_stats" in data and "filename" in data['print_stats']:
|
||||
if data['print_stats']['filename'] != self.filename and self.state not in ["cancelling","cancelled","complete"]:
|
||||
logging.debug("filename: '%s' '%s' status: %s" % (self.filename, data['print_stats']['filename'], self.state))
|
||||
if data['print_stats']['filename'] != self.filename and (
|
||||
self.state not in ["cancelling", "cancelled", "complete"]):
|
||||
logging.debug("filename: '%s' '%s' status: %s" %
|
||||
(self.filename, data['print_stats']['filename'], self.state))
|
||||
self.update_filename()
|
||||
|
||||
if "toolhead" in data:
|
||||
@@ -413,8 +408,6 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels['pos_z'].set_text("Z: %.2f" % (data["gcode_move"]["gcode_position"][2]))
|
||||
|
||||
if "gcode_move" in data:
|
||||
#if "homing_origin" in data["gcode_move"]:
|
||||
# self.labels['zoffset'].set_text("%.2fmm" % data["gcode_move"]["homing_origin"][2])
|
||||
if "extrude_factor" in data["gcode_move"]:
|
||||
self.extrusion = int(data["gcode_move"]["extrude_factor"]*100)
|
||||
self.labels['extrusion'].set_text("%3d%%" % self.extrusion)
|
||||
@@ -423,16 +416,16 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels['speed'].set_text("%3d%%" % self.speed)
|
||||
|
||||
if "fan" in data and "speed" in data['fan']:
|
||||
self.fan = int(round(data['fan']['speed'],2)*100)
|
||||
self.fan = int(round(data['fan']['speed'], 2)*100)
|
||||
self.labels['fan'].set_text("%3d%%" % self.fan)
|
||||
|
||||
if self.state in ["cancelling","cancelled","complete","error"]:
|
||||
if self.state in ["cancelling", "cancelled", "complete", "error"]:
|
||||
return
|
||||
|
||||
self.update_percent_complete()
|
||||
self.update_text("duration", str(self._gtk.formatTimeString(ps['print_duration'])))
|
||||
|
||||
timeleft_type = self._config.get_config()['main'].get('print_estimate_method','file')
|
||||
timeleft_type = self._config.get_config()['main'].get('print_estimate_method', 'file')
|
||||
if timeleft_type != self.timeleft_type:
|
||||
if self.timeleft_type == "duration":
|
||||
self.labels['it_box'].add(self.labels['est_time'])
|
||||
@@ -440,20 +433,20 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels['it_box'].remove(self.labels['est_time'])
|
||||
self.timeleft_type = timeleft_type
|
||||
|
||||
if timeleft_type in ['filament','file','slicer']:
|
||||
if timeleft_type in ['filament', 'file', 'slicer']:
|
||||
duration = ps['print_duration']
|
||||
if timeleft_type == "filament":
|
||||
estimated_filament = (self.file_metadata['filament_total'] if "filament_total" in self.file_metadata
|
||||
else 1)
|
||||
total_duration = duration / (max(ps['filament_used'],0.0001) / max(estimated_filament, 0.0001))
|
||||
else 1)
|
||||
total_duration = duration / (max(ps['filament_used'], 0.0001) / max(estimated_filament, 0.0001))
|
||||
elif timeleft_type == "file":
|
||||
total_duration = duration / max(self.progress, 0.0001)
|
||||
elif timeleft_type == "slicer":
|
||||
total_duration = (self.file_metadata['estimated_time'] if "estimated_time" in self.file_metadata
|
||||
else duration)
|
||||
else duration)
|
||||
time_left = max(total_duration - duration, 0)
|
||||
self.update_text("time_left", str(self._gtk.formatTimeString(time_left)))
|
||||
self.update_text("est_time","/ %s" % str(self._gtk.formatTimeString(total_duration)))
|
||||
self.update_text("est_time", "/ %s" % str(self._gtk.formatTimeString(total_duration)))
|
||||
|
||||
def state_check(self):
|
||||
ps = self._printer.get_stat("print_stats")
|
||||
@@ -513,15 +506,15 @@ class JobStatusPanel(ScreenPanel):
|
||||
logging.debug("Changing job_status state from '%s' to '%s'" % (self.state, state))
|
||||
self.state = state
|
||||
if state == "paused":
|
||||
self.update_text("status",_("Paused"))
|
||||
self.update_text("status", _("Paused"))
|
||||
elif state == "printing":
|
||||
self.update_text("status",_("Printing"))
|
||||
self.update_text("status", _("Printing"))
|
||||
elif state == "cancelling":
|
||||
self.update_text("status",_("Cancelling"))
|
||||
self.update_text("status", _("Cancelling"))
|
||||
elif state == "cancelled":
|
||||
self.update_text("status",_("Cancelled"))
|
||||
self.update_text("status", _("Cancelled"))
|
||||
elif state == "complete":
|
||||
self.update_text("status",_("Complete"))
|
||||
self.update_text("status", _("Complete"))
|
||||
self.show_buttons_for_state()
|
||||
|
||||
|
||||
@@ -533,13 +526,13 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels['button_grid'].attach(self.labels['cancel'], 1, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(self.labels['fine_tune'], 2, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(self.labels['control'], 3, 0, 1, 1)
|
||||
self.enable_button("pause","cancel")
|
||||
self.enable_button("pause", "cancel")
|
||||
elif self.state == "paused":
|
||||
self.labels['button_grid'].attach(self.labels['resume'], 0, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(self.labels['cancel'], 1, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(self.labels['fine_tune'], 2, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(self.labels['control'], 3, 0, 1, 1)
|
||||
self.enable_button("resume","cancel")
|
||||
self.enable_button("resume", "cancel")
|
||||
elif self.state == "cancelling":
|
||||
self.labels['button_grid'].attach(Gtk.Label(""), 0, 0, 1, 1)
|
||||
self.labels['button_grid'].attach(Gtk.Label(""), 1, 0, 1, 1)
|
||||
@@ -555,12 +548,12 @@ class JobStatusPanel(ScreenPanel):
|
||||
def show_file_thumbnail(self):
|
||||
if self._files.has_thumbnail(self.filename):
|
||||
pixbuf = self.get_file_image(self.filename, 7, 3.25)
|
||||
if pixbuf != None:
|
||||
if pixbuf is not None:
|
||||
self.labels['thumbnail'].set_from_pixbuf(pixbuf)
|
||||
|
||||
def update_filename(self):
|
||||
self.filename = self._printer.get_stat('print_stats','filename')
|
||||
self.update_text("file", os.path.splitext(self._printer.get_stat('print_stats','filename'))[0])
|
||||
self.filename = self._printer.get_stat('print_stats', 'filename')
|
||||
self.update_text("file", os.path.splitext(self._printer.get_stat('print_stats', 'filename'))[0])
|
||||
self.update_percent_complete()
|
||||
self.update_file_metadata()
|
||||
|
||||
@@ -569,8 +562,8 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.file_metadata = self._files.get_file_info(self.filename)
|
||||
logging.info("Update Metadata. File: %s Size: %s" % (self.filename, self.file_metadata['size']))
|
||||
if "estimated_time" in self.file_metadata and self.timeleft_type == "slicer":
|
||||
self.update_text("est_time","/ %s" %
|
||||
str(self._gtk.formatTimeString(self.file_metadata['estimated_time'])))
|
||||
self.update_text("est_time", "/ %s" %
|
||||
str(self._gtk.formatTimeString(self.file_metadata['estimated_time'])))
|
||||
if "thumbnails" in self.file_metadata:
|
||||
tmp = self.file_metadata['thumbnails'].copy()
|
||||
for i in tmp:
|
||||
@@ -586,16 +579,16 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.labels[label]['l'].set_text(text)
|
||||
|
||||
def update_percent_complete(self):
|
||||
if self.state in ["cancelling","cancelled","complete","error"]:
|
||||
if self.state in ["cancelling", "cancelled", "complete", "error"]:
|
||||
return
|
||||
|
||||
if "gcode_start_byte" in self.file_metadata:
|
||||
progress = (max(self._printer.get_stat('virtual_sdcard','file_position') -
|
||||
self.file_metadata['gcode_start_byte'],0) / (self.file_metadata['gcode_end_byte'] -
|
||||
self.file_metadata['gcode_start_byte']))
|
||||
progress = (max(self._printer.get_stat('virtual_sdcard', 'file_position') -
|
||||
self.file_metadata['gcode_start_byte'], 0) / (self.file_metadata['gcode_end_byte'] -
|
||||
self.file_metadata['gcode_start_byte']))
|
||||
else:
|
||||
progress = self._printer.get_stat('virtual_sdcard','progress')
|
||||
progress = round(progress,2)
|
||||
progress = self._printer.get_stat('virtual_sdcard', 'progress')
|
||||
progress = round(progress, 2)
|
||||
|
||||
if progress != self.progress:
|
||||
self.progress = progress
|
||||
@@ -606,16 +599,12 @@ class JobStatusPanel(ScreenPanel):
|
||||
if label in self.labels:
|
||||
self.labels[label].set_text(text)
|
||||
|
||||
def update_progress (self):
|
||||
self.labels['progress_text'].set_text("%s%%" % (str( min(int(self.progress*100),100) )))
|
||||
def update_progress(self):
|
||||
self.labels['progress_text'].set_text("%s%%" % (str(min(int(self.progress*100), 100))))
|
||||
|
||||
def update_message (self):
|
||||
def update_message(self):
|
||||
msg = self._printer.get_stat("display_status", "message")
|
||||
self.labels['lcdmessage'].set_text("" if msg == None else msg)
|
||||
|
||||
#def update_temp(self, dev, temp, target):
|
||||
# if dev in self.labels:
|
||||
# self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
self.labels['lcdmessage'].set_text("" if msg is None else msg)
|
||||
|
||||
def update_temp(self, x, temp, target):
|
||||
self.labels[x].set_markup(
|
||||
|
||||
+9
-7
@@ -45,7 +45,7 @@ class MainPanel(MenuPanel):
|
||||
i = 0
|
||||
cols = 3 if len(self.heaters) > 4 else (1 if len(self.heaters) <= 2 else 2)
|
||||
for h in self.heaters:
|
||||
eq_grid.attach(self.labels[h], i%cols, int(i/cols), 1, 1)
|
||||
eq_grid.attach(self.labels[h], i % cols, int(i/cols), 1, 1)
|
||||
i += 1
|
||||
|
||||
self.items = items
|
||||
@@ -78,14 +78,16 @@ class MainPanel(MenuPanel):
|
||||
return
|
||||
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
self.update_temp(
|
||||
x,
|
||||
self._printer.get_dev_stat(x, "temperature"),
|
||||
self._printer.get_dev_stat(x, "target")
|
||||
)
|
||||
for h in self._printer.get_heaters():
|
||||
self.update_temp(h,
|
||||
self._printer.get_dev_stat(h,"temperature"),
|
||||
self._printer.get_dev_stat(h,"target"),
|
||||
self.update_temp(
|
||||
h,
|
||||
self._printer.get_dev_stat(h, "temperature"),
|
||||
self._printer.get_dev_stat(h, "target"),
|
||||
None if h == "heater_bed" else " ".join(h.split(" ")[1:])
|
||||
)
|
||||
return
|
||||
+11
-11
@@ -31,11 +31,11 @@ class MenuPanel(ScreenPanel):
|
||||
})
|
||||
self.arrangeMenuItems(self.items, 4)
|
||||
|
||||
def arrangeMenuItems (self, items, columns, expandLast=False):
|
||||
def arrangeMenuItems(self, items, columns, expandLast=False):
|
||||
for child in self.grid.get_children():
|
||||
self.grid.remove(child)
|
||||
|
||||
l = len(items)
|
||||
length = len(items)
|
||||
i = 0
|
||||
for item in items:
|
||||
key = list(item)[0]
|
||||
@@ -47,7 +47,7 @@ class MenuPanel(ScreenPanel):
|
||||
row = int(i/columns)
|
||||
width = 1
|
||||
|
||||
if expandLast == True and i+1 == l and l%2 == 1:
|
||||
if expandLast is True and i+1 == length and length % 2 == 1:
|
||||
width = 2
|
||||
|
||||
self.grid.attach(self.labels[key], col, row, width, 1)
|
||||
@@ -66,13 +66,13 @@ class MenuPanel(ScreenPanel):
|
||||
parsed_name = j2_temp.render()
|
||||
|
||||
b = self._gtk.ButtonImage(
|
||||
item['icon'], parsed_name, "color"+str((i%4)+1)
|
||||
item['icon'], parsed_name, "color"+str((i % 4)+1)
|
||||
)
|
||||
if item['panel'] != False:
|
||||
if item['panel'] is not False:
|
||||
b.connect("clicked", self.menu_item_clicked, item['panel'], item)
|
||||
elif item['method'] != False:
|
||||
params = item['params'] if item['params'] != False else {}
|
||||
if item['confirm'] != False:
|
||||
elif item['method'] is not False:
|
||||
params = item['params'] if item['params'] is not False else {}
|
||||
if item['confirm'] is not False:
|
||||
b.connect("clicked", self._screen._confirm_send_action, item['confirm'], item['method'], params)
|
||||
else:
|
||||
b.connect("clicked", self._screen._send_action, item['method'], params)
|
||||
@@ -81,9 +81,9 @@ class MenuPanel(ScreenPanel):
|
||||
self.labels[key] = b
|
||||
|
||||
def evaluate_enable(self, enable):
|
||||
if enable == True:
|
||||
if enable is True:
|
||||
return True
|
||||
if enable == False:
|
||||
if enable is False:
|
||||
return False
|
||||
|
||||
try:
|
||||
@@ -94,6 +94,6 @@ class MenuPanel(ScreenPanel):
|
||||
if result == 'True':
|
||||
return True
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Error evaluating enable statement: %s", enable)
|
||||
return False
|
||||
+7
-9
@@ -12,7 +12,7 @@ def create_panel(*args):
|
||||
|
||||
class MovePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['.1','.5','1','5','10','25','50']
|
||||
distances = ['.1', '.5', '1', '5', '10', '25', '50']
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
@@ -52,7 +52,7 @@ class MovePanel(ScreenPanel):
|
||||
grid.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.distances:
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].set_direction(Gtk.TextDirection.LTR)
|
||||
@@ -71,10 +71,6 @@ class MovePanel(ScreenPanel):
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
#space_grid = self._gtk.HomogeneousGrid()
|
||||
#space_grid.attach(Gtk.Label("Distance (mm):"),0,0,1,1)
|
||||
#space_grid.attach(distgrid,0,1,1,1)
|
||||
#space_grid.attach(Gtk.Label(" "),0,2,1,1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
bottomgrid = self._gtk.HomogeneousGrid()
|
||||
@@ -126,8 +122,10 @@ class MovePanel(ScreenPanel):
|
||||
|
||||
dist = str(self.distance) if dir == "+" else "-" + str(self.distance)
|
||||
speed = self._config.get_config()['main'].getint("move_speed", 20)
|
||||
speed = min(max(1,speed),200) # Cap movement speed between 1-200mm/s
|
||||
speed = min(max(1, speed), 200) # Cap movement speed between 1-200mm/s
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"%s\n%s %s%s F%s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
|
||||
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") == True else "")
|
||||
"%s\n%s %s%s F%s%s" % (
|
||||
KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
|
||||
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") is True else ""
|
||||
)
|
||||
)
|
||||
+40
-41
@@ -7,7 +7,6 @@ import re
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
def create_panel(*args):
|
||||
@@ -54,7 +53,7 @@ class NetworkPanel(ScreenPanel):
|
||||
sbox.set_hexpand(True)
|
||||
sbox.set_vexpand(False)
|
||||
sbox.add(self.labels['interface'])
|
||||
#sbox.add(self.labels['disconnect'])
|
||||
# sbox.add(self.labels['disconnect'])
|
||||
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
@@ -67,7 +66,7 @@ class NetworkPanel(ScreenPanel):
|
||||
self.labels['networklist'] = Gtk.Grid()
|
||||
self.files = {}
|
||||
|
||||
if self._screen.wifi != None and self._screen.wifi.is_initialized():
|
||||
if self._screen.wifi is not None and self._screen.wifi.is_initialized():
|
||||
box.pack_start(sbox, False, False, 0)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
|
||||
@@ -104,7 +103,7 @@ class NetworkPanel(ScreenPanel):
|
||||
def add_network(self, ssid, show=True):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if ssid == None:
|
||||
if ssid is None:
|
||||
return
|
||||
ssid = ssid.strip()
|
||||
|
||||
@@ -113,7 +112,7 @@ class NetworkPanel(ScreenPanel):
|
||||
return
|
||||
|
||||
netinfo = self._screen.wifi.get_network_info(ssid)
|
||||
if netinfo == None:
|
||||
if netinfo is None:
|
||||
logging.debug("Couldn't get netinfo")
|
||||
return
|
||||
|
||||
@@ -124,7 +123,7 @@ class NetworkPanel(ScreenPanel):
|
||||
network_id = net
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
|
||||
@@ -137,7 +136,7 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
info = Gtk.Label()
|
||||
info.set_halign(Gtk.Align.START)
|
||||
#info.set_markup(self.get_file_info_str(ssid))
|
||||
# info.set_markup(self.get_file_info_str(ssid))
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
labels.add(info)
|
||||
@@ -145,14 +144,14 @@ class NetworkPanel(ScreenPanel):
|
||||
labels.set_valign(Gtk.Align.CENTER)
|
||||
labels.set_halign(Gtk.Align.START)
|
||||
|
||||
connect = self._gtk.ButtonImage("load",None,"color3")
|
||||
connect = self._gtk.ButtonImage("load", None, "color3")
|
||||
connect.connect("clicked", self.connect_network, ssid)
|
||||
connect.set_hexpand(False)
|
||||
connect.set_halign(Gtk.Align.END)
|
||||
|
||||
delete = self._gtk.ButtonImage("delete","","color3")
|
||||
delete = self._gtk.ButtonImage("delete", "", "color3")
|
||||
delete.connect("clicked", self.remove_wifi_network, ssid)
|
||||
delete.set_size_request(60,0)
|
||||
delete.set_size_request(60, 0)
|
||||
delete.set_hexpand(False)
|
||||
delete.set_halign(Gtk.Align.END)
|
||||
|
||||
@@ -165,7 +164,7 @@ class NetworkPanel(ScreenPanel):
|
||||
buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
if network_id != -1:
|
||||
buttons.pack_end(delete, False, False, 0)
|
||||
if netinfo['connected'] == False:
|
||||
if netinfo['connected'] is False:
|
||||
buttons.pack_end(connect, False, False, 0)
|
||||
|
||||
network.add(buttons)
|
||||
@@ -176,17 +175,17 @@ class NetworkPanel(ScreenPanel):
|
||||
reverse = False
|
||||
|
||||
pos = 0
|
||||
if netinfo['connected'] == True:
|
||||
if netinfo['connected'] is True:
|
||||
pos = 0
|
||||
else:
|
||||
connected_ssid = self._screen.wifi.get_connected_ssid()
|
||||
nets = list(self.networks)
|
||||
if connected_ssid != None:
|
||||
if connected_ssid is not None:
|
||||
if connected_ssid in nets:
|
||||
nets.remove(connected_ssid)
|
||||
nets = sorted(nets, reverse=reverse)
|
||||
pos = nets.index(ssid)
|
||||
if connected_ssid != None:
|
||||
if connected_ssid is not None:
|
||||
pos += 1
|
||||
|
||||
self.labels['networks'][ssid] = {
|
||||
@@ -199,7 +198,7 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
self.labels['networklist'].insert_row(pos)
|
||||
self.labels['networklist'].attach(self.networks[ssid], 0, pos, 1, 1)
|
||||
if show == True:
|
||||
if show is True:
|
||||
self.labels['networklist'].show()
|
||||
|
||||
def add_new_network(self, widget, ssid, connect=False):
|
||||
@@ -209,14 +208,14 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
self.close_add_network()
|
||||
|
||||
if connect == True:
|
||||
if result == True:
|
||||
if connect is True:
|
||||
if result is True:
|
||||
self.connect_network(widget, ssid, False)
|
||||
else:
|
||||
self._screen.show_popup_message("Error adding network %s" % ssid)
|
||||
|
||||
def back(self):
|
||||
if self.show_add == True:
|
||||
if self.show_add is True:
|
||||
self.close_add_network()
|
||||
return True
|
||||
return False
|
||||
@@ -232,14 +231,14 @@ class NetworkPanel(ScreenPanel):
|
||||
self.labels['networklist'].show_all()
|
||||
|
||||
def close_add_network(self):
|
||||
if self.show_add == False:
|
||||
if self.show_add is False:
|
||||
return
|
||||
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels['main_box'])
|
||||
self.content.show()
|
||||
for i in ['add_network','network_psk']:
|
||||
for i in ['add_network', 'network_psk']:
|
||||
if i in self.labels:
|
||||
del self.labels[i]
|
||||
self.show_add = False
|
||||
@@ -249,9 +248,9 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
def connected_callback(self, ssid, prev_ssid):
|
||||
logging.info("Now connected to a new network")
|
||||
if ssid != None:
|
||||
if ssid is not None:
|
||||
self.remove_network(ssid)
|
||||
if prev_ssid != None:
|
||||
if prev_ssid is not None:
|
||||
self.remove_network(prev_ssid)
|
||||
|
||||
self.check_missing_networks()
|
||||
@@ -266,8 +265,8 @@ class NetworkPanel(ScreenPanel):
|
||||
isdef = True
|
||||
break
|
||||
|
||||
if isdef == False:
|
||||
if showadd == True:
|
||||
if isdef is False:
|
||||
if showadd is True:
|
||||
self.show_add_network(widget, ssid)
|
||||
return
|
||||
self.prev_network = self._screen.wifi.get_connected_ssid()
|
||||
@@ -280,7 +279,7 @@ class NetworkPanel(ScreenPanel):
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.set_size_request(800,400)
|
||||
scroll.set_size_request(800, 400)
|
||||
self.labels['connecting_info'] = Gtk.Label(_("Starting WiFi Re-association"))
|
||||
self.labels['connecting_info'].set_halign(Gtk.Align.START)
|
||||
self.labels['connecting_info'].set_valign(Gtk.Align.START)
|
||||
@@ -292,7 +291,7 @@ class NetworkPanel(ScreenPanel):
|
||||
self.remove_network(ssid)
|
||||
if self.prev_network in self.networks:
|
||||
self.remove_network(self.prev_network)
|
||||
#GLib.timeout_add(500, self.add_network, self.prev_network)
|
||||
# GLib.timeout_add(500, self.add_network, self.prev_network)
|
||||
|
||||
self._screen.wifi.add_callback("connecting_status", self.connecting_status_callback)
|
||||
self._screen.wifi.connect(ssid)
|
||||
@@ -306,7 +305,7 @@ class NetworkPanel(ScreenPanel):
|
||||
return
|
||||
|
||||
i = 0
|
||||
while self.labels['networklist'].get_child_at(0, i) != None:
|
||||
while self.labels['networklist'].get_child_at(0, i) is not None:
|
||||
if self.networks[ssid] == self.labels['networklist'].get_child_at(0, i):
|
||||
self.labels['networklist'].remove_row(i)
|
||||
self.labels['networklist'].show()
|
||||
@@ -332,7 +331,7 @@ class NetworkPanel(ScreenPanel):
|
||||
self.content.show_all()
|
||||
|
||||
def show_add_network(self, widget, ssid):
|
||||
if self.show_add == True:
|
||||
if self.show_add is True:
|
||||
return
|
||||
|
||||
_ = self.lang.gettext
|
||||
@@ -347,23 +346,23 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
box = Gtk.Box(spacing=5)
|
||||
box.set_size_request(self._gtk.get_content_width(), self._gtk.get_content_height() -
|
||||
self._screen.keyboard_height - 20)
|
||||
self._screen.keyboard_height - 20)
|
||||
box.set_hexpand(True)
|
||||
box.set_vexpand(False)
|
||||
self.labels['add_network'].add(box)
|
||||
|
||||
l = self._gtk.Label("%s %s:" % (_("PSK for"), ssid))
|
||||
l.set_hexpand(False)
|
||||
label = self._gtk.Label("%s %s:" % (_("PSK for"), ssid))
|
||||
label.set_hexpand(False)
|
||||
entry = Gtk.Entry()
|
||||
entry.set_hexpand(True)
|
||||
|
||||
save = self._gtk.ButtonImage("sd",_("Save"),"color3")
|
||||
save = self._gtk.ButtonImage("sd", _("Save"), "color3")
|
||||
save.set_hexpand(False)
|
||||
save.connect("clicked", self.add_new_network, ssid, True)
|
||||
|
||||
|
||||
self.labels['network_psk'] = entry
|
||||
box.pack_start(l, False, False, 5)
|
||||
box.pack_start(label, False, False, 5)
|
||||
box.pack_start(entry, True, True, 5)
|
||||
box.pack_start(save, False, False, 5)
|
||||
|
||||
@@ -386,12 +385,12 @@ class NetworkPanel(ScreenPanel):
|
||||
if ssid not in self.networks or ssid not in self.labels['networks']:
|
||||
return
|
||||
netinfo = self._screen.wifi.get_network_info(ssid)
|
||||
if netinfo == None:
|
||||
if netinfo is None:
|
||||
logging.debug("Couldn't get netinfo for update")
|
||||
return
|
||||
|
||||
connected = ""
|
||||
if netinfo['connected'] == True:
|
||||
if netinfo['connected'] is True:
|
||||
stream = os.popen('hostname -f')
|
||||
hostname = stream.read().strip()
|
||||
ifadd = netifaces.ifaddresses(self.interface)
|
||||
@@ -401,15 +400,15 @@ class NetworkPanel(ScreenPanel):
|
||||
ipv4 = "<b>%s:</b> %s " % (_("IPv4"), ifadd[netifaces.AF_INET][0]['addr'])
|
||||
if netifaces.AF_INET6 in ifadd and len(ifadd[netifaces.AF_INET6]) > 0:
|
||||
ipv6 = ipv6 = "<b>%s:</b> %s " % (_("IPv6"), ifadd[netifaces.AF_INET6][0]['addr'].split('%')[0])
|
||||
connected = "<b>%s</b>\n<b>%s:</b> %s\n%s%s\n" % (_("Connected"),_("Hostname"),hostname, ipv4, ipv6)
|
||||
connected = "<b>%s</b>\n<b>%s:</b> %s\n%s%s\n" % (_("Connected"), _("Hostname"), hostname, ipv4, ipv6)
|
||||
elif "psk" in netinfo:
|
||||
connected = "Password saved."
|
||||
freq = "2.4 GHz" if netinfo['frequency'][0:1] == "2" else "5 Ghz"
|
||||
|
||||
self.labels['networks'][ssid]['info'].set_markup("%s%s <small>%s %s %s %s%s</small>" % ( connected,
|
||||
"" if netinfo['encryption'] == "off" else netinfo['encryption'].upper(),
|
||||
self.labels['networks'][ssid]['info'].set_markup("%s%s <small>%s %s %s %s%s</small>" % (
|
||||
connected, "" if netinfo['encryption'] == "off" else netinfo['encryption'].upper(),
|
||||
freq, _("Channel"), netinfo['channel'], netinfo['signal_level_dBm'], _("dBm")
|
||||
))
|
||||
))
|
||||
self.labels['networks'][ssid]['info'].show_all()
|
||||
|
||||
def update_single_network_info(self):
|
||||
@@ -424,8 +423,8 @@ class NetworkPanel(ScreenPanel):
|
||||
ipv4 = "<b>%s:</b> %s " % (_("IPv4"), ifadd[netifaces.AF_INET][0]['addr'])
|
||||
if netifaces.AF_INET6 in ifadd and len(ifadd[netifaces.AF_INET6]) > 0:
|
||||
ipv6 = ipv6 = "<b>%s:</b> %s " % (_("IPv6"), ifadd[netifaces.AF_INET6][0]['addr'].split('%')[0])
|
||||
connected = "<b>%s</b>\n\n<small><b>%s</b></small>\n<b>%s:</b> %s\n%s\n%s\n" % (self.interface, _("Connected"),_("Hostname"),
|
||||
hostname, ipv4, ipv6)
|
||||
connected = "<b>%s</b>\n\n<small><b>%s</b></small>\n<b>%s:</b> %s\n%s\n%s\n" % (
|
||||
self.interface, _("Connected"), _("Hostname"), hostname, ipv4, ipv6)
|
||||
|
||||
self.labels['networkinfo'].set_markup(connected)
|
||||
self.labels['networkinfo'].show_all()
|
||||
+1
-1
@@ -37,7 +37,7 @@ class PowerPanel(ScreenPanel):
|
||||
|
||||
def add_device(self, device):
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
|
||||
+23
-21
@@ -47,35 +47,35 @@ class PreheatPanel(ScreenPanel):
|
||||
cols = 3 if len(self.heaters) > 4 else (1 if len(self.heaters) <= 2 else 2)
|
||||
for h in self.heaters:
|
||||
self.labels[h].connect('clicked', self.select_heater, h)
|
||||
eq_grid.attach(self.labels[h], i%cols, int(i/cols), 1, 1)
|
||||
eq_grid.attach(self.labels[h], i % cols, int(i/cols), 1, 1)
|
||||
i += 1
|
||||
|
||||
|
||||
self.labels["control_grid"] = self._gtk.HomogeneousGrid()
|
||||
|
||||
i = 0
|
||||
for option in self.preheat_options:
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i%4)+1))
|
||||
for option in self.preheat_options:
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4)+1))
|
||||
self.labels[option].connect("clicked", self.set_temperature, option)
|
||||
self.labels['control_grid'].attach(
|
||||
self.labels[option],
|
||||
i%2, int(i/2), 1, 1)
|
||||
i % 2, int(i/2), 1, 1)
|
||||
i += 1
|
||||
|
||||
|
||||
cooldown = self._gtk.ButtonImage('cool-down', _('Cooldown'), "color%d" % ((i%4)+1))
|
||||
cooldown = self._gtk.ButtonImage('cool-down', _('Cooldown'), "color%d" % ((i % 4)+1))
|
||||
cooldown.connect("clicked", self.set_temperature, "cooldown")
|
||||
|
||||
row = int(i/2) if i%2 == 0 else int(i/2)+1
|
||||
self.labels["control_grid"].attach(cooldown, i%2, int(i/2), 1, 1)
|
||||
row = int(i/2) if i % 2 == 0 else int(i/2)+1
|
||||
self.labels["control_grid"].attach(cooldown, i % 2, int(i/2), 1, 1)
|
||||
|
||||
i += 1
|
||||
temperature = self._gtk.ButtonImage('heat-up', _('Temperature'), "color%d" % ((i%4)+1))
|
||||
temperature = self._gtk.ButtonImage('heat-up', _('Temperature'), "color%d" % ((i % 4)+1))
|
||||
temperature.connect("clicked", self.menu_item_clicked, "temperature", {
|
||||
"name": "Temperature",
|
||||
"panel": "temperature"
|
||||
})
|
||||
self.labels["control_grid"].attach(temperature, i%2, int(i/2), 1, 1)
|
||||
self.labels["control_grid"].attach(temperature, i % 2, int(i/2), 1, 1)
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
@@ -112,39 +112,41 @@ class PreheatPanel(ScreenPanel):
|
||||
self._screen._ws.klippy.set_heater_temp(" ".join(heater.split(" ")[1:]), 0)
|
||||
elif heater.startswith('heater_bed'):
|
||||
self._screen._ws.klippy.set_bed_temp(0)
|
||||
self._printer.set_dev_stat(heater,"target", 0)
|
||||
self._printer.set_dev_stat(heater, "target", 0)
|
||||
else:
|
||||
self._screen._ws.klippy.set_tool_temp(self._printer.get_tool_number(heater), 0)
|
||||
self._printer.set_dev_stat(heater,"target", 0)
|
||||
self._printer.set_dev_stat(heater, "target", 0)
|
||||
return
|
||||
|
||||
for heater in self.active_heaters:
|
||||
if heater.startswith('heater_generic '):
|
||||
logging.info("Setting %s to %d" % (heater, self.preheat_options[setting]['heater_generic']))
|
||||
self._screen._ws.klippy.set_heater_temp(" ".join(heater.split(" ")[1:]),
|
||||
self.preheat_options[setting]["heater_generic"])
|
||||
self.preheat_options[setting]["heater_generic"])
|
||||
elif heater.startswith('heater_bed'):
|
||||
logging.info("Setting %s to %d" % (heater, self.preheat_options[setting]['bed']))
|
||||
self._screen._ws.klippy.set_bed_temp(self.preheat_options[setting]["bed"])
|
||||
self._printer.set_dev_stat(heater,"target", int(self.preheat_options[setting]["bed"]))
|
||||
self._printer.set_dev_stat(heater, "target", int(self.preheat_options[setting]["bed"]))
|
||||
else:
|
||||
logging.info("Setting %s to %d" % (heater, self.preheat_options[setting]['extruder']))
|
||||
self._screen._ws.klippy.set_tool_temp(self._printer.get_tool_number(heater),
|
||||
self.preheat_options[setting]["extruder"])
|
||||
self._printer.set_dev_stat(heater,"target", int(self.preheat_options[setting]["extruder"]))
|
||||
self.preheat_options[setting]["extruder"])
|
||||
self._printer.set_dev_stat(heater, "target", int(self.preheat_options[setting]["extruder"]))
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
self.update_temp(
|
||||
x,
|
||||
self._printer.get_dev_stat(x, "temperature"),
|
||||
self._printer.get_dev_stat(x, "target")
|
||||
)
|
||||
for h in self._printer.get_heaters():
|
||||
self.update_temp(h,
|
||||
self._printer.get_dev_stat(h,"temperature"),
|
||||
self._printer.get_dev_stat(h,"target"),
|
||||
self.update_temp(
|
||||
h,
|
||||
self._printer.get_dev_stat(h, "temperature"),
|
||||
self._printer.get_dev_stat(h, "target"),
|
||||
None if h == "heater_bed" else " ".join(h.split(" ")[1:])
|
||||
)
|
||||
+34
-32
@@ -17,7 +17,7 @@ def create_panel(*args):
|
||||
class PrintPanel(ScreenPanel):
|
||||
cur_directory = "gcodes"
|
||||
dir_panels = {}
|
||||
filelist = {'gcodes':{'directories':[],'files':[]}}
|
||||
filelist = {'gcodes': {'directories': [], 'files': []}}
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@@ -27,13 +27,13 @@ class PrintPanel(ScreenPanel):
|
||||
"name": _("Name"),
|
||||
"date": _("Date")
|
||||
}
|
||||
self.sort_char = ["↑","↓"]
|
||||
self.sort_char = ["↑", "↓"]
|
||||
|
||||
sortdir = self._config.get_main_config_option("print_sort_dir","name_asc")
|
||||
sortdir = self._config.get_main_config_option("print_sort_dir", "name_asc")
|
||||
sortdir = sortdir.split('_')
|
||||
if sortdir[0] not in ["name","date"] or sortdir[1] not in ["asc","desc"]:
|
||||
sortdir = ["name","asc"]
|
||||
self.sort_current = [sortdir[0], 0 if sortdir[1] == "asc" else 1] # 0 for asc, 1 for desc
|
||||
if sortdir[0] not in ["name", "date"] or sortdir[1] not in ["asc", "desc"]:
|
||||
sortdir = ["name", "asc"]
|
||||
self.sort_current = [sortdir[0], 0 if sortdir[1] == "asc" else 1] # 0 for asc, 1 for desc
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
@@ -46,7 +46,7 @@ class PrintPanel(ScreenPanel):
|
||||
sbox.add(sort)
|
||||
i = 1
|
||||
for name, val in self.sort_items.items():
|
||||
s = self._gtk.Button(val, "color%s" % (i%4))
|
||||
s = self._gtk.Button(val, "color%s" % (i % 4))
|
||||
s.set_label(val)
|
||||
if name == sortdir[0]:
|
||||
s.set_label("%s %s" % (s.get_label(), self.sort_char[self.sort_current[1]]))
|
||||
@@ -95,12 +95,12 @@ class PrintPanel(ScreenPanel):
|
||||
def add_directory(self, directory, show=True):
|
||||
parent_dir = '/'.join(directory.split('/')[:-1])
|
||||
if directory not in self.filelist:
|
||||
self.filelist[directory] = {'directories':[],'files':[],'modified': 0}
|
||||
self.filelist[directory] = {'directories': [], 'files': [], 'modified': 0}
|
||||
self.filelist[parent_dir]['directories'].append(directory)
|
||||
|
||||
if directory not in self.labels['directories']:
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
@@ -120,7 +120,7 @@ class PrintPanel(ScreenPanel):
|
||||
labels.set_valign(Gtk.Align.CENTER)
|
||||
labels.set_halign(Gtk.Align.START)
|
||||
|
||||
actions = self._gtk.ButtonImage("load",None,"color3")
|
||||
actions = self._gtk.ButtonImage("load", None, "color3")
|
||||
actions.connect("clicked", self.change_dir, directory)
|
||||
actions.set_hexpand(False)
|
||||
actions.set_halign(Gtk.Align.END)
|
||||
@@ -149,21 +149,21 @@ class PrintPanel(ScreenPanel):
|
||||
reverse = False if self.sort_current[1] == 0 else True
|
||||
if self.sort_current[0] == "date":
|
||||
dirs = sorted(self.filelist[parent_dir]['directories'], reverse=reverse,
|
||||
key=lambda item: self.filelist[item]['modified'])
|
||||
key=lambda item: self.filelist[item]['modified'])
|
||||
else:
|
||||
dirs = sorted(self.filelist[parent_dir]['directories'], reverse=reverse)
|
||||
pos = dirs.index(directory)
|
||||
|
||||
self.dir_panels[parent_dir].insert_row(pos)
|
||||
self.dir_panels[parent_dir].attach(self.directories[directory], 0, pos, 1, 1)
|
||||
if show == True:
|
||||
if show is True:
|
||||
self.dir_panels[parent_dir].show_all()
|
||||
|
||||
def add_file(self, filepath, show=True):
|
||||
_ = self.lang.gettext
|
||||
|
||||
fileinfo = self._screen.files.get_file_info(filepath)
|
||||
if fileinfo == None:
|
||||
if fileinfo is None:
|
||||
return
|
||||
|
||||
dir = ("gcodes/%s" % filepath).split('/')[:-1]
|
||||
@@ -180,13 +180,14 @@ class PrintPanel(ScreenPanel):
|
||||
curdir = "/".join(dir[0:i+1])
|
||||
if curdir != "gcodes" and fileinfo['modified'] > self.filelist[curdir]['modified']:
|
||||
self.filelist[curdir]['modified'] = fileinfo['modified']
|
||||
self.labels['directories'][curdir]['info'].set_markup("<small>%s: <b>%s</b></small>" %
|
||||
self.labels['directories'][curdir]['info'].set_markup(
|
||||
"<small>%s: <b>%s</b></small>" %
|
||||
(_("Modified"), datetime.fromtimestamp(fileinfo['modified']).strftime("%Y-%m-%d %H:%M")))
|
||||
self.filelist[directory]['files'].append(filename)
|
||||
|
||||
if filepath not in self.files:
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
@@ -206,7 +207,7 @@ class PrintPanel(ScreenPanel):
|
||||
labels.set_valign(Gtk.Align.CENTER)
|
||||
labels.set_halign(Gtk.Align.START)
|
||||
|
||||
actions = self._gtk.ButtonImage("print",None,"color3")
|
||||
actions = self._gtk.ButtonImage("print", None, "color3")
|
||||
actions.connect("clicked", self.confirm_print, filepath)
|
||||
actions.set_hexpand(False)
|
||||
actions.set_halign(Gtk.Align.END)
|
||||
@@ -217,7 +218,7 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
icon = self._gtk.Image("file.svg", False, 1.6, 1.6)
|
||||
pixbuf = self.get_file_image(filepath)
|
||||
if pixbuf != None:
|
||||
if pixbuf is not None:
|
||||
icon.set_from_pixbuf(pixbuf)
|
||||
|
||||
file.add(icon)
|
||||
@@ -234,8 +235,10 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
reverse = False if self.sort_current[1] == 0 else True
|
||||
if self.sort_current[0] == "date":
|
||||
files = sorted(self.filelist[directory]['files'], reverse=reverse,
|
||||
key=lambda item: self._screen.files.get_file_info(("%s/%s" %(directory,item))[7:])['modified'])
|
||||
files = sorted(
|
||||
self.filelist[directory]['files'], reverse=reverse,
|
||||
key=lambda item: self._screen.files.get_file_info(("%s/%s" % (directory, item))[7:])['modified']
|
||||
)
|
||||
else:
|
||||
files = sorted(self.filelist[directory]['files'], reverse=reverse)
|
||||
pos = files.index(filename)
|
||||
@@ -243,7 +246,7 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
self.dir_panels[directory].insert_row(pos)
|
||||
self.dir_panels[directory].attach(self.files[filepath], 0, pos, 1, 1)
|
||||
if show == True:
|
||||
if show is True:
|
||||
self.dir_panels[directory].show_all()
|
||||
|
||||
def back(self):
|
||||
@@ -284,8 +287,8 @@ class PrintPanel(ScreenPanel):
|
||||
def confirm_print(self, widget, filename):
|
||||
_ = self.lang.gettext
|
||||
buttons = [
|
||||
{"name":_("Print"), "response": Gtk.ResponseType.OK},
|
||||
{"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL}
|
||||
{"name": _("Print"), "response": Gtk.ResponseType.OK},
|
||||
{"name": _("Cancel"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
@@ -302,16 +305,15 @@ class PrintPanel(ScreenPanel):
|
||||
grid.set_size_request(self._screen.width - 60, -1)
|
||||
|
||||
pixbuf = self.get_file_image(filename, 8, 3.2)
|
||||
if pixbuf != None:
|
||||
if pixbuf is not None:
|
||||
image = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
grid.attach_next_to(image, label, Gtk.PositionType.BOTTOM, 1, 3)
|
||||
|
||||
#table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
|
||||
grid.set_vexpand(True)
|
||||
grid.set_halign(Gtk.Align.CENTER)
|
||||
grid.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, grid, self.confirm_print_response, filename)
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, grid, self.confirm_print_response, filename)
|
||||
|
||||
def confirm_print_response(self, widget, response_id, filename):
|
||||
widget.destroy()
|
||||
@@ -352,7 +354,7 @@ class PrintPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
fileinfo = self._screen.files.get_file_info(filename)
|
||||
if fileinfo == None:
|
||||
if fileinfo is None:
|
||||
return
|
||||
|
||||
return "<small>%s: <b>%s</b> - %s: <b>%s</b>\n%s: <b>%s</b></small>" % (
|
||||
@@ -364,9 +366,9 @@ class PrintPanel(ScreenPanel):
|
||||
self.get_print_time(filename)
|
||||
)
|
||||
|
||||
def get_print_time (self, filename):
|
||||
def get_print_time(self, filename):
|
||||
fileinfo = self._screen.files.get_file_info(filename)
|
||||
if fileinfo == None:
|
||||
if fileinfo is None:
|
||||
return
|
||||
|
||||
if "estimated_time" in fileinfo:
|
||||
@@ -379,17 +381,17 @@ class PrintPanel(ScreenPanel):
|
||||
print_str = "%sd " % print_val
|
||||
|
||||
# Take remainder from days and divide by hours
|
||||
print_val = int((print_time%86400)/3600)
|
||||
print_val = int((print_time % 86400)/3600)
|
||||
if print_val > 0:
|
||||
print_str = "%s%sh " % (print_str, print_val)
|
||||
|
||||
print_val = int(((print_time%86400)%3600)/60)
|
||||
print_val = int(((print_time % 86400) % 3600)/60)
|
||||
print_str = "%s%sm" % (print_str, print_val)
|
||||
return print_str
|
||||
return "Unavailable"
|
||||
|
||||
def reload_files(self, widget=None):
|
||||
self.filelist = {'gcodes':{'directories':[],'files':[]}}
|
||||
self.filelist = {'gcodes': {'directories': [], 'files': []}}
|
||||
for dirpan in self.dir_panels:
|
||||
for child in self.dir_panels[dirpan].get_children():
|
||||
self.dir_panels[dirpan].remove(child)
|
||||
@@ -408,7 +410,7 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
# Update icon
|
||||
pixbuf = self.get_file_image(filename)
|
||||
if pixbuf != None:
|
||||
if pixbuf is not None:
|
||||
self.labels['files'][filename]['icon'].set_from_pixbuf(pixbuf)
|
||||
|
||||
def _callback(self, newfiles, deletedfiles, updatedfiles=[]):
|
||||
|
||||
@@ -27,7 +27,7 @@ class PrinterSelect(ScreenPanel):
|
||||
i = 1
|
||||
for printer in printers:
|
||||
name = list(printer)[0]
|
||||
self.labels[name] = self._gtk.ButtonImage("extruder",name,"color%s" % (i%4))
|
||||
self.labels[name] = self._gtk.ButtonImage("extruder", name, "color%s" % (i % 4))
|
||||
self.labels[name].connect("clicked", self._screen.connect_printer_widget, name)
|
||||
box.add(self.labels[name])
|
||||
i += 1
|
||||
@@ -19,8 +19,8 @@ class ScreenSaverPanel(ScreenPanel):
|
||||
box.set_vexpand(True)
|
||||
box.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
l = Gtk.Label(_("Screen will show in less than one second"))
|
||||
box.add(l)
|
||||
label = Gtk.Label(_("Screen will show in less than one second"))
|
||||
box.add(label)
|
||||
|
||||
|
||||
self.layout = box
|
||||
+6
-13
@@ -24,7 +24,6 @@ class SettingsPanel(ScreenPanel):
|
||||
printbox = Gtk.Box(spacing=0)
|
||||
printbox.set_vexpand(False)
|
||||
self.labels['add_printer_button'] = self._gtk.Button(_("Add Printer"), "color1")
|
||||
#printbox.add(self.labels['add_printer_button'])
|
||||
self.labels['printers_box'] = self.create_box('printers', printbox)
|
||||
|
||||
options = self._config.get_configurable_options().copy()
|
||||
@@ -40,7 +39,7 @@ class SettingsPanel(ScreenPanel):
|
||||
}})
|
||||
|
||||
for option in options:
|
||||
name = list(option)[0]
|
||||
name = list(option)[0]
|
||||
self.add_option('main', self.settings, name, option[name])
|
||||
|
||||
for macro in self._printer.get_config_section_list("gcode_macro "):
|
||||
@@ -98,11 +97,11 @@ class SettingsPanel(ScreenPanel):
|
||||
return box
|
||||
|
||||
def add_option(self, boxname, opt_array, opt_name, option):
|
||||
if option['type'] == None:
|
||||
if option['type'] is None:
|
||||
return
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
@@ -114,11 +113,6 @@ class SettingsPanel(ScreenPanel):
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
#open = self._gtk.ButtonImage("resume",None,"color3")
|
||||
#open.connect("clicked", self.run_gcode_macro, macro)
|
||||
#open.set_hexpand(False)
|
||||
#open.set_halign(Gtk.Align.END)
|
||||
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
|
||||
@@ -139,7 +133,7 @@ class SettingsPanel(ScreenPanel):
|
||||
else:
|
||||
switch.set_active(self._config.get_config().getboolean(option['section'], opt_name))
|
||||
switch.connect("notify::active", self.switch_config_option, option['section'], opt_name,
|
||||
option['callback'] if "callback" in option else None)
|
||||
option['callback'] if "callback" in option else None)
|
||||
switch.set_property("width-request", round(self._gtk.get_image_width()*2.5))
|
||||
switch.set_property("height-request", round(self._gtk.get_image_height()*1.25))
|
||||
box.add(switch)
|
||||
@@ -153,8 +147,7 @@ class SettingsPanel(ScreenPanel):
|
||||
dropdown.set_active(i)
|
||||
i += 1
|
||||
dropdown.connect("changed", self.on_dropdown_change, option['section'], opt_name,
|
||||
option['callback'] if "callback" in option else None)
|
||||
#dropdown.props.relief = Gtk.ReliefStyle.NONE
|
||||
option['callback'] if "callback" in option else None)
|
||||
dropdown.set_entry_text_column(0)
|
||||
dev.add(dropdown)
|
||||
logging.debug("Children: %s" % dropdown.get_children())
|
||||
@@ -176,7 +169,7 @@ class SettingsPanel(ScreenPanel):
|
||||
box.add(label)
|
||||
dev.add(box)
|
||||
elif option['type'] == "menu":
|
||||
open = self._gtk.ButtonImage("settings",None,"color3")
|
||||
open = self._gtk.ButtonImage("settings", None, "color3")
|
||||
open.connect("clicked", self.load_menu, option['menu'])
|
||||
open.set_hexpand(False)
|
||||
open.set_halign(Gtk.Align.END)
|
||||
|
||||
@@ -44,7 +44,6 @@ class SplashScreenPanel(ScreenPanel):
|
||||
main.pack_end(self.labels['text'], True, True, 0)
|
||||
|
||||
self.content.add(main)
|
||||
#self.layout.put(box, 0, 0)
|
||||
|
||||
def update_text(self, text):
|
||||
self.labels['text'].set_text(text)
|
||||
@@ -58,20 +57,20 @@ class SplashScreenPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if "firmware_restart" not in self.labels:
|
||||
self.labels['printer_select'] = self._gtk.ButtonImage("shuffle",_("Change Printer"))
|
||||
self.labels['printer_select'] = self._gtk.ButtonImage("shuffle", _("Change Printer"))
|
||||
self.labels['printer_select'].connect("clicked", self._screen.show_printer_select)
|
||||
self.labels['menu'] = self._gtk.ButtonImage("settings",_("Menu"),"color4")
|
||||
self.labels['menu'] = self._gtk.ButtonImage("settings", _("Menu"), "color4")
|
||||
self.labels['menu'].connect("clicked", self._screen._go_to_submenu, "")
|
||||
self.labels['power'] = self._gtk.ButtonImage("shutdown",_("Power On Printer"),"color3")
|
||||
self.labels['restart'] = self._gtk.ButtonImage("refresh",_("Restart"),"color1")
|
||||
self.labels['power'] = self._gtk.ButtonImage("shutdown", _("Power On Printer"), "color3")
|
||||
self.labels['restart'] = self._gtk.ButtonImage("refresh", _("Restart"), "color1")
|
||||
self.labels['restart'].connect("clicked", self.restart)
|
||||
self.labels['firmware_restart'] = self._gtk.ButtonImage("refresh",_("Firmware Restart"),"color2")
|
||||
self.labels['firmware_restart'] = self._gtk.ButtonImage("refresh", _("Firmware Restart"), "color2")
|
||||
self.labels['firmware_restart'].connect("clicked", self.firmware_restart)
|
||||
|
||||
self.clear_action_bar()
|
||||
|
||||
devices = [i for i in self._printer.get_power_devices() if i.lower().startswith('printer')] if (
|
||||
self._printer is not None) else []
|
||||
self._printer is not None) else []
|
||||
logging.debug("Power devices: %s" % devices)
|
||||
if len(devices) > 0:
|
||||
logging.debug("Adding power button")
|
||||
|
||||
+24
-24
@@ -12,7 +12,8 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
def create_panel(*args):
|
||||
return SystemPanel(*args)
|
||||
|
||||
ALLOWED_SERVICES = ["KlipperScreen","MoonCord","klipper","moonraker"]
|
||||
|
||||
ALLOWED_SERVICES = ["KlipperScreen", "MoonCord", "klipper", "moonraker"]
|
||||
|
||||
class SystemPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
@@ -21,20 +22,20 @@ class SystemPanel(ScreenPanel):
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
grid.set_row_homogeneous(False)
|
||||
|
||||
restart = self._gtk.ButtonImage('refresh',"\n".join(_('Klipper Restart').split(' ')),'color1')
|
||||
restart = self._gtk.ButtonImage('refresh', "\n".join(_('Klipper Restart').split(' ')), 'color1')
|
||||
restart.connect("clicked", self.restart_klippy)
|
||||
restart.set_vexpand(False)
|
||||
firmrestart = self._gtk.ButtonImage('refresh',"\n".join(_('Firmware Restart').split(' ')),'color2')
|
||||
firmrestart = self._gtk.ButtonImage('refresh', "\n".join(_('Firmware Restart').split(' ')), 'color2')
|
||||
firmrestart.connect("clicked", self.restart_klippy, "firmware")
|
||||
firmrestart.set_vexpand(False)
|
||||
|
||||
reboot = self._gtk.ButtonImage('refresh',_('System\nRestart'),'color3')
|
||||
reboot = self._gtk.ButtonImage('refresh', _('System\nRestart'), 'color3')
|
||||
reboot.connect("clicked", self._screen._confirm_send_action,
|
||||
_("Are you sure you wish to reboot the system?"), "machine.reboot")
|
||||
_("Are you sure you wish to reboot the system?"), "machine.reboot")
|
||||
reboot.set_vexpand(False)
|
||||
shutdown = self._gtk.ButtonImage('shutdown',_('System\nShutdown'),'color4')
|
||||
shutdown = self._gtk.ButtonImage('shutdown', _('System\nShutdown'), 'color4')
|
||||
shutdown.connect("clicked", self._screen._confirm_send_action,
|
||||
_("Are you sure you wish to shutdown the system?"), "machine.shutdown")
|
||||
_("Are you sure you wish to shutdown the system?"), "machine.shutdown")
|
||||
shutdown.set_vexpand(False)
|
||||
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
@@ -42,9 +43,9 @@ class SystemPanel(ScreenPanel):
|
||||
info.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
self.labels['loadavg'] = Gtk.Label("temp")
|
||||
#self.system_timeout = GLib.timeout_add(1000, self.update_system_load)
|
||||
|
||||
self.labels['klipper_version'] = Gtk.Label(_("Klipper Version") +
|
||||
self.labels['klipper_version'] = Gtk.Label(
|
||||
_("Klipper Version") +
|
||||
(": %s" % self._screen.printer.get_klipper_version()))
|
||||
self.labels['klipper_version'].set_margin_top(15)
|
||||
|
||||
@@ -64,7 +65,7 @@ class SystemPanel(ScreenPanel):
|
||||
update_resp = self._screen.apiclient.send_request("machine/update/status")
|
||||
self.update_status = False
|
||||
|
||||
if update_resp == False:
|
||||
if update_resp is False:
|
||||
logging.info("No update manager configured")
|
||||
else:
|
||||
self.update_status = update_resp['result']
|
||||
@@ -79,15 +80,14 @@ class SystemPanel(ScreenPanel):
|
||||
self.labels["%s_status" % prog] = self._gtk.Button()
|
||||
self.labels["%s_status" % prog].set_hexpand(False)
|
||||
self.labels["%s_status" % prog].connect("clicked", self.show_commit_history, prog)
|
||||
self.labels["%s_info" % prog] = self._gtk.ButtonImage("info",None, None, .7, .7)
|
||||
self.labels["%s_info" % prog] = self._gtk.ButtonImage("info", None, None, .7, .7)
|
||||
self.labels["%s_info" % prog].connect("clicked", self.show_commit_history, prog)
|
||||
|
||||
if prog in ALLOWED_SERVICES:
|
||||
self.labels["%s_restart" % prog] = self._gtk.ButtonImage("refresh",None, None, .7, .7)
|
||||
self.labels["%s_restart" % prog] = self._gtk.ButtonImage("refresh", None, None, .7, .7)
|
||||
self.labels["%s_restart" % prog].connect("clicked", self.restart, prog)
|
||||
infogrid.attach(self.labels["%s_restart" % prog], 0, i, 1, 1)
|
||||
|
||||
#infogrid.attach(self.labels["%s_info" % prog], 2, i, 1, 1)
|
||||
infogrid.attach(self.labels["%s_status" % prog], 2, i, 1, 1)
|
||||
logging.info("Updating program: %s " % prog)
|
||||
self.update_program_info(prog)
|
||||
@@ -120,7 +120,7 @@ class SystemPanel(ScreenPanel):
|
||||
|
||||
def get_updates(self):
|
||||
update_resp = self._screen.apiclient.send_request("machine/update/status")
|
||||
if update_resp == False:
|
||||
if update_resp is False:
|
||||
logging.info("No update manager configured")
|
||||
else:
|
||||
self.update_status = update_resp['result']
|
||||
@@ -134,12 +134,12 @@ class SystemPanel(ScreenPanel):
|
||||
logging.info("Update: %s" % data)
|
||||
if 'application' in data and data['application'] == self.update_prog:
|
||||
self.labels['update_progress'].set_text(self.labels['update_progress'].get_text().strip() + "\n" +
|
||||
data['message'] + "\n")
|
||||
data['message'] + "\n")
|
||||
adjustment = self.labels['update_scroll'].get_vadjustment()
|
||||
adjustment.set_value( adjustment.get_upper() - adjustment.get_page_size() )
|
||||
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size())
|
||||
adjustment = self.labels['update_scroll'].show_all()
|
||||
|
||||
if data['complete'] == True:
|
||||
if data['complete'] is True:
|
||||
self.update_dialog.set_response_sensitive(Gtk.ResponseType.CANCEL, True)
|
||||
|
||||
def restart(self, widget, program):
|
||||
@@ -152,7 +152,7 @@ class SystemPanel(ScreenPanel):
|
||||
def show_commit_history(self, widget, program):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if self.update_status == False or program not in self.update_status['version_info']:
|
||||
if self.update_status is False or program not in self.update_status['version_info']:
|
||||
return
|
||||
|
||||
info = self.update_status['version_info'][program]
|
||||
@@ -160,8 +160,8 @@ class SystemPanel(ScreenPanel):
|
||||
return
|
||||
|
||||
buttons = [
|
||||
{"name":_("Update"), "response": Gtk.ResponseType.OK},
|
||||
{"name":_("Go Back"), "response": Gtk.ResponseType.CANCEL}
|
||||
{"name": _("Update"), "response": Gtk.ResponseType.OK},
|
||||
{"name": _("Go Back"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
@@ -183,7 +183,7 @@ class SystemPanel(ScreenPanel):
|
||||
i = i + 1
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup("%s\n<i>%s</i> %s %s\n" % (c['subject'], c['author'], _("Commited"),"2 days ago"))
|
||||
label.set_markup("%s\n<i>%s</i> %s %s\n" % (c['subject'], c['author'], _("Commited"), "2 days ago"))
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.START)
|
||||
grid.attach(label, 0, i, 1, 1)
|
||||
@@ -205,7 +205,7 @@ class SystemPanel(ScreenPanel):
|
||||
|
||||
_ = self.lang.gettext
|
||||
|
||||
if self.update_status == False or program not in self.update_status['version_info']:
|
||||
if self.update_status is False or program not in self.update_status['version_info']:
|
||||
return
|
||||
|
||||
info = self.update_status['version_info'][program]
|
||||
@@ -218,7 +218,7 @@ class SystemPanel(ScreenPanel):
|
||||
return
|
||||
|
||||
buttons = [
|
||||
{"name":_("Finish"), "response": Gtk.ResponseType.CANCEL}
|
||||
{"name": _("Finish"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
@@ -237,7 +237,7 @@ class SystemPanel(ScreenPanel):
|
||||
self.update_prog = program
|
||||
self.update_dialog = dialog
|
||||
|
||||
if program in ['klipper','moonraker','system']:
|
||||
if program in ['klipper', 'moonraker', 'system']:
|
||||
logging.info("Sending machine.update.%s" % program)
|
||||
self._screen._ws.send_method("machine.update.%s" % program)
|
||||
else:
|
||||
|
||||
+33
-31
@@ -13,7 +13,7 @@ def create_panel(*args):
|
||||
|
||||
class TemperaturePanel(ScreenPanel):
|
||||
active_heater = "extruder"
|
||||
tempdeltas = ["1","5","10","25"]
|
||||
tempdeltas = ["1", "5", "10", "25"]
|
||||
tempdelta = "10"
|
||||
|
||||
def initialize(self, panel_name):
|
||||
@@ -52,24 +52,24 @@ class TemperaturePanel(ScreenPanel):
|
||||
for h in self.heaters:
|
||||
if not (h.startswith("temperature_sensor")):
|
||||
self.labels[h].connect('clicked', self.select_heater, h)
|
||||
eq_grid.attach(self.labels[h], i%cols, int(i/cols), 1, 1)
|
||||
eq_grid.attach(self.labels[h], i % cols, int(i/cols), 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels["control_grid"] = self._gtk.HomogeneousGrid()
|
||||
|
||||
self.labels["increase"] = self._gtk.ButtonImage("increase", _("Increase"), "color1")
|
||||
self.labels["increase"].connect("clicked",self.change_target_temp, "+")
|
||||
self.labels["increase"].connect("clicked", self.change_target_temp, "+")
|
||||
self.labels["decrease"] = self._gtk.ButtonImage("decrease", _("Decrease"), "color3")
|
||||
self.labels["decrease"].connect("clicked",self.change_target_temp, "-")
|
||||
self.labels["decrease"].connect("clicked", self.change_target_temp, "-")
|
||||
self.labels["npad"] = self._gtk.ButtonImage("hashtag", _("Number Pad"), "color2")
|
||||
self.labels["npad"].connect("clicked", self.show_numpad)
|
||||
|
||||
tempgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.tempdeltas:
|
||||
self.labels['deg'+ i] = self._gtk.ToggleButton(i)
|
||||
self.labels['deg'+ i].connect("clicked", self.change_temp_delta, i)
|
||||
ctx = self.labels['deg'+ i].get_style_context()
|
||||
self.labels['deg' + i] = self._gtk.ToggleButton(i)
|
||||
self.labels['deg' + i].connect("clicked", self.change_temp_delta, i)
|
||||
ctx = self.labels['deg' + i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("tempbutton_top")
|
||||
elif j == len(self.tempdeltas)-1:
|
||||
@@ -78,7 +78,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
ctx.add_class("tempbutton")
|
||||
if i == "10":
|
||||
ctx.add_class("distbutton_active")
|
||||
tempgrid.attach(self.labels['deg'+ i], 0, j, 1, 1)
|
||||
tempgrid.attach(self.labels['deg' + i], 0, j, 1, 1)
|
||||
j += 1
|
||||
|
||||
self.labels["deg" + self.tempdelta].set_active(True)
|
||||
@@ -100,7 +100,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
self.update_temp("heater_bed",35,40)
|
||||
self.update_temp("heater_bed", 35, 40)
|
||||
|
||||
def change_temp_delta(self, widget, tempdelta):
|
||||
if self.tempdelta == tempdelta:
|
||||
@@ -125,18 +125,18 @@ class TemperaturePanel(ScreenPanel):
|
||||
numpad.set_direction(Gtk.TextDirection.LTR)
|
||||
|
||||
keys = [
|
||||
['1','numpad_tleft'],
|
||||
['2','numpad_top'],
|
||||
['3','numpad_tright'],
|
||||
['4','numpad_left'],
|
||||
['5','numpad_button'],
|
||||
['6','numpad_right'],
|
||||
['7','numpad_left'],
|
||||
['8','numpad_button'],
|
||||
['9','numpad_right'],
|
||||
['B','numpad_bleft'],
|
||||
['0','numpad_bottom'],
|
||||
['E','numpad_bright']
|
||||
['1', 'numpad_tleft'],
|
||||
['2', 'numpad_top'],
|
||||
['3', 'numpad_tright'],
|
||||
['4', 'numpad_left'],
|
||||
['5', 'numpad_button'],
|
||||
['6', 'numpad_right'],
|
||||
['7', 'numpad_left'],
|
||||
['8', 'numpad_button'],
|
||||
['9', 'numpad_right'],
|
||||
['B', 'numpad_bleft'],
|
||||
['0', 'numpad_bottom'],
|
||||
['E', 'numpad_bright']
|
||||
]
|
||||
for i in range(len(keys)):
|
||||
id = 'button_' + str(keys[i][0])
|
||||
@@ -147,9 +147,9 @@ class TemperaturePanel(ScreenPanel):
|
||||
else:
|
||||
self.labels[id] = Gtk.Button(keys[i][0])
|
||||
self.labels[id].connect('clicked', self.update_entry, keys[i][0])
|
||||
ctx=self.labels[id].get_style_context()
|
||||
ctx = self.labels[id].get_style_context()
|
||||
ctx.add_class(keys[i][1])
|
||||
numpad.attach(self.labels[id], i%3, i/3, 1, 1)
|
||||
numpad.attach(self.labels[id], i % 3, i/3, 1, 1)
|
||||
|
||||
self.labels["keypad"] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.labels['entry'] = Gtk.Entry()
|
||||
@@ -176,7 +176,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
self.grid.show_all()
|
||||
|
||||
|
||||
def select_heater (self, widget, heater):
|
||||
def select_heater(self, widget, heater):
|
||||
if self.active_heater == heater:
|
||||
return
|
||||
|
||||
@@ -194,14 +194,16 @@ class TemperaturePanel(ScreenPanel):
|
||||
return
|
||||
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
self.update_temp(
|
||||
x,
|
||||
self._printer.get_dev_stat(x, "temperature"),
|
||||
self._printer.get_dev_stat(x, "target")
|
||||
)
|
||||
for h in self._printer.get_heaters():
|
||||
self.update_temp(h,
|
||||
self._printer.get_dev_stat(h,"temperature"),
|
||||
self._printer.get_dev_stat(h,"target"),
|
||||
self.update_temp(
|
||||
h,
|
||||
self._printer.get_dev_stat(h, "temperature"),
|
||||
self._printer.get_dev_stat(h, "target"),
|
||||
None if h == "heater_bed" else " ".join(h.split(" ")[1:])
|
||||
)
|
||||
return
|
||||
|
||||
@@ -15,7 +15,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
_screen = None
|
||||
labels = {}
|
||||
distance = 1
|
||||
distances = ['.01','.05','.1','.5','1','5']
|
||||
distances = ['.01', '.05', '.1', '.5', '1', '5']
|
||||
|
||||
def __init__(self, screen, title, back=True):
|
||||
super().__init__(screen, title, False)
|
||||
@@ -33,13 +33,13 @@ class ZCalibratePanel(ScreenPanel):
|
||||
box.add(label)
|
||||
box.add(self.labels['zposition'])
|
||||
|
||||
zpos = self._gtk.ButtonImage('z-farther',_("Raise Nozzle"))
|
||||
zpos = self._gtk.ButtonImage('z-farther', _("Raise Nozzle"))
|
||||
zpos.connect("clicked", self.move, "+")
|
||||
zneg = self._gtk.ButtonImage('z-closer',_("Lower Nozzle"))
|
||||
zneg = self._gtk.ButtonImage('z-closer', _("Lower Nozzle"))
|
||||
zneg.connect("clicked", self.move, "-")
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
j = 0
|
||||
for i in self.distances:
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].set_direction(Gtk.TextDirection.LTR)
|
||||
@@ -63,10 +63,10 @@ class ZCalibratePanel(ScreenPanel):
|
||||
bottombox.pack_start(self.labels['move_dist'], True, True, 0)
|
||||
bottombox.pack_start(distgrid, True, True, 0)
|
||||
|
||||
complete = self._gtk.ButtonImage('complete',_('Accept'),'color4')
|
||||
complete = self._gtk.ButtonImage('complete', _('Accept'), 'color4')
|
||||
complete.connect("clicked", self.accept)
|
||||
|
||||
b = self._gtk.ButtonImage('cancel', _('Abort'),'color2')
|
||||
b = self._gtk.ButtonImage('cancel', _('Abort'), 'color2')
|
||||
b.connect("clicked", self.abort)
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def activate(self):
|
||||
if self._screen.printer.get_stat("toolhead","homed_axes") != "xyz":
|
||||
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE)
|
||||
|
||||
@@ -95,7 +95,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
self.updatePosition(data['toolhead']['position'])
|
||||
|
||||
def updatePosition(self, position):
|
||||
self.labels['zposition'].set_text(str(round(position[2],2)))
|
||||
self.labels['zposition'].set_text(str(round(position[2], 2)))
|
||||
|
||||
def change_distance(self, widget, distance):
|
||||
if self.distance == distance:
|
||||
|
||||
@@ -119,7 +119,8 @@ class KlipperScreen(Gtk.Window):
|
||||
logging.info("Screen resolution: %sx%s" % (self.width, self.height))
|
||||
|
||||
self.theme = self._config.get_main_config_option('theme')
|
||||
self.gtk = KlippyGtk(self, self.width, self.height, self.theme, self._config.get_main_config().getboolean("show_cursor", fallback=False))
|
||||
self.gtk = KlippyGtk(self, self.width, self.height, self.theme,
|
||||
self._config.get_main_config().getboolean("show_cursor", fallback=False))
|
||||
self.keyboard_height = self.gtk.get_keyboard_height()
|
||||
self.init_style()
|
||||
|
||||
@@ -146,7 +147,7 @@ class KlipperScreen(Gtk.Window):
|
||||
pname = list(self._config.get_printers()[0])[0]
|
||||
self.connect_printer(pname)
|
||||
else:
|
||||
self.show_panel("printer_select","printer_select","Printer Select", 2)
|
||||
self.show_panel("printer_select", "printer_select", "Printer Select", 2)
|
||||
|
||||
def connect_printer_widget(self, widget, name):
|
||||
self.connect_printer(name)
|
||||
@@ -155,8 +156,8 @@ class KlipperScreen(Gtk.Window):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if self.connected_printer == name:
|
||||
if self.printer_select_prepanel != None:
|
||||
self.show_panel(self.printer_select_prepanel, "","", 2)
|
||||
if self.printer_select_prepanel is not None:
|
||||
self.show_panel(self.printer_select_prepanel, "", "", 2)
|
||||
self.printer_select_prepanel = None
|
||||
while len(self.printer_select_callbacks) > 0:
|
||||
i = self.printer_select_callbacks.pop(0)
|
||||
@@ -219,19 +220,19 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
powerdevs = self.apiclient.send_request("machine/device_power/devices")
|
||||
logging.debug("Found power devices: %s" % powerdevs)
|
||||
if powerdevs != False:
|
||||
if powerdevs is not False:
|
||||
self.printer.configure_power_devices(powerdevs['result'])
|
||||
self.panels['splash_screen'].show_restart_buttons()
|
||||
|
||||
self._ws = KlippyWebsocket(self,
|
||||
{
|
||||
"on_connect": self.init_printer,
|
||||
"on_message": self._websocket_callback,
|
||||
"on_close": self.printer_initializing
|
||||
},
|
||||
data["moonraker_host"],
|
||||
data["moonraker_port"]
|
||||
)
|
||||
{
|
||||
"on_connect": self.init_printer,
|
||||
"on_message": self._websocket_callback,
|
||||
"on_close": self.printer_initializing
|
||||
},
|
||||
data["moonraker_host"],
|
||||
data["moonraker_port"]
|
||||
)
|
||||
self.files = KlippyFiles(self)
|
||||
self._ws.initial_connect()
|
||||
self.connecting = False
|
||||
@@ -242,30 +243,30 @@ class KlipperScreen(Gtk.Window):
|
||||
def ws_subscribe(self):
|
||||
requested_updates = {
|
||||
"objects": {
|
||||
"bed_mesh": ["profile_name","mesh_max","mesh_min","probed_matrix"],
|
||||
"bed_mesh": ["profile_name", "mesh_max", "mesh_min", "probed_matrix"],
|
||||
"configfile": ["config"],
|
||||
"display_status": ["progress","message"],
|
||||
"display_status": ["progress", "message"],
|
||||
"fan": ["speed"],
|
||||
"gcode_move": ["extrude_factor","gcode_position","homing_origin","speed_factor"],
|
||||
"gcode_move": ["extrude_factor", "gcode_position", "homing_origin", "speed_factor"],
|
||||
"idle_timeout": ["state"],
|
||||
"pause_resume": ["is_paused"],
|
||||
"print_stats": ["print_duration","total_duration","filament_used","filename","state","message"],
|
||||
"toolhead": ["homed_axes","estimated_print_time","print_time","position","extruder"],
|
||||
"virtual_sdcard": ["file_position","is_active","progress"],
|
||||
"webhooks": ["state","state_message"]
|
||||
"print_stats": ["print_duration", "total_duration", "filament_used", "filename", "state", "message"],
|
||||
"toolhead": ["homed_axes", "estimated_print_time", "print_time", "position", "extruder"],
|
||||
"virtual_sdcard": ["file_position", "is_active", "progress"],
|
||||
"webhooks": ["state", "state_message"]
|
||||
}
|
||||
}
|
||||
for extruder in self.printer.get_tools():
|
||||
requested_updates['objects'][extruder] = ["target","temperature","pressure_advance","smooth_time"]
|
||||
requested_updates['objects'][extruder] = ["target", "temperature", "pressure_advance", "smooth_time"]
|
||||
for h in self.printer.get_heaters():
|
||||
requested_updates['objects'][h] = ["target","temperature"]
|
||||
requested_updates['objects'][h] = ["target", "temperature"]
|
||||
for f in self.printer.get_fans():
|
||||
requested_updates['objects'][f] = ["speed"]
|
||||
|
||||
self._ws.klippy.object_subscription(requested_updates)
|
||||
|
||||
def _load_panel(self, panel, *args):
|
||||
if not panel in self.load_panel:
|
||||
if panel not in self.load_panel:
|
||||
logging.debug("Loading panel: %s" % panel)
|
||||
panel_path = os.path.join(os.path.dirname(__file__), 'panels', "%s.py" % panel)
|
||||
logging.info("Panel path: %s" % panel_path)
|
||||
@@ -297,14 +298,14 @@ class KlipperScreen(Gtk.Window):
|
||||
self.panels[panel_name].initialize(panel_name, **kwargs)
|
||||
else:
|
||||
self.panels[panel_name].initialize(panel_name)
|
||||
except:
|
||||
except Exception:
|
||||
if panel_name in self.panels:
|
||||
del self.panels[panel_name]
|
||||
logging.exception("Unable to load panel %s" % type)
|
||||
self.show_error_modal("Unable to load panel %s" % type)
|
||||
return
|
||||
|
||||
if hasattr(self.panels[panel_name],"process_update"):
|
||||
if hasattr(self.panels[panel_name], "process_update"):
|
||||
self.panels[panel_name].process_update("notify_status_update", self.printer.get_data())
|
||||
|
||||
try:
|
||||
@@ -323,19 +324,19 @@ class KlipperScreen(Gtk.Window):
|
||||
self.base_panel.show_back(True)
|
||||
self.show_all()
|
||||
|
||||
if hasattr(self.panels[panel_name],"process_update"):
|
||||
if hasattr(self.panels[panel_name], "process_update"):
|
||||
self.panels[panel_name].process_update("notify_status_update", self.printer.get_updates())
|
||||
if hasattr(self.panels[panel_name],"activate"):
|
||||
if hasattr(self.panels[panel_name], "activate"):
|
||||
self.panels[panel_name].activate()
|
||||
self.show_all()
|
||||
except:
|
||||
except Exception:
|
||||
logging.exception("Error attaching panel")
|
||||
|
||||
self._cur_panels.append(panel_name)
|
||||
logging.debug("Current panel hierarchy: %s", str(self._cur_panels))
|
||||
|
||||
def show_popup_message(self, message):
|
||||
if self.popup_message != None:
|
||||
if self.popup_message is not None:
|
||||
self.close_popup_message()
|
||||
|
||||
box = Gtk.Box()
|
||||
@@ -357,7 +358,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
cur_panel = self.panels[self._cur_panels[-1]]
|
||||
|
||||
self.base_panel.get().put(box, 0,0)
|
||||
self.base_panel.get().put(box, 0, 0)
|
||||
|
||||
self.show_all()
|
||||
self.popup_message = box
|
||||
@@ -367,7 +368,7 @@ class KlipperScreen(Gtk.Window):
|
||||
return False
|
||||
|
||||
def close_popup_message(self, widget=None):
|
||||
if self.popup_message == None:
|
||||
if self.popup_message is None:
|
||||
return
|
||||
|
||||
self.base_panel.get().remove(self.popup_message)
|
||||
@@ -379,11 +380,12 @@ class KlipperScreen(Gtk.Window):
|
||||
logging.exception("Showing error modal: %s", err)
|
||||
|
||||
buttons = [
|
||||
{"name":_("Go Back"),"response": Gtk.ResponseType.CANCEL}
|
||||
{"name": _("Go Back"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup(("%s \n\n" % err) +
|
||||
label.set_markup(
|
||||
("%s \n\n" % err) +
|
||||
_("Check /tmp/KlipperScreen.log for more information.\nPlease submit an issue on GitHub for help."))
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
@@ -392,7 +394,7 @@ class KlipperScreen(Gtk.Window):
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self.error_modal_response)
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self.error_modal_response)
|
||||
|
||||
def error_modal_response(self, widget, response_id):
|
||||
widget.destroy()
|
||||
@@ -415,7 +417,7 @@ class KlipperScreen(Gtk.Window):
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self.restart_ks)
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self.restart_ks)
|
||||
|
||||
def restart_ks(self, widget, response_id):
|
||||
if response_id == Gtk.ResponseType.OK:
|
||||
@@ -432,13 +434,13 @@ class KlipperScreen(Gtk.Window):
|
||||
css.close()
|
||||
|
||||
self.font_size = self.gtk.get_font_size()
|
||||
fontsize_type = self._config.get_main_config_option("font_size","medium")
|
||||
fontsize_type = self._config.get_main_config_option("font_size", "medium")
|
||||
if fontsize_type != "medium":
|
||||
if fontsize_type == "small":
|
||||
self.font_size = round(self.font_size * 0.91)
|
||||
elif (fontsize_type == "large"):
|
||||
self.font_size = round(self.font_size * 1.09)
|
||||
css_data = css_data.replace("KS_FONT_SIZE",str(self.font_size))
|
||||
css_data = css_data.replace("KS_FONT_SIZE", str(self.font_size))
|
||||
|
||||
style_provider = Gtk.CssProvider()
|
||||
style_provider.load_from_data(css_data.encode())
|
||||
@@ -450,7 +452,7 @@ class KlipperScreen(Gtk.Window):
|
||||
)
|
||||
|
||||
def is_keyboard_showing(self):
|
||||
if self.keyboard == None:
|
||||
if self.keyboard is None:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -462,7 +464,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
def _go_to_submenu(self, widget, name):
|
||||
logging.info("#### Go to submenu " + str(name))
|
||||
#self._remove_current_panel(False)
|
||||
# self._remove_current_panel(False)
|
||||
|
||||
# Find current menu item
|
||||
panels = list(self._cur_panels)
|
||||
@@ -481,7 +483,7 @@ class KlipperScreen(Gtk.Window):
|
||||
return
|
||||
|
||||
self.show_panel(self._cur_panels[-1] + '_' + name, "menu", disname, 1, False, display_name=disname,
|
||||
items=menuitems)
|
||||
items=menuitems)
|
||||
|
||||
def _remove_all_panels(self):
|
||||
while len(self._cur_panels) > 0:
|
||||
@@ -491,18 +493,18 @@ class KlipperScreen(Gtk.Window):
|
||||
def _remove_current_panel(self, pop=True, show=True):
|
||||
if len(self._cur_panels) > 0:
|
||||
self.base_panel.remove(self.panels[self._cur_panels[-1]].get_content())
|
||||
if pop ==True:
|
||||
if pop is True:
|
||||
self._cur_panels.pop()
|
||||
if len(self._cur_panels) > 0:
|
||||
self.base_panel.add_content(self.panels[self._cur_panels[-1]])
|
||||
self.base_panel.show_back(False if len(self._cur_panels) == 1 else True)
|
||||
if hasattr(self.panels[self._cur_panels[-1]], "process_update"):
|
||||
self.panels[self._cur_panels[-1]].process_update("notify_status_update",
|
||||
self.printer.get_updates())
|
||||
if show == True:
|
||||
self.printer.get_updates())
|
||||
if show is True:
|
||||
self.show_all()
|
||||
|
||||
def _menu_go_back (self, widget=None):
|
||||
def _menu_go_back(self, widget=None):
|
||||
logging.info("#### Menu go back")
|
||||
self.remove_keyboard()
|
||||
self.close_popup_message()
|
||||
@@ -515,7 +517,7 @@ class KlipperScreen(Gtk.Window):
|
||||
while len(self._cur_panels) > 1:
|
||||
self._remove_current_panel()
|
||||
|
||||
def add_subscription (self, panel_name):
|
||||
def add_subscription(self, panel_name):
|
||||
add = True
|
||||
for sub in self.subscriptions:
|
||||
if sub == panel_name:
|
||||
@@ -523,7 +525,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
self.subscriptions.append(panel_name)
|
||||
|
||||
def remove_subscription (self, panel_name):
|
||||
def remove_subscription(self, panel_name):
|
||||
for i in range(len(self.subscriptions)):
|
||||
if self.subscriptions[i] == panel_name:
|
||||
self.subscriptions.pop(i)
|
||||
@@ -551,13 +553,13 @@ class KlipperScreen(Gtk.Window):
|
||||
os.system("xset -display :0 s off")
|
||||
os.system("xset -display :0 s noblank")
|
||||
|
||||
if functions.dpms_loaded == False:
|
||||
if functions.dpms_loaded is False:
|
||||
logging.info("DPMS functions not loaded. Unable to protect on button click when DPMS is enabled.")
|
||||
|
||||
|
||||
logging.debug("Changing power save to: %s" % time)
|
||||
if time == "off":
|
||||
if self.dpms_timeout != None:
|
||||
if self.dpms_timeout is not None:
|
||||
GLib.source_remove(self.dpms_timeout)
|
||||
self.dpms_timeout = None
|
||||
os.system("xset -display :0 -dpms")
|
||||
@@ -567,11 +569,11 @@ class KlipperScreen(Gtk.Window):
|
||||
if time < 0:
|
||||
return
|
||||
os.system("xset -display :0 dpms 0 %s 0" % time)
|
||||
if self.dpms_timeout == None and functions.dpms_loaded == True:
|
||||
if self.dpms_timeout is None and functions.dpms_loaded is True:
|
||||
self.dpms_timeout = GLib.timeout_add(1000, self.check_dpms_state)
|
||||
|
||||
def set_updating(self, updating=False):
|
||||
if self.updating == True and updating == False:
|
||||
if self.updating is True and updating is False:
|
||||
if len(self.update_queue) > 0:
|
||||
i = self.update_queue.pop()
|
||||
self.update_queue = []
|
||||
@@ -582,7 +584,7 @@ class KlipperScreen(Gtk.Window):
|
||||
def show_printer_select(self, widget=None):
|
||||
logging.debug("Saving panel: %s" % self._cur_panels[0])
|
||||
self.printer_select_prepanel = self._cur_panels[0]
|
||||
self.show_panel("printer_select","printer_select","Printer Select", 2)
|
||||
self.show_panel("printer_select", "printer_select", "Printer Select", 2)
|
||||
self.base_panel.show_macro_shortcut(False)
|
||||
|
||||
def state_execute(self, callback, prev_state):
|
||||
@@ -602,9 +604,9 @@ class KlipperScreen(Gtk.Window):
|
||||
self.printer_initializing(_("Klipper has disconnected"))
|
||||
|
||||
for panel in list(self.panels):
|
||||
if panel in ["printer_select","splash_screen"]:
|
||||
if panel in ["printer_select", "splash_screen"]:
|
||||
continue
|
||||
#del self.panels[panel]
|
||||
# del self.panels[panel]
|
||||
|
||||
def state_error(self, prev_state):
|
||||
if "printer_select" in self._cur_panels:
|
||||
@@ -613,7 +615,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
_ = self.lang.gettext
|
||||
self.base_panel.show_macro_shortcut(False)
|
||||
msg = self.printer.get_stat("webhooks","state_message")
|
||||
msg = self.printer.get_stat("webhooks", "state_message")
|
||||
if "FIRMWARE_RESTART" in msg:
|
||||
self.printer_initializing(
|
||||
_("Klipper has encountered an error.\nIssue a FIRMWARE_RESTART to attempt fixing the issue.")
|
||||
@@ -628,7 +630,7 @@ class KlipperScreen(Gtk.Window):
|
||||
)
|
||||
|
||||
for panel in list(self.panels):
|
||||
if panel in ["printer_select","splash_screen"]:
|
||||
if panel in ["printer_select", "splash_screen"]:
|
||||
continue
|
||||
del self.panels[panel]
|
||||
|
||||
@@ -656,7 +658,7 @@ class KlipperScreen(Gtk.Window):
|
||||
return
|
||||
|
||||
self.base_panel.show_macro_shortcut(self._config.get_main_config_option('side_macro_shortcut'))
|
||||
if prev_state not in ['paused','printing']:
|
||||
if prev_state not in ['paused', 'printing']:
|
||||
self.init_printer()
|
||||
self.base_panel._printer = self.printer
|
||||
self.base_panel.show_heaters()
|
||||
@@ -681,7 +683,7 @@ class KlipperScreen(Gtk.Window):
|
||||
self.printer_initializing(_("Klipper has shutdown"))
|
||||
|
||||
def toggle_macro_shortcut(self, value):
|
||||
if value == True:
|
||||
if value is True:
|
||||
self.base_panel.show_macro_shortcut(True, True)
|
||||
else:
|
||||
self.base_panel.show_macro_shortcut(False, True)
|
||||
@@ -689,7 +691,7 @@ class KlipperScreen(Gtk.Window):
|
||||
def _websocket_callback(self, action, data):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if self.connecting == True:
|
||||
if self.connecting is True:
|
||||
return
|
||||
|
||||
if action == "notify_klippy_disconnected":
|
||||
@@ -701,26 +703,26 @@ class KlipperScreen(Gtk.Window):
|
||||
elif action == "notify_status_update" and self.printer.get_state() != "shutdown":
|
||||
self.printer.process_update(data)
|
||||
elif action == "notify_filelist_changed":
|
||||
logging.debug("Filelist changed: %s", json.dumps(data,indent=2))
|
||||
if self.files != None:
|
||||
logging.debug("Filelist changed: %s", json.dumps(data, indent=2))
|
||||
if self.files is not None:
|
||||
self.files.process_update(data)
|
||||
elif action == "notify_metadata_update":
|
||||
self.files.request_metadata(data['filename'])
|
||||
elif action == "notify_update_response":
|
||||
logging.info("%s: %s" % (action,data))
|
||||
logging.info("%s: %s" % (action, data))
|
||||
elif action == "notify_power_changed":
|
||||
logging.debug("Power status changed: %s", data)
|
||||
self.printer.process_power_update(data)
|
||||
elif self.printer.get_state() not in ["error","shutdown"] and action == "notify_gcode_response":
|
||||
elif self.printer.get_state() not in ["error", "shutdown"] and action == "notify_gcode_response":
|
||||
if "Klipper state: Shutdown" in data:
|
||||
logging.debug("Shutdown in gcode response, changing state to shutdown")
|
||||
self.printer.change_state("shutdown")
|
||||
|
||||
if not (data.startswith("B:") and
|
||||
re.search(r'B:[0-9\.]+\s/[0-9\.]+\sT[0-9]+:[0-9\.]+', data)):
|
||||
re.search(r'B:[0-9\.]+\s/[0-9\.]+\sT[0-9]+:[0-9\.]+', data)):
|
||||
if data.startswith("!! "):
|
||||
self.show_popup_message(data[3:])
|
||||
#logging.debug(json.dumps([action, data], indent=2))
|
||||
# logging.debug(json.dumps([action, data], indent=2))
|
||||
|
||||
self.base_panel.process_update(action, data)
|
||||
if self._cur_panels[-1] in self.subscriptions:
|
||||
@@ -730,8 +732,8 @@ class KlipperScreen(Gtk.Window):
|
||||
_ = self.lang.gettext
|
||||
|
||||
buttons = [
|
||||
{"name":_("Continue"), "response": Gtk.ResponseType.OK},
|
||||
{"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL}
|
||||
{"name": _("Continue"), "response": Gtk.ResponseType.OK},
|
||||
{"name": _("Cancel"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
try:
|
||||
@@ -739,7 +741,7 @@ class KlipperScreen(Gtk.Window):
|
||||
env.install_gettext_translations(self.lang)
|
||||
j2_temp = env.from_string(text)
|
||||
text = j2_temp.render()
|
||||
except:
|
||||
except Exception:
|
||||
logging.debug("Error parsing jinja for confirm_send_action")
|
||||
|
||||
label = Gtk.Label()
|
||||
@@ -751,7 +753,7 @@ class KlipperScreen(Gtk.Window):
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self._confirm_send_action_response, method, params)
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self._confirm_send_action_response, method, params)
|
||||
|
||||
def _confirm_send_action_response(self, widget, response_id, method, params):
|
||||
if response_id == Gtk.ResponseType.OK:
|
||||
@@ -765,8 +767,8 @@ class KlipperScreen(Gtk.Window):
|
||||
def printer_initializing(self, text=None):
|
||||
self.shutdown = True
|
||||
self.close_popup_message()
|
||||
self.show_panel('splash_screen',"splash_screen", "Splash Screen", 2)
|
||||
if text != None:
|
||||
self.show_panel('splash_screen', "splash_screen", "Splash Screen", 2)
|
||||
if text is not None:
|
||||
self.panels['splash_screen'].update_text(text)
|
||||
self.panels['splash_screen'].show_restart_buttons()
|
||||
|
||||
@@ -774,18 +776,18 @@ class KlipperScreen(Gtk.Window):
|
||||
_ = self.lang.gettext
|
||||
|
||||
printer_info = self.apiclient.get_printer_info()
|
||||
if printer_info == False:
|
||||
if printer_info is False:
|
||||
logging.info("Unable to get printer info from moonraker")
|
||||
return False
|
||||
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS))
|
||||
if data == False:
|
||||
if data is False:
|
||||
logging.info("Error getting printer object data")
|
||||
return False
|
||||
powerdevs = self.apiclient.send_request("machine/device_power/devices")
|
||||
data = data['result']['status']
|
||||
|
||||
config = self.apiclient.send_request("printer/objects/query?configfile")
|
||||
if config == False:
|
||||
if config is False:
|
||||
logging.info("Error getting printer config data")
|
||||
return False
|
||||
|
||||
@@ -802,8 +804,8 @@ class KlipperScreen(Gtk.Window):
|
||||
extra_items.append(f)
|
||||
|
||||
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS +
|
||||
extra_items))
|
||||
if data == False:
|
||||
extra_items))
|
||||
if data is False:
|
||||
logging.info("Error getting printer object data")
|
||||
return False
|
||||
logging.info("Startup data: %s" % data['result']['status'])
|
||||
@@ -812,16 +814,16 @@ class KlipperScreen(Gtk.Window):
|
||||
self.files.initialize()
|
||||
self.files.refresh_files()
|
||||
|
||||
if powerdevs != False:
|
||||
if powerdevs is not False:
|
||||
self.printer.configure_power_devices(powerdevs['result'])
|
||||
|
||||
def printer_ready(self):
|
||||
_ = self.lang.gettext
|
||||
self.close_popup_message()
|
||||
# Force update to printer webhooks state in case the update is missed due to websocket subscribe not yet sent
|
||||
self.printer.process_update({"webhooks":{"state":"ready","state_message": "Printer is ready"}})
|
||||
self.printer.process_update({"webhooks": {"state": "ready", "state_message": "Printer is ready"}})
|
||||
self.show_panel('main_panel', "main_menu", _("Home"), 2,
|
||||
items=self._config.get_menu_items("__main"), extrudercount=self.printer.get_extruder_count())
|
||||
items=self._config.get_menu_items("__main"), extrudercount=self.printer.get_extruder_count())
|
||||
self.ws_subscribe()
|
||||
if "job_status" in self.panels:
|
||||
self.remove_subscription("job_status")
|
||||
@@ -829,7 +831,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
def printer_printing(self):
|
||||
self.close_popup_message()
|
||||
self.show_panel('job_status',"job_status", "Print Status", 2)
|
||||
self.show_panel('job_status', "job_status", "Print Status", 2)
|
||||
|
||||
def show_keyboard(self, widget=None):
|
||||
if self.keyboard is not None:
|
||||
@@ -842,7 +844,7 @@ class KlipperScreen(Gtk.Window):
|
||||
else:
|
||||
env["MB_KBD_CONFIG"] = "ks_includes/locales/keyboard.xml"
|
||||
p = subprocess.Popen(["matchbox-keyboard", "--xid"], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, env=env)
|
||||
stderr=subprocess.PIPE, env=env)
|
||||
|
||||
xid = int(p.stdout.readline())
|
||||
logging.debug("XID %s" % xid)
|
||||
@@ -864,7 +866,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
self.keyboard = {
|
||||
"box": box,
|
||||
#"panel": cur_panel.get(),
|
||||
# "panel": cur_panel.get(),
|
||||
"process": p,
|
||||
"socket": keyboard
|
||||
}
|
||||
@@ -882,11 +884,11 @@ def main():
|
||||
version = functions.get_software_version()
|
||||
parser = argparse.ArgumentParser(description="KlipperScreen - A GUI for Klipper")
|
||||
parser.add_argument(
|
||||
"-c","--configfile", default="~/KlipperScreen.conf", metavar='<configfile>',
|
||||
"-c", "--configfile", default="~/KlipperScreen.conf", metavar='<configfile>',
|
||||
help="Location of KlipperScreen configuration file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l","--logfile", default="/tmp/KlipperScreen.log", metavar='<logfile>',
|
||||
"-l", "--logfile", default="/tmp/KlipperScreen.log", metavar='<logfile>',
|
||||
help="Location of KlipperScreen logfile output"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
@@ -910,5 +912,5 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
except Exception:
|
||||
logging.exception("Fatal error in main loop")
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
pycodestyle --ignore=E226,E301,E302,E303,E402,W503,W504 --max-line-length=120 --max-doc-length=120 screen.py ks_includes panels
|
||||
Reference in new issue
Block a user