PEP8, typos and warnings fixes
This commit is contained in:
parent
fd2a717ece
commit
5a36729b76
@ -106,7 +106,7 @@ temperature_fan: 40
|
||||
gcode: MY_HEATSOAK_MACRO
|
||||
```
|
||||
|
||||
There is an special preheat setting named cooldown to do additional things when the _cooldown_ button is pressed
|
||||
There is a special preheat setting named cooldown to do additional things when the _cooldown_ button is pressed
|
||||
for example:
|
||||
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
## Create Translations
|
||||
|
||||
You can use a editor such as [poedit](https://poedit.net/) to assist in translations. This guide will assume that you
|
||||
You can use an editor such as [poedit](https://poedit.net/) to assist in translations. This guide will assume that you
|
||||
will be using poedit.
|
||||
|
||||
This guide will refer to `language designation`. This can be found from running `echo $LANG` on your pi, as long as you
|
||||
|
@ -47,7 +47,7 @@ If you have another fb, try changing it:
|
||||
|
||||
for example: change `/dev/fb0` to `/dev/fb1`
|
||||
|
||||
Once you have saved that file, restart KlipperScreen and it should show up on your display.
|
||||
Once you have saved that file, restart KlipperScreen.
|
||||
|
||||
## Screen is all white or blank or no signal
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
class KlippyGcodes:
|
||||
|
||||
HOME = "G28"
|
||||
HOME_X = "G28 X"
|
||||
HOME_Y = "G28 Y"
|
||||
@ -33,7 +32,6 @@ class KlippyGcodes:
|
||||
RESTART = "RESTART"
|
||||
FIRMWARE_RESTART = "FIRMWARE_RESTART"
|
||||
|
||||
|
||||
@staticmethod
|
||||
def set_bed_temp(temp):
|
||||
return "%s S%s" % (KlippyGcodes.SET_BED_TEMP, str(temp))
|
||||
@ -52,7 +50,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
|
||||
|
@ -7,6 +7,7 @@ import pathlib
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gdk, GdkPixbuf, Gio, Gtk, Pango
|
||||
|
||||
|
||||
class KlippyGtk:
|
||||
labels = {}
|
||||
keyboard_ratio = .22
|
||||
@ -29,7 +30,7 @@ class KlippyGtk:
|
||||
))
|
||||
if fontsize_type == "small":
|
||||
self.font_size = round(self.font_size * 0.91)
|
||||
elif (fontsize_type == "large"):
|
||||
elif fontsize_type == "large":
|
||||
self.font_size = round(self.font_size * 1.09)
|
||||
self.header_size = int(round((self.width / self.width_ratio) / 1.33))
|
||||
self.img_width = int(round(self.width / self.width_ratio))
|
||||
@ -46,7 +47,7 @@ class KlippyGtk:
|
||||
|
||||
for key in self.color_list:
|
||||
if "base" in self.color_list[key]:
|
||||
rgb = [int(self.color_list[key]['base'][i:i+2], 16) for i in range(0, 6, 2)]
|
||||
rgb = [int(self.color_list[key]['base'][i:i + 2], 16) for i in range(0, 6, 2)]
|
||||
self.color_list[key]['rgb'] = rgb
|
||||
|
||||
logging.debug("img width: %s height: %s" % (self.img_width, self.img_height))
|
||||
@ -89,14 +90,14 @@ class KlippyGtk:
|
||||
rgb[1] = rgb[1] + self.color_list[device]['hsplit'] * self.color_list[device]['state']
|
||||
self.color_list[device]['state'] += 1
|
||||
color = '{:02X}{:02X}{:02X}'.format(rgb[0], rgb[1], rgb[2])
|
||||
rgb = [x/255 for x in rgb]
|
||||
rgb = [x / 255 for x in rgb]
|
||||
# logging.debug("Assigning color: %s %s %s" % (device, rgb, color))
|
||||
else:
|
||||
colors = self.color_list[device]['colors']
|
||||
if self.color_list[device]['state'] >= len(colors):
|
||||
self.color_list[device]['state'] = 0
|
||||
color = colors[self.color_list[device]['state'] % len(colors)]
|
||||
rgb = [int(color[i:i+2], 16)/255 for i in range(0, 6, 2)]
|
||||
rgb = [int(color[i:i + 2], 16) / 255 for i in range(0, 6, 2)]
|
||||
self.color_list[device]['state'] += 1
|
||||
# logging.debug("Assigning color: %s %s %s" % (device, rgb, color))
|
||||
|
||||
@ -106,14 +107,13 @@ class KlippyGtk:
|
||||
for key in self.color_list:
|
||||
self.color_list[key]['state'] = 0
|
||||
|
||||
|
||||
def Label(self, label, style=None):
|
||||
la = Gtk.Label(label)
|
||||
if style is not None and style is not False:
|
||||
la.get_style_context().add_class(style)
|
||||
return la
|
||||
|
||||
def Image(self, image_name, scale=1):
|
||||
def Image(self, image_name, scale=1.0):
|
||||
filename = os.path.join(self.themedir, str(image_name) + ".svg")
|
||||
if os.path.exists(filename):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename,
|
||||
@ -201,7 +201,7 @@ class KlippyGtk:
|
||||
button = dialog.get_children()[0].get_children()[0].get_children()[0].get_children()[i]
|
||||
button.get_child().set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
button.get_child().set_line_wrap(True)
|
||||
button.set_size_request((screen.width-30)/3, screen.height/5)
|
||||
button.set_size_request((screen.width - 30) / 3, screen.height / 5)
|
||||
|
||||
dialog.connect("response", callback, *args)
|
||||
dialog.get_style_context().add_class("dialog")
|
||||
@ -222,7 +222,6 @@ class KlippyGtk:
|
||||
|
||||
return dialog
|
||||
|
||||
|
||||
def ToggleButtonImage(self, image_name, label, style=False, scale=1.38):
|
||||
|
||||
b = Gtk.ToggleButton(label=label)
|
||||
@ -263,21 +262,20 @@ class KlippyGtk:
|
||||
return name[0:25] + "\n" + name[25:50]
|
||||
return name
|
||||
|
||||
|
||||
def formatTimeString(self, seconds):
|
||||
time = int(seconds)
|
||||
text = ""
|
||||
if int(time/86400) != 0:
|
||||
text += str(int(time/86400))+"d "
|
||||
if int(time/3600) != 0:
|
||||
text += str(int(time/3600) % 24)+"h "
|
||||
if int(time/60) != 0:
|
||||
text += str(int(time/60) % 60)+"m "
|
||||
if int(time / 86400) != 0:
|
||||
text += str(int(time / 86400)) + "d "
|
||||
if int(time / 3600) != 0:
|
||||
text += str(int(time / 3600) % 24) + "h "
|
||||
if int(time / 60) != 0:
|
||||
text += str(int(time / 60) % 60) + "m "
|
||||
else:
|
||||
text = str(time % 60)+"s"
|
||||
text = str(time % 60) + "s"
|
||||
return text
|
||||
|
||||
def formatTemperatureString(self, temp, target):
|
||||
if (target > temp-2 and target < temp+2) or round(target, 0) == 0:
|
||||
if (temp - 2 < target < temp + 2) or round(target, 0) == 0:
|
||||
return str(round(temp, 1)) + "°C" # °C →"
|
||||
return str(round(temp)) + " °C\n(" + str(round(target)) + ")"
|
||||
|
@ -2,6 +2,7 @@ import json
|
||||
import requests
|
||||
import logging
|
||||
|
||||
|
||||
class KlippyRest:
|
||||
def __init__(self, ip, port=7125, api_key=False):
|
||||
self.ip = ip
|
||||
|
@ -26,6 +26,7 @@ api = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class KlippyWebsocket(threading.Thread):
|
||||
_req_id = 0
|
||||
connected = False
|
||||
@ -70,7 +71,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
if self.reconnect_count > 3:
|
||||
self._screen.panels['splash_screen'].update_text(
|
||||
_("Cannot connect to Moonraker") +
|
||||
("\n\n%s\n\n") % self._url +
|
||||
"\n\n%s\n\n" % self._url +
|
||||
_("Retry #%s") % self.reconnect_count)
|
||||
return False
|
||||
token = self._screen.apiclient.get_oneshot_token()
|
||||
@ -195,6 +196,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
def on_error(self, ws, error):
|
||||
logging.debug("Websocket error: %s" % error)
|
||||
|
||||
|
||||
class MoonrakerApi:
|
||||
def __init__(self, ws):
|
||||
self._ws = ws
|
||||
|
@ -12,19 +12,21 @@ 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
|
||||
"300", # 5 Minutes
|
||||
"900", # 15 Minutes
|
||||
"1800", # 30 Minutes
|
||||
"3600", # 1 Hour
|
||||
"7200", # 2 Hours
|
||||
"14400", # 4 Hours
|
||||
]
|
||||
|
||||
klipperscreendir = pathlib.Path(__file__).parent.resolve().parent
|
||||
|
||||
|
||||
class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class KlipperScreenConfig:
|
||||
config = None
|
||||
configfile_name = "KlipperScreen.conf"
|
||||
@ -103,10 +105,10 @@ class KlipperScreenConfig:
|
||||
_n = self.lang.ngettext
|
||||
|
||||
self.configurable_options = [
|
||||
{"language": {"section": "main", "name": _("Language"), "type": "dropdown", "value": "system_lang",
|
||||
"callback": screen.restart_warning, "options": [
|
||||
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}
|
||||
]}},
|
||||
{"language": {
|
||||
"section": "main", "name": _("Language"), "type": "dropdown", "value": "system_lang",
|
||||
"callback": screen.restart_warning, "options": [
|
||||
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}]}},
|
||||
{"theme": {
|
||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"value": "z-bolt", "callback": screen.restart_warning, "options": [
|
||||
@ -177,11 +179,11 @@ class KlipperScreenConfig:
|
||||
index = self.configurable_options.index(
|
||||
[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)
|
||||
hour = int(int(num) / 3600)
|
||||
if hour > 0:
|
||||
name = str(hour) + " " + _n("hour", "hours", hour)
|
||||
else:
|
||||
name = str(int(int(num)/60)) + " " + _("minutes")
|
||||
name = str(int(int(num) / 60)) + " " + _("minutes")
|
||||
self.configurable_options[index]['screen_blanking']['options'].append({
|
||||
"name": name,
|
||||
"value": num
|
||||
@ -258,7 +260,7 @@ class KlipperScreenConfig:
|
||||
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):])
|
||||
saved_def.append(line[(len(self.do_not_edit_prefix) + 1):])
|
||||
return ["\n".join(user_def), None if saved_def is None else "\n".join(saved_def)]
|
||||
|
||||
def get_config_file_location(self, file):
|
||||
@ -312,7 +314,6 @@ class KlipperScreenConfig:
|
||||
return False
|
||||
return self.config[name].get('name')
|
||||
|
||||
|
||||
def get_preheat_options(self):
|
||||
index = "preheat "
|
||||
items = [i[len(index):] for i in self.config.sections() if i.startswith(index)]
|
||||
|
@ -2,10 +2,12 @@ import logging
|
||||
import os
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib
|
||||
|
||||
class KlippyFiles():
|
||||
|
||||
class KlippyFiles:
|
||||
def __init__(self, screen):
|
||||
self._screen = screen
|
||||
self.callbacks = []
|
||||
@ -177,7 +179,7 @@ class KlippyFiles():
|
||||
self.run_callbacks(deletedfiles=[filename])
|
||||
|
||||
def ret_file_data(self, filename):
|
||||
print("Getting file info for %s" % (filename))
|
||||
print("Getting file info for %s" % filename)
|
||||
self._screen._ws.klippy.get_file_metadata(filename, self._callback)
|
||||
|
||||
def run_callbacks(self, newfiles=[], deletedfiles=[], mods=[]):
|
||||
|
@ -17,6 +17,7 @@ try:
|
||||
ctypes.cdll.LoadLibrary('libXext.so.6')
|
||||
libXext = ctypes.CDLL('libXext.so.6')
|
||||
|
||||
|
||||
class DPMS_State:
|
||||
Fail = -1
|
||||
On = 0
|
||||
@ -24,6 +25,7 @@ try:
|
||||
Suspend = 2
|
||||
Off = 3
|
||||
|
||||
|
||||
def get_DPMS_state(display_name_in_byte_string=b':0'):
|
||||
state = DPMS_State.Fail
|
||||
if not isinstance(display_name_in_byte_string, bytes):
|
||||
@ -35,8 +37,8 @@ try:
|
||||
dummy1_i_p = ctypes.create_string_buffer(8)
|
||||
dummy2_i_p = ctypes.create_string_buffer(8)
|
||||
if display.value:
|
||||
if libXext.DPMSQueryExtension(display, dummy1_i_p, dummy2_i_p)\
|
||||
and libXext.DPMSCapable(display):
|
||||
if libXext.DPMSQueryExtension(display, dummy1_i_p, dummy2_i_p) \
|
||||
and libXext.DPMSCapable(display):
|
||||
onoff_p = ctypes.create_string_buffer(1)
|
||||
state_p = ctypes.create_string_buffer(2)
|
||||
if libXext.DPMSInfo(display, state_p, onoff_p):
|
||||
@ -45,14 +47,18 @@ try:
|
||||
state = struct.unpack('H', state_p.raw)[0]
|
||||
libXext.XCloseDisplay(display)
|
||||
return state
|
||||
|
||||
|
||||
dpms_loaded = True
|
||||
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\\.]*'")
|
||||
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)
|
||||
|
||||
@ -76,6 +82,7 @@ def get_wireless_interfaces():
|
||||
|
||||
return interfaces
|
||||
|
||||
|
||||
def get_software_version():
|
||||
prog = ('git', '-C', os.path.dirname(__file__), 'describe', '--always',
|
||||
'--tags', '--long', '--dirty')
|
||||
@ -95,6 +102,7 @@ def get_software_version():
|
||||
logging.exception("Error runing git describe")
|
||||
return "?"
|
||||
|
||||
|
||||
def patch_threading_excepthook():
|
||||
"""Installs our exception handler into the threading modules Thread object
|
||||
Inspired by https://bugs.python.org/issue1230540
|
||||
@ -112,15 +120,18 @@ def patch_threading_excepthook():
|
||||
raise
|
||||
except Exception:
|
||||
sys.excepthook(*sys.exc_info(), thread_identifier=threading.get_ident())
|
||||
|
||||
self.run = run_with_excepthook
|
||||
|
||||
threading.Thread.__init__ = new_init
|
||||
|
||||
|
||||
# Timed rotating file handler based on Klipper and Moonraker's implementation
|
||||
class KlipperScreenLoggingHandler(logging.handlers.TimedRotatingFileHandler):
|
||||
def __init__(self, software_version, filename, **kwargs):
|
||||
super(KlipperScreenLoggingHandler, self).__init__(filename, **kwargs)
|
||||
self.rollover_info = {
|
||||
'header': f"{'-'*20}KlipperScreen Log Start{'-'*20}",
|
||||
'header': f"{'-' * 20}KlipperScreen Log Start{'-' * 20}",
|
||||
'version': f"Git Version: {software_version}",
|
||||
}
|
||||
lines = [line for line in self.rollover_info.values() if line]
|
||||
@ -136,6 +147,7 @@ class KlipperScreenLoggingHandler(logging.handlers.TimedRotatingFileHandler):
|
||||
if self.stream is not None:
|
||||
self.stream.write("\n".join(lines) + "\n")
|
||||
|
||||
|
||||
# Logging based on Arksine's logging setup
|
||||
def setup_logging(log_file, software_version):
|
||||
root_logger = logging.getLogger()
|
||||
@ -165,6 +177,7 @@ def setup_logging(log_file, software_version):
|
||||
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))))
|
||||
|
||||
sys.excepthook = logging_exception_handler
|
||||
logging.captureWarnings(True)
|
||||
|
||||
|
@ -209,11 +209,6 @@ class Printer:
|
||||
return self.config[section]
|
||||
return False
|
||||
|
||||
def get_config_section(self, section):
|
||||
if section not in self.config:
|
||||
return False
|
||||
return self.config[section]
|
||||
|
||||
def get_data(self):
|
||||
return self.data
|
||||
|
||||
|
@ -5,6 +5,7 @@ from gi.repository import Gtk
|
||||
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
|
||||
|
||||
class ScreenPanel:
|
||||
|
||||
def __init__(self, screen, title, back=True, action_bar=True, printer_name=True):
|
||||
@ -42,7 +43,7 @@ class ScreenPanel:
|
||||
if temp <= 0:
|
||||
return ""
|
||||
else:
|
||||
return ("(%s)" % str(int(temp)))
|
||||
return "(%s)" % str(int(temp))
|
||||
|
||||
def format_temp(self, temp, places=1):
|
||||
if places == 0:
|
||||
|
@ -91,7 +91,6 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
max_num = math.ceil(self.get_max_num(data_points) * 1.1 / 10) * 10
|
||||
d_width = 1 / points_per_pixel
|
||||
|
||||
|
||||
d_height_scale = self.graph_lines(ctx, gsize, max_num)
|
||||
self.graph_time(ctx, gsize, points_per_pixel)
|
||||
|
||||
@ -115,10 +114,10 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
ctx.set_dash([1, 0])
|
||||
d_len = len(data) - 1
|
||||
for d in data:
|
||||
p_x = i*swidth + gsize[0][0] if i != d_len else gsize[1][0] - 1
|
||||
p_y = gsize[1][1] - 1 - (d*hscale)
|
||||
p_x = i * swidth + gsize[0][0] if i != d_len else gsize[1][0] - 1
|
||||
p_y = gsize[1][1] - 1 - (d * hscale)
|
||||
if i == 0:
|
||||
ctx.move_to(gsize[0][0]+1, p_y)
|
||||
ctx.move_to(gsize[0][0] + 1, p_y)
|
||||
i += 1
|
||||
continue
|
||||
ctx.line_to(p_x, p_y)
|
||||
@ -139,15 +138,15 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
while (max_num / nscale) > 5:
|
||||
nscale += 10
|
||||
# nscale = math.floor((max_num / 10) / 4) * 10
|
||||
r = int(max_num/nscale) + 1
|
||||
r = int(max_num / nscale) + 1
|
||||
hscale = (gsize[1][1] - gsize[0][1]) / (r * nscale)
|
||||
|
||||
for i in range(r):
|
||||
ctx.set_source_rgb(.5, .5, .5)
|
||||
lheight = gsize[1][1] - nscale*i*hscale
|
||||
lheight = gsize[1][1] - nscale * i * hscale
|
||||
ctx.move_to(6, lheight + 3)
|
||||
ctx.set_font_size(self.font_size)
|
||||
ctx.show_text(str(nscale*i).rjust(3, " "))
|
||||
ctx.show_text(str(nscale * i).rjust(3, " "))
|
||||
ctx.stroke()
|
||||
ctx.set_source_rgba(.5, .5, .5, .2)
|
||||
ctx.move_to(gsize[0][0], lheight)
|
||||
|
@ -9,10 +9,12 @@ from threading import Thread
|
||||
from queue import Queue
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gdk
|
||||
|
||||
class WifiManager():
|
||||
|
||||
class WifiManager:
|
||||
networks_in_supplicant = []
|
||||
connected = False
|
||||
_stop_loop = False
|
||||
@ -77,7 +79,7 @@ class WifiManager():
|
||||
# TODO: Add wpa_cli error checking
|
||||
network_id = self.wpa_cli("ADD_NETWORK")
|
||||
commands = [
|
||||
'ENABLE_NETWORK %s' % (network_id),
|
||||
'ENABLE_NETWORK %s' % network_id,
|
||||
'SET_NETWORK %s ssid "%s"' % (network_id, ssid.replace('"', '\"')),
|
||||
'SET_NETWORK %s psk "%s"' % (network_id, psk.replace('"', '\"'))
|
||||
]
|
||||
@ -365,117 +367,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 "5", "196"
|
||||
return None
|
||||
|
@ -9,6 +9,7 @@ from jinja2 import Environment
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
class BasePanel(ScreenPanel):
|
||||
def __init__(self, screen, title, back=True, action_bar=True, printer_name=True):
|
||||
super().__init__(screen, title, back, action_bar, printer_name)
|
||||
@ -85,7 +86,6 @@ class BasePanel(ScreenPanel):
|
||||
self.titlelbl.set_hexpand(True)
|
||||
self.titlelbl.set_vexpand(True)
|
||||
self.titlelbl.set_halign(Gtk.Align.CENTER)
|
||||
self.titlelbl.set_ellipsize(True)
|
||||
self.titlelbl.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
self.set_title(title)
|
||||
|
||||
@ -129,7 +129,6 @@ class BasePanel(ScreenPanel):
|
||||
self.layout.put(self.titlebar, action_bar_width, 0)
|
||||
self.layout.put(self.content, action_bar_width + self.hmargin, self.title_spacing)
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
self.update_time()
|
||||
return
|
||||
@ -138,14 +137,13 @@ class BasePanel(ScreenPanel):
|
||||
for child in self.control['temp_box'].get_children():
|
||||
self.control['temp_box'].remove(child)
|
||||
|
||||
if (not show or self._screen.printer.get_temp_store_devices() is None):
|
||||
if not show or self._screen.printer.get_temp_store_devices() is None:
|
||||
return
|
||||
|
||||
for device in self._screen.printer.get_temp_store_devices():
|
||||
logging.info(device)
|
||||
self.labels[device + '_box'] = Gtk.Box(spacing=0)
|
||||
self.labels[device] = Gtk.Label(label="100º")
|
||||
self.labels[device].set_ellipsize(True)
|
||||
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
|
||||
if device.startswith("extruder"):
|
||||
if self._screen.printer.extrudercount > 1:
|
||||
@ -269,7 +267,6 @@ class BasePanel(ScreenPanel):
|
||||
self.control['temp_box'].reorder_child(self.labels["%s_box" % self.current_extruder], 0)
|
||||
self.control['temp_box'].show_all()
|
||||
|
||||
|
||||
def remove(self, widget):
|
||||
self.content.remove(widget)
|
||||
|
||||
|
@ -8,9 +8,11 @@ from gi.repository import Gtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return BedLevelPanel(*args)
|
||||
|
||||
|
||||
class BedLevelPanel(ScreenPanel):
|
||||
x_offset = 0
|
||||
y_offset = 0
|
||||
@ -47,19 +49,19 @@ class BedLevelPanel(ScreenPanel):
|
||||
logging.debug("%d bed_screws not supported: calculating 4 locations", nscrews)
|
||||
xconf = self._screen.printer.get_config_section("stepper_x")
|
||||
yconf = self._screen.printer.get_config_section("stepper_y")
|
||||
x = int(int(xconf['position_max'])/4)
|
||||
y = int(int(yconf['position_max'])/4)
|
||||
x = int(int(xconf['position_max']) / 4)
|
||||
y = int(int(yconf['position_max']) / 4)
|
||||
self.screws = [
|
||||
[x, y],
|
||||
[x*3, y],
|
||||
[x, y*3],
|
||||
[x*3, y*3],
|
||||
[x * 3, y],
|
||||
[x, y * 3],
|
||||
[x * 3, y * 3],
|
||||
]
|
||||
else:
|
||||
self.screws = screws
|
||||
|
||||
if (("bltouch" in self._screen.printer.get_config_section_list() or
|
||||
"probe" in self._screen.printer.get_config_section_list()) and
|
||||
"probe" in self._screen.printer.get_config_section_list()) and
|
||||
config_section_name == "screws_tilt_adjust"):
|
||||
if "bltouch" in self._screen.printer.get_config_section_list():
|
||||
bltouch = self._screen.printer.get_config_section("bltouch")
|
||||
@ -307,7 +309,7 @@ class BedLevelPanel(ScreenPanel):
|
||||
self.labels[key].set_label(result.group(5))
|
||||
break
|
||||
self.response_count += 1
|
||||
if self.response_count >= len(self.screws)-1:
|
||||
if self.response_count >= len(self.screws) - 1:
|
||||
self.labels['screws'].set_sensitive(True)
|
||||
else:
|
||||
result = re.match(
|
||||
|
@ -15,9 +15,11 @@ from matplotlib.ticker import LinearLocator
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return BedMeshPanel(*args)
|
||||
|
||||
|
||||
class BedMeshPanel(ScreenPanel):
|
||||
active_mesh = None
|
||||
graphs = {}
|
||||
@ -37,7 +39,6 @@ class BedMeshPanel(ScreenPanel):
|
||||
self.labels['profiles'] = Gtk.Grid()
|
||||
scroll.add(self.labels['profiles'])
|
||||
|
||||
|
||||
addprofile = self._gtk.ButtonImage("increase", " %s" % _("Add bed mesh profile"),
|
||||
"color1", .5, Gtk.PositionType.LEFT, False)
|
||||
addprofile.connect("clicked", self.show_create_profile)
|
||||
@ -92,7 +93,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
frame = Gtk.Frame()
|
||||
|
||||
name = Gtk.Label()
|
||||
name.set_markup("<big><b>%s</b></big>" % (profile))
|
||||
name.set_markup("<big><b>%s</b></big>" % profile)
|
||||
name.set_hexpand(True)
|
||||
name.set_vexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
@ -177,7 +178,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
if "default" in pl:
|
||||
pl.remove('default')
|
||||
profiles = sorted(pl)
|
||||
pos = profiles.index(profile)+1 if profile != "default" else 0
|
||||
pos = profiles.index(profile) + 1 if profile != "default" else 0
|
||||
|
||||
self.labels['profiles'].insert_row(pos)
|
||||
self.labels['profiles'].attach(self.profiles[profile]['row'], 0, pos, 1, 1)
|
||||
@ -240,7 +241,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
if "default" in pl:
|
||||
pl.remove('default')
|
||||
profiles = sorted(pl)
|
||||
pos = profiles.index(profile)+1 if profile != "default" else 0
|
||||
pos = profiles.index(profile) + 1 if profile != "default" else 0
|
||||
self.labels['profiles'].remove_row(pos)
|
||||
del self.profiles[profile]
|
||||
|
||||
@ -287,7 +288,6 @@ class BedMeshPanel(ScreenPanel):
|
||||
save.set_hexpand(False)
|
||||
save.connect("clicked", self.create_profile)
|
||||
|
||||
|
||||
self.labels['profile_name'] = entry
|
||||
box.pack_start(pl, False, False, 5)
|
||||
box.pack_start(entry, True, True, 5)
|
||||
@ -324,19 +324,19 @@ class BedMeshPanel(ScreenPanel):
|
||||
maxz_mesh = 0.5
|
||||
z_range = [minz_mesh, maxz_mesh]
|
||||
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)]
|
||||
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])]
|
||||
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)
|
||||
z = np.asarray(abm['mesh_matrix'])
|
||||
else:
|
||||
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)]
|
||||
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'])]
|
||||
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'])
|
||||
|
||||
@ -349,8 +349,8 @@ class BedMeshPanel(ScreenPanel):
|
||||
fig.add_axes(ax)
|
||||
surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm, vmin=-0.1, vmax=0.1)
|
||||
|
||||
chartBox = ax.get_position()
|
||||
ax.set_position([chartBox.x0, chartBox.y0+0.1, chartBox.width*.92, chartBox.height])
|
||||
chartbox = ax.get_position()
|
||||
ax.set_position([chartbox.x0, chartbox.y0 + 0.1, chartbox.width * .92, chartbox.height])
|
||||
|
||||
ax.set_zlim(z_range[0], z_range[1])
|
||||
ax.zaxis.set_major_locator(LinearLocator(5))
|
||||
@ -381,7 +381,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
|
||||
alloc = canvas_box.get_allocation()
|
||||
canvas = FigureCanvas(fig)
|
||||
canvas.set_size_request(alloc.width, self._screen.height/3*2)
|
||||
canvas.set_size_request(alloc.width, self._screen.height / 3 * 2)
|
||||
canvas_box.add(canvas)
|
||||
canvas_box.show_all()
|
||||
# Remove the "matplotlib-canvas" class which forces a white background.
|
||||
@ -390,6 +390,5 @@ class BedMeshPanel(ScreenPanel):
|
||||
for css_class in style_ctx.list_classes():
|
||||
style_ctx.remove_class(css_class)
|
||||
|
||||
|
||||
def _close_dialog(self, widget, response):
|
||||
widget.destroy()
|
||||
|
@ -9,6 +9,7 @@ from gi.repository import Gtk
|
||||
from datetime import datetime
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return ConsolePanel(*args)
|
||||
|
||||
@ -21,6 +22,7 @@ COLORS = {
|
||||
"warning": "#c9c9c9"
|
||||
}
|
||||
|
||||
|
||||
class ConsolePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@ -32,16 +34,16 @@ class ConsolePanel(ScreenPanel):
|
||||
o1_lbl = Gtk.Label(_("Auto-scroll"))
|
||||
o1_lbl.set_halign(Gtk.Align.END)
|
||||
o1_switch = Gtk.Switch()
|
||||
o1_switch.set_property("width-request", round(self._gtk.get_font_size()*5))
|
||||
o1_switch.set_property("height-request", round(self._gtk.get_font_size()*2.5))
|
||||
o1_switch.set_property("width-request", round(self._gtk.get_font_size() * 5))
|
||||
o1_switch.set_property("height-request", round(self._gtk.get_font_size() * 2.5))
|
||||
o1_switch.set_active(self.autoscroll)
|
||||
o1_switch.connect("notify::active", self.set_autoscroll)
|
||||
|
||||
o2_lbl = Gtk.Label(_("Hide temp."))
|
||||
o2_lbl.set_halign(Gtk.Align.END)
|
||||
o2_switch = Gtk.Switch()
|
||||
o2_switch.set_property("width-request", round(self._gtk.get_font_size()*5))
|
||||
o2_switch.set_property("height-request", round(self._gtk.get_font_size()*2.5))
|
||||
o2_switch.set_property("width-request", round(self._gtk.get_font_size() * 5))
|
||||
o2_switch.set_property("height-request", round(self._gtk.get_font_size() * 2.5))
|
||||
o2_switch.set_active(self.hidetemps)
|
||||
o2_switch.connect("notify::active", self.hide_temps)
|
||||
|
||||
@ -85,7 +87,6 @@ class ConsolePanel(ScreenPanel):
|
||||
enter.set_hexpand(False)
|
||||
enter.connect("clicked", self._send_command)
|
||||
|
||||
|
||||
ebox.add(entry)
|
||||
ebox.add(enter)
|
||||
|
||||
|
@ -5,9 +5,11 @@ from gi.repository import Gtk
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return ExamplePanel(*args)
|
||||
|
||||
|
||||
class ExamplePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
@ -7,9 +7,11 @@ from gi.repository import Gtk, Pango
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return ExtrudePanel(*args)
|
||||
|
||||
|
||||
class ExtrudePanel(ScreenPanel):
|
||||
distance = 5
|
||||
distances = ['5', '10', '15', '25']
|
||||
@ -56,40 +58,40 @@ class ExtrudePanel(ScreenPanel):
|
||||
if i < limit:
|
||||
extgrid.attach(self.labels[extruder], i, 0, 1, 1)
|
||||
if i < (limit - 1):
|
||||
extgrid.attach(self.labels['temperature'], i+1, 0, 1, 1)
|
||||
extgrid.attach(self.labels['temperature'], i + 1, 0, 1, 1)
|
||||
i += 1
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
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()
|
||||
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 is True and j == 0) or
|
||||
(self._screen.lang_ltr is False and j == len(self.distances)-1)):
|
||||
(self._screen.lang_ltr is False and j == len(self.distances) - 1)):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif ((self._screen.lang_ltr is False and j == 0) or
|
||||
(self._screen.lang_ltr is True and j == len(self.distances)-1)):
|
||||
(self._screen.lang_ltr is True and j == len(self.distances) - 1)):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
if i == "5":
|
||||
ctx.add_class("distbutton_active")
|
||||
distgrid.attach(self.labels["dist"+str(i)], j, 0, 1, 1)
|
||||
distgrid.attach(self.labels["dist" + str(i)], j, 0, 1, 1)
|
||||
j += 1
|
||||
self.labels["dist5"].set_active(True)
|
||||
|
||||
speedgrid = Gtk.Grid()
|
||||
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()
|
||||
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 is True and j == 0) or
|
||||
(self._screen.lang_ltr is False and j == len(self.speeds)-1)):
|
||||
(self._screen.lang_ltr is False and j == len(self.speeds) - 1)):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif ((self._screen.lang_ltr is False and j == 0) or
|
||||
(self._screen.lang_ltr is True and j == len(self.speeds)-1)):
|
||||
(self._screen.lang_ltr is True and j == len(self.speeds) - 1)):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -116,7 +118,7 @@ class ExtrudePanel(ScreenPanel):
|
||||
sensors.set_halign(Gtk.Align.CENTER)
|
||||
sensors.set_valign(Gtk.Align.CENTER)
|
||||
for s, x in enumerate(filament_sensors):
|
||||
if s > (limit):
|
||||
if s > limit:
|
||||
break
|
||||
name = x[23:].strip()
|
||||
self.labels[x] = {
|
||||
@ -126,9 +128,8 @@ class ExtrudePanel(ScreenPanel):
|
||||
}
|
||||
self.labels[x]['label'].set_halign(Gtk.Align.CENTER)
|
||||
self.labels[x]['label'].set_hexpand(True)
|
||||
self.labels[x]['label'].set_ellipsize(True)
|
||||
self.labels[x]['label'].set_ellipsize(Pango.EllipsizeMode.END)
|
||||
self.labels[x]['switch'].set_property("width-request", round(self._gtk.get_font_size()*2))
|
||||
self.labels[x]['switch'].set_property("width-request", round(self._gtk.get_font_size() * 2))
|
||||
self.labels[x]['switch'].set_property("height-request", round(self._gtk.get_font_size()))
|
||||
self.labels[x]['switch'].set_active(self._printer.get_dev_stat(x, "enabled"))
|
||||
self.labels[x]['switch'].connect("notify::active", self.enable_disable_fs, name, x)
|
||||
@ -206,16 +207,16 @@ class ExtrudePanel(ScreenPanel):
|
||||
return
|
||||
logging.info("### Distance " + str(distance))
|
||||
|
||||
ctx = self.labels["dist"+str(self.distance)].get_style_context()
|
||||
ctx = self.labels["dist" + str(self.distance)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
|
||||
self.distance = distance
|
||||
ctx = self.labels["dist"+self.distance].get_style_context()
|
||||
ctx = self.labels["dist" + self.distance].get_style_context()
|
||||
ctx.add_class("distbutton_active")
|
||||
for i in self.distances:
|
||||
if i == self.distance:
|
||||
continue
|
||||
self.labels["dist"+str(i)].set_active(False)
|
||||
self.labels["dist" + str(i)].set_active(False)
|
||||
|
||||
def change_extruder(self, widget, extruder):
|
||||
if extruder == self.current_extruder:
|
||||
|
@ -7,12 +7,14 @@ from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return FanPanel(*args)
|
||||
|
||||
|
||||
CHANGEABLE_FANS = ["fan", "fan_generic"]
|
||||
|
||||
|
||||
class FanPanel(ScreenPanel):
|
||||
fan_speed = {}
|
||||
user_selecting = False
|
||||
@ -41,7 +43,7 @@ class FanPanel(ScreenPanel):
|
||||
self.content.add(box)
|
||||
|
||||
def process_update(self, action, data):
|
||||
if (action != "notify_status_update"):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
for fan in self.devices:
|
||||
@ -80,7 +82,7 @@ class FanPanel(ScreenPanel):
|
||||
fan_name = "Part Fan"
|
||||
else:
|
||||
fan_name = " ".join(fan.split(" ")[1:])
|
||||
name.set_markup("<big><b>%s</b></big>" % (fan_name))
|
||||
name.set_markup("<big><b>%s</b></big>" % fan_name)
|
||||
name.set_hexpand(True)
|
||||
name.set_vexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
@ -150,7 +152,7 @@ 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))
|
||||
# Check the speed in case it wasn't applied
|
||||
GLib.timeout_add_seconds(1, self.check_fan_speed, fan)
|
||||
|
||||
|
@ -8,9 +8,11 @@ from gi.repository import Gtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return FineTunePanel(*args)
|
||||
|
||||
|
||||
class FineTunePanel(ScreenPanel):
|
||||
user_selecting = False
|
||||
|
||||
@ -47,7 +49,7 @@ class FineTunePanel(ScreenPanel):
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("distbutton_top")
|
||||
elif j == len(self.bs_deltas)-1:
|
||||
elif j == len(self.bs_deltas) - 1:
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -65,7 +67,7 @@ class FineTunePanel(ScreenPanel):
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("distbutton_top")
|
||||
elif j == len(self.percent_deltas)-1:
|
||||
elif j == len(self.percent_deltas) - 1:
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -156,10 +158,10 @@ class FineTunePanel(ScreenPanel):
|
||||
if "homing_origin" in data["gcode_move"]:
|
||||
self.labels['zoffset'].set_label(" %.2fmm" % data["gcode_move"]["homing_origin"][2])
|
||||
if "extrude_factor" in data["gcode_move"]:
|
||||
self.extrusion = int(round(data["gcode_move"]["extrude_factor"]*100))
|
||||
self.extrusion = int(round(data["gcode_move"]["extrude_factor"] * 100))
|
||||
self.labels['extrudefactor'].set_label(" %3d%%" % self.extrusion)
|
||||
if "speed_factor" in data["gcode_move"]:
|
||||
self.speed = int(round(data["gcode_move"]["speed_factor"]*100))
|
||||
self.speed = int(round(data["gcode_move"]["speed_factor"] * 100))
|
||||
self.labels['speedfactor'].set_label(" %3d%%" % self.speed)
|
||||
|
||||
def change_babystepping(self, widget, dir):
|
||||
|
@ -6,9 +6,11 @@ from gi.repository import Gdk, Gtk, GLib, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return MacroPanel(*args)
|
||||
|
||||
|
||||
class MacroPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@ -55,7 +57,7 @@ class MacroPanel(ScreenPanel):
|
||||
return
|
||||
|
||||
name = Gtk.Label()
|
||||
name.set_markup("<big><b>%s</b></big>" % (macro))
|
||||
name.set_markup("<big><b>%s</b></big>" % macro)
|
||||
name.set_hexpand(True)
|
||||
name.set_vexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
@ -158,8 +160,8 @@ class MacroPanel(ScreenPanel):
|
||||
switch.set_vexpand(False)
|
||||
switch.set_active(self._config.get_config().getboolean(option['section'], opt_name, fallback=True))
|
||||
switch.connect("notify::active", self.switch_config_option, option['section'], opt_name)
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size()*7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size()*3.5))
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size() * 7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size() * 3.5))
|
||||
box.add(switch)
|
||||
|
||||
dev = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
|
@ -7,6 +7,7 @@ from gi.repository import Gtk, Pango
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return InputShaperPanel(*args)
|
||||
|
||||
@ -18,6 +19,7 @@ XY_FREQ = [
|
||||
]
|
||||
SHAPERS = ['zv', 'mzv', 'zvd', 'ei', '2hump_ei', '3hump_ei']
|
||||
|
||||
|
||||
class InputShaperPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
@ -9,9 +9,11 @@ from gi.repository import GLib, Gtk, Pango
|
||||
from numpy import sqrt, pi, dot, array, median
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return JobStatusPanel(*args)
|
||||
|
||||
|
||||
class JobStatusPanel(ScreenPanel):
|
||||
is_paused = False
|
||||
filename = state_timeout = prev_pos = prev_gpos = vel_timeout = animation_timeout = None
|
||||
@ -85,10 +87,9 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
for label in self.labels:
|
||||
self.labels[label].set_halign(Gtk.Align.START)
|
||||
self.labels[label].set_ellipsize(True)
|
||||
self.labels[label].set_ellipsize(Pango.EllipsizeMode.END)
|
||||
|
||||
fi_box = Gtk.VBox(spacing=0)
|
||||
fi_box = Gtk.VBox()
|
||||
fi_box.add(self.labels['file'])
|
||||
fi_box.add(self.labels['status'])
|
||||
fi_box.add(self.labels['lcdmessage'])
|
||||
@ -109,9 +110,9 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
self.labels['thumbnail'] = self._gtk.Image("file", 2)
|
||||
if self._screen.vertical_mode:
|
||||
self.labels['thumbnail'].set_size_request(0, self._screen.height/4)
|
||||
self.labels['thumbnail'].set_size_request(0, self._screen.height / 4)
|
||||
else:
|
||||
self.labels['thumbnail'].set_size_request(self._screen.width/3, 0)
|
||||
self.labels['thumbnail'].set_size_request(self._screen.width / 3, 0)
|
||||
|
||||
self.labels['info_grid'] = Gtk.Grid()
|
||||
self.labels['info_grid'].attach(self.labels['thumbnail'], 0, 0, 1, 1)
|
||||
@ -245,8 +246,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
szfe.attach(self.extrusion_button, 0, 1, 1, 1)
|
||||
szfe.attach(self.fan_button, 1, 1, 1, 1)
|
||||
|
||||
|
||||
info = Gtk.VBox(spacing=0)
|
||||
info = Gtk.VBox()
|
||||
info.get_style_context().add_class("printing-info")
|
||||
info.add(self.labels['temp_grid'])
|
||||
info.add(szfe)
|
||||
@ -345,15 +345,15 @@ class JobStatusPanel(ScreenPanel):
|
||||
def on_draw(self, da, ctx):
|
||||
w = da.get_allocated_width()
|
||||
h = da.get_allocated_height()
|
||||
r = min(w, h)*.42
|
||||
r = min(w, h) * .42
|
||||
|
||||
ctx.set_source_rgb(0.13, 0.13, 0.13)
|
||||
ctx.set_line_width(self._gtk.get_font_size() * .75)
|
||||
ctx.translate(w / 2, h / 2)
|
||||
ctx.arc(0, 0, r, 0, 2*pi)
|
||||
ctx.arc(0, 0, r, 0, 2 * pi)
|
||||
ctx.stroke()
|
||||
ctx.set_source_rgb(0.718, 0.110, 0.110)
|
||||
ctx.arc(0, 0, r, 3/2*pi, 3/2*pi+(self.progress*2*pi))
|
||||
ctx.arc(0, 0, r, 3 / 2 * pi, 3 / 2 * pi + (self.progress * 2 * pi))
|
||||
ctx.stroke()
|
||||
|
||||
def activate(self):
|
||||
@ -391,23 +391,23 @@ class JobStatusPanel(ScreenPanel):
|
||||
def save_offset(self, widget, device):
|
||||
_ = self.lang.gettext
|
||||
|
||||
save_offset = "?"
|
||||
saved_z_offset = 0
|
||||
if self._printer.config_section_exists("probe"):
|
||||
saved_z_offset = float(self._screen.printer.get_config_section("probe")['z_offset'])
|
||||
elif self._printer.config_section_exists("bltouch"):
|
||||
saved_z_offset = float(self._screen.printer.get_config_section("bltouch")['z_offset'])
|
||||
|
||||
if self.zoffset > 0:
|
||||
sign = "-"
|
||||
else:
|
||||
sign = "+"
|
||||
|
||||
else:
|
||||
sign = "-"
|
||||
label = Gtk.Label()
|
||||
if device == "probe":
|
||||
label = Gtk.Label(_("Apply %s%.2f offset to Probe?") % (sign, abs(self.zoffset))
|
||||
+ "\n\n"
|
||||
+ _("Saved offset: %s") % (saved_z_offset))
|
||||
if device == "endstop":
|
||||
label = Gtk.Label(_("Apply %.2f offset to Endstop?") % (self.zoffset))
|
||||
label.set_text(_("Apply %s%.2f offset to Probe?") % (sign, abs(self.zoffset))
|
||||
+ "\n\n"
|
||||
+ _("Saved offset: %s") % saved_z_offset)
|
||||
elif device == "endstop":
|
||||
label.set_text(_("Apply %.2f offset to Endstop?") % self.zoffset)
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_vexpand(True)
|
||||
@ -615,7 +615,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
for fan in self.fans:
|
||||
if fan in data and "speed" in data[fan]:
|
||||
fan_speed = int(round(self._printer.get_fan_speed(fan, data[fan]["speed"]), 2)*100)
|
||||
fan_speed = int(round(self._printer.get_fan_speed(fan, data[fan]["speed"]), 2) * 100)
|
||||
self.fans[fan]['speed'] = ("%3d%%" % fan_speed)
|
||||
fan_label = ""
|
||||
for fan in self.fans:
|
||||
@ -686,6 +686,9 @@ class JobStatusPanel(ScreenPanel):
|
||||
slicer_time = (self.file_metadata['estimated_time'] * slicer_correction) / spdcomp
|
||||
if slicer_time < duration:
|
||||
slicer_time = None
|
||||
self.update_text("slicer_time", "-")
|
||||
else:
|
||||
self.update_text("slicer_time", str(self._gtk.formatTimeString(slicer_time)))
|
||||
|
||||
if "filament_total" in self.file_metadata:
|
||||
if self.file_metadata['filament_total'] > 0 and filament_used > 0:
|
||||
@ -693,9 +696,15 @@ class JobStatusPanel(ScreenPanel):
|
||||
filament_time = duration / (filament_used / self.file_metadata['filament_total'])
|
||||
if filament_time < duration:
|
||||
filament_time = None
|
||||
self.update_text("filament_time", "-")
|
||||
else:
|
||||
self.update_text("filament_time", str(self._gtk.formatTimeString(slicer_time)))
|
||||
|
||||
if self.progress > 0:
|
||||
file_time = duration / self.progress
|
||||
self.update_text("file_time", str(self._gtk.formatTimeString(file_time)))
|
||||
else:
|
||||
self.update_text("file_time", "-")
|
||||
|
||||
if timeleft_type == "file" and file_time is not None:
|
||||
total_duration = file_time
|
||||
@ -717,16 +726,11 @@ class JobStatusPanel(ScreenPanel):
|
||||
else:
|
||||
total_duration = file_time
|
||||
|
||||
if total_duration is None:
|
||||
if total_duration is not None:
|
||||
self.update_text("est_time", str(self._gtk.formatTimeString(total_duration)))
|
||||
return str(self._gtk.formatTimeString((total_duration - duration)))
|
||||
else:
|
||||
return "-"
|
||||
self.update_text("est_time", str(self._gtk.formatTimeString(total_duration)))
|
||||
if slicer_time is not None:
|
||||
self.update_text("slicer_time", str(self._gtk.formatTimeString(slicer_time)))
|
||||
if file_time is not None:
|
||||
self.update_text("file_time", str(self._gtk.formatTimeString(file_time)))
|
||||
if filament_time is not None:
|
||||
self.update_text("filament_time", str(self._gtk.formatTimeString(filament_time)))
|
||||
return str(self._gtk.formatTimeString((total_duration - duration)))
|
||||
|
||||
def state_check(self):
|
||||
ps = self._printer.get_stat("print_stats")
|
||||
@ -794,7 +798,6 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.state = state
|
||||
self.show_buttons_for_state()
|
||||
|
||||
|
||||
def show_buttons_for_state(self):
|
||||
self.buttons['button_grid'].remove_row(0)
|
||||
self.buttons['button_grid'].insert_row(0)
|
||||
@ -818,7 +821,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
self.buttons['button_grid'].attach(self.buttons["save_offset_endstop"], 0, 0, 1, 1)
|
||||
else:
|
||||
self.buttons['button_grid'].attach(Gtk.Label(""), 0, 0, 1, 1)
|
||||
if (self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch")):
|
||||
if self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch"):
|
||||
self.buttons['button_grid'].attach(self.buttons["save_offset_probe"], 1, 0, 1, 1)
|
||||
else:
|
||||
self.buttons['button_grid'].attach(Gtk.Label(""), 1, 0, 1, 1)
|
||||
@ -888,7 +891,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
if "first_layer_height" in self.file_metadata:
|
||||
self.f_layer_h = self.file_metadata['first_layer_height']
|
||||
else:
|
||||
self.f_layer_h = layer_h
|
||||
self.f_layer_h = self.layer_h
|
||||
self.labels['total_layers'].set_label(str(int((self.height - self.f_layer_h) / self.layer_h) + 1))
|
||||
if "filament_total" in self.file_metadata:
|
||||
filament_total = float(self.file_metadata['filament_total']) / 1000
|
||||
@ -908,8 +911,8 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
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']))
|
||||
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')
|
||||
|
||||
@ -924,7 +927,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
def update_progress(self):
|
||||
if self.progress < 1:
|
||||
self.labels['progress_text'].set_text("%s%%" % (str((int(self.progress*100)))))
|
||||
self.labels['progress_text'].set_text("%s%%" % (str((int(self.progress * 100)))))
|
||||
else:
|
||||
self.labels['progress_text'].set_text("100")
|
||||
|
||||
@ -938,4 +941,4 @@ class JobStatusPanel(ScreenPanel):
|
||||
if target > 0:
|
||||
self.labels[x].set_label("%3d/%3d°" % (temp, target))
|
||||
else:
|
||||
self.labels[x].set_label("%3d°" % (temp))
|
||||
self.labels[x].set_label("%3d°" % temp)
|
||||
|
@ -6,6 +6,7 @@ from gi.repository import Gdk, Gtk, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return LimitsPanel(*args)
|
||||
|
||||
@ -30,14 +31,14 @@ class LimitsPanel(ScreenPanel):
|
||||
conf = self._printer.get_config_section("printer")
|
||||
self.options = [
|
||||
{"name": _("Max Acceleration"), "units": _("mm/s^2"), "option": "max_accel",
|
||||
"max": self.stn(conf['max_accel'])},
|
||||
"max": self.stn(conf['max_accel'])},
|
||||
{"name": _("Max Acceleration to Deceleration"), "units": _("mm/s^2"), "option": "max_accel_to_decel",
|
||||
"max": self.stn(conf['max_accel_to_decel']) if "max_accel_to_decel" in conf else
|
||||
round(self.stn(conf['max_accel'])/2)},
|
||||
"max": self.stn(conf['max_accel_to_decel']) if "max_accel_to_decel" in conf else
|
||||
round(self.stn(conf['max_accel']) / 2)},
|
||||
{"name": _("Max Velocity"), "units": _("mm/s"), "option": "max_velocity",
|
||||
"max": self.stn(conf["max_velocity"])},
|
||||
"max": self.stn(conf["max_velocity"])},
|
||||
{"name": _("Square Corner Velocity"), "units": _("mm/s"), "option": "square_corner_velocity",
|
||||
"max": self.stn(conf['square_corner_velocity']) if "square_corner_velocity" in conf else 5}
|
||||
"max": self.stn(conf['square_corner_velocity']) if "square_corner_velocity" in conf else 5}
|
||||
]
|
||||
|
||||
for opt in self.options:
|
||||
@ -50,7 +51,7 @@ class LimitsPanel(ScreenPanel):
|
||||
return int(float(str))
|
||||
|
||||
def process_update(self, action, data):
|
||||
if (action != "notify_status_update"):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
for opt in self.limits:
|
||||
@ -132,10 +133,10 @@ class LimitsPanel(ScreenPanel):
|
||||
value = self.limits[opt]['scale'].get_value()
|
||||
|
||||
if opt == "max_accel":
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT ACCEL=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT ACCEL=%s" % value)
|
||||
elif opt == "max_accel_to_decel":
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT ACCEL_TO_DECEL=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT ACCEL_TO_DECEL=%s" % value)
|
||||
elif opt == "max_velocity":
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT VELOCITY=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT VELOCITY=%s" % value)
|
||||
elif opt == "square_corner_velocity":
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=%s" % value)
|
||||
|
@ -8,9 +8,11 @@ from panels.menu import MenuPanel
|
||||
from ks_includes.widgets.graph import HeaterGraph
|
||||
from ks_includes.widgets.keypad import Keypad
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return MainPanel(*args)
|
||||
|
||||
|
||||
class MainPanel(MenuPanel):
|
||||
def __init__(self, screen, title, back=False):
|
||||
super().__init__(screen, title, False)
|
||||
@ -135,7 +137,6 @@ class MainPanel(MenuPanel):
|
||||
name.set_alignment(0, .5)
|
||||
name.get_style_context().add_class(class_name)
|
||||
child = name.get_children()[0].get_children()[0].get_children()[1]
|
||||
child.set_ellipsize(True)
|
||||
child.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
|
||||
temp = self._gtk.Button("")
|
||||
@ -225,7 +226,6 @@ class MainPanel(MenuPanel):
|
||||
box.add(scroll)
|
||||
box.add(self.labels['da'])
|
||||
|
||||
|
||||
self.labels['graph_settemp'] = self._gtk.Button(label=_("Set Temp"))
|
||||
self.labels['graph_settemp'].connect("clicked", self.show_numpad)
|
||||
self.labels['graph_hide'] = self._gtk.Button(label=_("Hide"))
|
||||
|
@ -7,12 +7,15 @@ from jinja2 import Environment, Template
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return MenuPanel(*args)
|
||||
|
||||
|
||||
class MenuPanel(ScreenPanel):
|
||||
i = 0
|
||||
j2_data = None
|
||||
|
||||
def initialize(self, panel_name, display_name, items):
|
||||
_ = self.lang.gettext
|
||||
|
||||
@ -57,15 +60,15 @@ class MenuPanel(ScreenPanel):
|
||||
if length <= 4:
|
||||
# Arrange 2 x 2
|
||||
columns = 2
|
||||
elif length > 4 and length <= 6:
|
||||
elif 4 < length <= 6:
|
||||
# Arrange 3 x 2
|
||||
columns = 3
|
||||
|
||||
col = i % columns
|
||||
row = int(i/columns)
|
||||
row = int(i / columns)
|
||||
|
||||
width = height = 1
|
||||
if expandLast is True and i+1 == length and length % 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, height)
|
||||
@ -84,7 +87,7 @@ 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'] is not False:
|
||||
b.connect("clicked", self.menu_item_clicked, item['panel'], item)
|
||||
|
@ -11,14 +11,15 @@ AXIS_X = "X"
|
||||
AXIS_Y = "Y"
|
||||
AXIS_Z = "Z"
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return MovePanel(*args)
|
||||
|
||||
|
||||
class MovePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['.1', '.5', '1', '5', '10', '25', '50']
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
self.settings = {}
|
||||
@ -103,9 +104,9 @@ class MovePanel(ScreenPanel):
|
||||
self.labels[i].set_direction(Gtk.TextDirection.LTR)
|
||||
self.labels[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if (self._screen.lang_ltr and j == 0) or (not self._screen.lang_ltr and j == len(self.distances)-1):
|
||||
if (self._screen.lang_ltr and j == 0) or (not self._screen.lang_ltr and j == len(self.distances) - 1):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif (not self._screen.lang_ltr and j == 0) or (self._screen.lang_ltr and j == len(self.distances)-1):
|
||||
elif (not self._screen.lang_ltr and j == 0) or (self._screen.lang_ltr and j == len(self.distances) - 1):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -229,7 +230,7 @@ class MovePanel(ScreenPanel):
|
||||
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"%s\n%s %s%s F%s%s" % (
|
||||
KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
|
||||
KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed * 60,
|
||||
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") is True else ""
|
||||
)
|
||||
)
|
||||
@ -258,19 +259,19 @@ class MovePanel(ScreenPanel):
|
||||
switch.set_vexpand(False)
|
||||
switch.set_active(self._config.get_config().getboolean(option['section'], opt_name))
|
||||
switch.connect("notify::active", self.switch_config_option, option['section'], opt_name)
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size()*7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size()*3.5))
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size() * 7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size() * 3.5))
|
||||
box.add(switch)
|
||||
dev.add(box)
|
||||
elif option['type'] == "scale":
|
||||
dev.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
val = int(self._config.get_config().get(option['section'], opt_name, fallback=option['value']))
|
||||
adj = Gtk.Adjustment(val, option['range'][0], option['range'][1], option['step'], option['step']*5)
|
||||
adj = Gtk.Adjustment(val, option['range'][0], option['range'][1], option['step'], option['step'] * 5)
|
||||
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
|
||||
scale.set_hexpand(True)
|
||||
scale.set_digits(0)
|
||||
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
||||
scale.set_property("width-request", round(self._screen.width/2.2))
|
||||
scale.set_property("width-request", round(self._screen.width / 2.2))
|
||||
dev.add(scale)
|
||||
|
||||
frame = Gtk.Frame()
|
||||
|
@ -8,9 +8,11 @@ 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):
|
||||
return NetworkPanel(*args)
|
||||
|
||||
|
||||
class NetworkPanel(ScreenPanel):
|
||||
initialized = False
|
||||
|
||||
@ -38,7 +40,7 @@ class NetworkPanel(ScreenPanel):
|
||||
ints = netifaces.interfaces()
|
||||
if 'lo' in ints:
|
||||
ints.pop(ints.index('lo'))
|
||||
if (len(ints) > 0):
|
||||
if len(ints) > 0:
|
||||
self.interface = ints[0]
|
||||
else:
|
||||
self.interface = 'lo'
|
||||
@ -69,7 +71,6 @@ class NetworkPanel(ScreenPanel):
|
||||
sbox.add(self.labels['ip'])
|
||||
sbox.add(reload_networks)
|
||||
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
@ -151,7 +152,7 @@ class NetworkPanel(ScreenPanel):
|
||||
display_name += " (" + _("Connected") + ")"
|
||||
|
||||
name = Gtk.Label("")
|
||||
name.set_markup("<big><b>%s</b></big>" % (display_name))
|
||||
name.set_markup("<big><b>%s</b></big>" % display_name)
|
||||
name.set_hexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
name.set_line_wrap(True)
|
||||
@ -372,7 +373,6 @@ class NetworkPanel(ScreenPanel):
|
||||
save.set_hexpand(False)
|
||||
save.connect("clicked", self.add_new_network, ssid, True)
|
||||
|
||||
|
||||
self.labels['network_psk'] = entry
|
||||
box.pack_start(label, False, False, 5)
|
||||
box.pack_start(entry, True, True, 5)
|
||||
@ -428,7 +428,7 @@ class NetworkPanel(ScreenPanel):
|
||||
lvl = netinfo['signal_level_dBm'] + " " + _("dBm")
|
||||
|
||||
self.labels['networks'][ssid]['info'].set_markup("%s <small>%s %s %s %s</small>" % (
|
||||
info, encr, freq, chan, lvl))
|
||||
info, encr, freq, chan, lvl))
|
||||
self.labels['networks'][ssid]['info'].show_all()
|
||||
|
||||
def update_single_network_info(self):
|
||||
|
@ -6,9 +6,11 @@ from gi.repository import Gdk, Gtk, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return PowerPanel(*args)
|
||||
|
||||
|
||||
class PowerPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@ -47,7 +49,7 @@ class PowerPanel(ScreenPanel):
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
name = Gtk.Label()
|
||||
name.set_markup("<big><b>%s</b></big>" % (device))
|
||||
name.set_markup("<big><b>%s</b></big>" % device)
|
||||
name.set_hexpand(True)
|
||||
name.set_vexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
@ -59,8 +61,8 @@ class PowerPanel(ScreenPanel):
|
||||
switch.set_hexpand(False)
|
||||
switch.set_active(True if self._screen.printer.get_power_device_status(device) == "on" else False)
|
||||
switch.connect("notify::active", self.on_switch, device)
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size()*7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size()*3.5))
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size() * 7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size() * 3.5))
|
||||
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
|
@ -9,9 +9,11 @@ from datetime import datetime
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return PrintPanel(*args)
|
||||
|
||||
|
||||
class PrintPanel(ScreenPanel):
|
||||
cur_directory = "gcodes"
|
||||
dir_panels = {}
|
||||
@ -167,13 +169,13 @@ class PrintPanel(ScreenPanel):
|
||||
filename = filepath.split('/')[-1]
|
||||
for i in range(1, len(dir)):
|
||||
curdir = "/".join(dir[0:i])
|
||||
newdir = "/".join(dir[0:i+1])
|
||||
newdir = "/".join(dir[0:i + 1])
|
||||
if newdir not in self.filelist[curdir]['directories']:
|
||||
self.add_directory(newdir)
|
||||
|
||||
if filename not in self.filelist[directory]['files']:
|
||||
for i in range(1, len(dir)):
|
||||
curdir = "/".join(dir[0:i+1])
|
||||
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(
|
||||
@ -290,7 +292,7 @@ class PrintPanel(ScreenPanel):
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup("<b>%s</b>\n" % (filename))
|
||||
label.set_markup("<b>%s</b>\n" % filename)
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_vexpand(True)
|
||||
@ -319,7 +321,7 @@ class PrintPanel(ScreenPanel):
|
||||
if response_id == Gtk.ResponseType.CANCEL:
|
||||
return
|
||||
|
||||
logging.info("Starting print: %s" % (filename))
|
||||
logging.info("Starting print: %s" % filename)
|
||||
self._screen._ws.klippy.print_start(filename)
|
||||
|
||||
def delete_file(self, filename):
|
||||
@ -370,7 +372,7 @@ class PrintPanel(ScreenPanel):
|
||||
for i, suffix in enumerate(suffixes, start=2):
|
||||
unit = 1024 ** i
|
||||
if size < unit:
|
||||
return ("%.1f %s") % ((1024 * size / unit), suffix)
|
||||
return "%.1f %s" % ((1024 * size / unit), suffix)
|
||||
|
||||
def get_print_time(self, filename):
|
||||
fileinfo = self._screen.files.get_file_info(filename)
|
||||
@ -382,16 +384,16 @@ class PrintPanel(ScreenPanel):
|
||||
print_str = ""
|
||||
|
||||
# Figure out how many days
|
||||
print_val = int(print_time/86400)
|
||||
print_val = int(print_time / 86400)
|
||||
if print_val > 0:
|
||||
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"
|
||||
|
@ -7,9 +7,11 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.PrinterSelect")
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return PrinterSelect(*args)
|
||||
|
||||
|
||||
class PrinterSelect(ScreenPanel):
|
||||
def __init__(self, screen, title, back=True, action_bar=True, printer_name=True):
|
||||
super().__init__(screen, title, False, False, False)
|
||||
@ -32,7 +34,7 @@ class PrinterSelect(ScreenPanel):
|
||||
if length == 4:
|
||||
# Arrange 2 x 2
|
||||
columns = 2
|
||||
elif length > 4 and length <= 6:
|
||||
elif 4 < length <= 6:
|
||||
# Arrange 3 x 2
|
||||
columns = 3
|
||||
else:
|
||||
@ -44,8 +46,8 @@ class PrinterSelect(ScreenPanel):
|
||||
self.labels[name].connect("clicked", self._screen.connect_printer_widget, name)
|
||||
if self._screen.vertical_mode:
|
||||
row = i % columns
|
||||
col = int(i/columns)
|
||||
col = int(i / columns)
|
||||
else:
|
||||
col = i % columns
|
||||
row = int(i/columns)
|
||||
row = int(i / columns)
|
||||
grid.attach(self.labels[name], col, row, 1, 1)
|
||||
|
@ -7,6 +7,7 @@ from gi.repository import Gdk, Gtk, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return FWRetractionPanel(*args)
|
||||
|
||||
@ -26,26 +27,26 @@ class FWRetractionPanel(ScreenPanel):
|
||||
"units": _("mm"),
|
||||
"option": "retract_length",
|
||||
"value": float(conf['retract_length']) if 'retract_length' in conf else 0,
|
||||
"digits":2,
|
||||
"maxval":4},
|
||||
"digits": 2,
|
||||
"maxval": 4},
|
||||
{"name": _("Retraction Speed"),
|
||||
"units": _("mm/s"),
|
||||
"option": "retract_speed",
|
||||
"value": int(float((conf['retract_speed']))) if 'retract_speed' in conf else 20,
|
||||
"digits":0,
|
||||
"maxval":100},
|
||||
"digits": 0,
|
||||
"maxval": 100},
|
||||
{"name": _("Unretract Extra Length"),
|
||||
"units": _("mm"),
|
||||
"option": "unretract_extra_length",
|
||||
"value": float(conf['unretract_extra_length']) if 'unretract_extra_length' in conf else 0,
|
||||
"digits":2,
|
||||
"maxval":15},
|
||||
"digits": 2,
|
||||
"maxval": 15},
|
||||
{"name": _("Unretract Speed"),
|
||||
"units": _("mm/s"),
|
||||
"option": "unretract_speed",
|
||||
"value": int(float((conf['unretract_speed']))) if 'unretract_speed' in conf else 10,
|
||||
"digits":0,
|
||||
"maxval":60}
|
||||
"digits": 0,
|
||||
"maxval": 60}
|
||||
]
|
||||
|
||||
for opt in self.options:
|
||||
@ -152,10 +153,10 @@ class FWRetractionPanel(ScreenPanel):
|
||||
value = self.list[opt]['scale'].get_value()
|
||||
|
||||
if opt == "retract_speed":
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION RETRACT_SPEED=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION RETRACT_SPEED=%s" % value)
|
||||
elif opt == "retract_length":
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION RETRACT_LENGTH=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION RETRACT_LENGTH=%s" % value)
|
||||
elif opt == "unretract_extra_length":
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION UNRETRACT_EXTRA_LENGTH=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION UNRETRACT_EXTRA_LENGTH=%s" % value)
|
||||
elif opt == "unretract_speed":
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION UNRETRACT_SPEED=%s" % (value))
|
||||
self._screen._ws.klippy.gcode_script("SET_RETRACTION UNRETRACT_SPEED=%s" % value)
|
||||
|
@ -6,9 +6,11 @@ from gi.repository import Gdk, Gtk, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return SettingsPanel(*args)
|
||||
|
||||
|
||||
class SettingsPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@ -113,8 +115,8 @@ class SettingsPanel(ScreenPanel):
|
||||
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)
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size()*7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size()*3.5))
|
||||
switch.set_property("width-request", round(self._gtk.get_font_size() * 7))
|
||||
switch.set_property("height-request", round(self._gtk.get_font_size() * 3.5))
|
||||
box.add(switch)
|
||||
dev.add(box)
|
||||
elif option['type'] == "dropdown":
|
||||
@ -131,12 +133,12 @@ class SettingsPanel(ScreenPanel):
|
||||
dev.add(dropdown)
|
||||
elif option['type'] == "scale":
|
||||
val = int(self._config.get_config().get(option['section'], opt_name, fallback=option['value']))
|
||||
adj = Gtk.Adjustment(val, option['range'][0], option['range'][1], option['step'], option['step']*5)
|
||||
adj = Gtk.Adjustment(val, option['range'][0], option['range'][1], option['step'], option['step'] * 5)
|
||||
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
|
||||
scale.set_hexpand(True)
|
||||
scale.set_digits(0)
|
||||
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
||||
scale.set_property("width-request", round(self._screen.width/2.2))
|
||||
scale.set_property("width-request", round(self._screen.width / 2.2))
|
||||
dev.add(scale)
|
||||
elif option['type'] == "printer":
|
||||
logging.debug("Option: %s" % option)
|
||||
|
@ -7,9 +7,11 @@ from gi.repository import Gdk, Gtk, Pango
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return SplashScreenPanel(*args)
|
||||
|
||||
|
||||
class SplashScreenPanel(ScreenPanel):
|
||||
box = None
|
||||
|
||||
@ -129,7 +131,6 @@ class SplashScreenPanel(ScreenPanel):
|
||||
def restart(self, widget):
|
||||
self._screen._ws.klippy.restart()
|
||||
|
||||
|
||||
def shutdown(self, widget):
|
||||
_ = self.lang.gettext
|
||||
if self._screen._ws.is_connected():
|
||||
|
@ -8,12 +8,14 @@ from datetime import datetime
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return SystemPanel(*args)
|
||||
|
||||
|
||||
ALLOWED_SERVICES = ["KlipperScreen", "MoonCord", "klipper", "moonraker"]
|
||||
|
||||
|
||||
class SystemPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
@ -74,7 +76,6 @@ class SystemPanel(ScreenPanel):
|
||||
logging.info("Updating program: %s " % prog)
|
||||
self.update_program_info(prog)
|
||||
|
||||
|
||||
infogrid.attach(self.labels[prog], 1, i, 1, 1)
|
||||
self.labels[prog].get_style_context().add_class('updater-item')
|
||||
i = i + 1
|
||||
@ -116,7 +117,6 @@ class SystemPanel(ScreenPanel):
|
||||
if 'application' in data:
|
||||
self.labels['update_progress'].set_text(self.labels['update_progress'].get_text().strip() + "\n" +
|
||||
data['message'] + "\n")
|
||||
self.labels['update_progress'].set_ellipsize(True)
|
||||
self.labels['update_progress'].set_ellipsize(Pango.EllipsizeMode.END)
|
||||
adjustment = self.labels['update_scroll'].get_vadjustment()
|
||||
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size())
|
||||
@ -199,7 +199,7 @@ class SystemPanel(ScreenPanel):
|
||||
grid.attach(label, 0, i, 1, 1)
|
||||
i = i + 1
|
||||
|
||||
details = Gtk.Label(label=c['message']+"\n\n\n")
|
||||
details = Gtk.Label(label=c['message'] + "\n\n\n")
|
||||
details.set_line_wrap(True)
|
||||
details.set_halign(Gtk.Align.START)
|
||||
grid.attach(details, 0, i, 1, 1)
|
||||
@ -216,12 +216,11 @@ class SystemPanel(ScreenPanel):
|
||||
label = Gtk.Label()
|
||||
label.set_markup(" %s " % c)
|
||||
label.set_halign(Gtk.Align.START)
|
||||
label.set_ellipsize(True)
|
||||
label.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
pos = (j % 3)
|
||||
grid.attach(label, pos, i, 1, 1)
|
||||
j = j + 1
|
||||
if (pos == 2):
|
||||
if pos == 2:
|
||||
i = i + 1
|
||||
elif "full" in info:
|
||||
label.set_markup("<b>" + _("Perform a full upgrade?") + "</b>")
|
||||
|
@ -8,9 +8,11 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
from ks_includes.widgets.graph import HeaterGraph
|
||||
from ks_includes.widgets.keypad import Keypad
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return TemperaturePanel(*args)
|
||||
|
||||
|
||||
class TemperaturePanel(ScreenPanel):
|
||||
graph_update = None
|
||||
active_heater = None
|
||||
@ -84,9 +86,9 @@ class TemperaturePanel(ScreenPanel):
|
||||
self.labels["preheat_grid"] = self._gtk.HomogeneousGrid()
|
||||
for i, option in enumerate(self.preheat_options):
|
||||
if option != "cooldown":
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4)+1))
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4) + 1))
|
||||
self.labels[option].connect("clicked", self.set_temperature, option)
|
||||
self.labels['preheat_grid'].attach(self.labels[option], (i % 2), int(i/2), 1, 1)
|
||||
self.labels['preheat_grid'].attach(self.labels[option], (i % 2), int(i / 2), 1, 1)
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
@ -116,7 +118,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
ctx = self.labels['deg' + i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("distbutton_top")
|
||||
elif j == len(self.tempdeltas)-1:
|
||||
elif j == len(self.tempdeltas) - 1:
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -343,7 +345,6 @@ class TemperaturePanel(ScreenPanel):
|
||||
name.set_alignment(0, .5)
|
||||
name.get_style_context().add_class(class_name)
|
||||
child = name.get_children()[0].get_children()[0].get_children()[1]
|
||||
child.set_ellipsize(True)
|
||||
child.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
|
||||
temp = self._gtk.Button("")
|
||||
@ -435,7 +436,6 @@ class TemperaturePanel(ScreenPanel):
|
||||
box.add(scroll)
|
||||
box.add(self.labels['da'])
|
||||
|
||||
|
||||
self.labels['graph_settemp'] = self._gtk.Button(label=_("Set Temp"))
|
||||
self.labels['graph_settemp'].connect("clicked", self.show_numpad)
|
||||
self.labels['graph_hide'] = self._gtk.Button(label=_("Hide"))
|
||||
@ -461,7 +461,6 @@ class TemperaturePanel(ScreenPanel):
|
||||
self.labels['da'].set_size_request(0, graph_height)
|
||||
return box
|
||||
|
||||
|
||||
def graph_show_device(self, widget, show=True):
|
||||
logging.info("Graph show: %s %s" % (self.popover_device, show))
|
||||
self.labels['da'].set_showing(self.popover_device, show)
|
||||
|
@ -8,9 +8,11 @@ from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
def create_panel(*args):
|
||||
return ZCalibratePanel(*args)
|
||||
|
||||
|
||||
class ZCalibratePanel(ScreenPanel):
|
||||
_screen = None
|
||||
widgets = {}
|
||||
@ -65,7 +67,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
else:
|
||||
functions.remove("endstop")
|
||||
|
||||
if (self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch")):
|
||||
if self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch"):
|
||||
probe = self._gtk.Button(label="Probe")
|
||||
probe.connect("clicked", self.start_calibration, "probe")
|
||||
pobox.pack_start(probe, True, True, 5)
|
||||
@ -81,7 +83,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
functions.remove("mesh")
|
||||
|
||||
if "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
|
||||
if (self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch")):
|
||||
if self._printer.config_section_exists("probe") or self._printer.config_section_exists("bltouch"):
|
||||
delta = self._gtk.Button(label="Delta Automatic")
|
||||
delta.connect("clicked", self.start_calibration, "delta")
|
||||
pobox.pack_start(delta, True, True, 5)
|
||||
@ -112,9 +114,9 @@ class ZCalibratePanel(ScreenPanel):
|
||||
self.widgets[i].set_direction(Gtk.TextDirection.LTR)
|
||||
self.widgets[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.widgets[i].get_style_context()
|
||||
if (self._screen.lang_ltr and j == 0) or (not self._screen.lang_ltr and j == len(self.distances)-1):
|
||||
if (self._screen.lang_ltr and j == 0) or (not self._screen.lang_ltr and j == len(self.distances) - 1):
|
||||
ctx.add_class("distbutton_top")
|
||||
elif (not self._screen.lang_ltr and j == 0) or (self._screen.lang_ltr and j == len(self.distances)-1):
|
||||
elif (not self._screen.lang_ltr and j == 0) or (self._screen.lang_ltr and j == len(self.distances) - 1):
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
@ -184,8 +186,8 @@ class ZCalibratePanel(ScreenPanel):
|
||||
self._screen._ws.klippy.gcode_script('G0 X%d Y%d F3000' % (0, 0))
|
||||
else:
|
||||
logging.debug("Position not configured, probing the middle of the bed")
|
||||
x_position = int(int(self._screen.printer.get_config_section("stepper_x")['position_max'])/2)
|
||||
y_position = int(int(self._screen.printer.get_config_section("stepper_y")['position_max'])/2)
|
||||
x_position = int(int(self._screen.printer.get_config_section("stepper_x")['position_max']) / 2)
|
||||
y_position = int(int(self._screen.printer.get_config_section("stepper_y")['position_max']) / 2)
|
||||
|
||||
# Find probe offset
|
||||
klipper_cfg = self._screen.printer.get_config_section_list()
|
||||
|
17
screen.py
17
screen.py
@ -51,6 +51,7 @@ PRINTER_BASE_STATUS_OBJECTS = [
|
||||
|
||||
klipperscreendir = pathlib.Path(__file__).parent.resolve()
|
||||
|
||||
|
||||
class KlipperScreen(Gtk.Window):
|
||||
""" Class for creating a screen for Klipper via HDMI """
|
||||
_cur_panels = []
|
||||
@ -440,7 +441,6 @@ class KlipperScreen(Gtk.Window):
|
||||
widget.destroy()
|
||||
|
||||
def init_style(self):
|
||||
style_provider = Gtk.CssProvider()
|
||||
css = open(os.path.join(klipperscreendir, "styles", "base.css"))
|
||||
css_data = css.read()
|
||||
css.close()
|
||||
@ -475,17 +475,17 @@ class KlipperScreen(Gtk.Window):
|
||||
)
|
||||
for i in range(len(style_options['graph_colors']['bed']['colors'])):
|
||||
css_data += "\n.graph_label_heater_bed%s {border-left-color: #%s}" % (
|
||||
"" if i+1 == 1 else i+1,
|
||||
"" if i + 1 == 1 else i + 1,
|
||||
style_options['graph_colors']['bed']['colors'][i]
|
||||
)
|
||||
for i in range(len(style_options['graph_colors']['fan']['colors'])):
|
||||
css_data += "\n.graph_label_fan_%s {border-left-color: #%s}" % (
|
||||
i+1,
|
||||
i + 1,
|
||||
style_options['graph_colors']['fan']['colors'][i]
|
||||
)
|
||||
for i in range(len(style_options['graph_colors']['sensor']['colors'])):
|
||||
css_data += "\n.graph_label_sensor_%s {border-left-color: #%s}" % (
|
||||
i+1,
|
||||
i + 1,
|
||||
style_options['graph_colors']['sensor']['colors'][i]
|
||||
)
|
||||
|
||||
@ -943,7 +943,7 @@ class KlipperScreen(Gtk.Window):
|
||||
if state['result']['klippy_connected'] is False:
|
||||
self.panels['splash_screen'].update_text(
|
||||
_("Moonraker: connected") +
|
||||
("\n\nKlipper: %s\n\n") % state['result']['klippy_state'] +
|
||||
"\n\nKlipper: %s\n\n" % state['result']['klippy_state'] +
|
||||
_("Retry #%s") % self.reinit_count)
|
||||
return False
|
||||
|
||||
@ -979,7 +979,7 @@ class KlipperScreen(Gtk.Window):
|
||||
)
|
||||
|
||||
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS +
|
||||
extra_items))
|
||||
extra_items))
|
||||
if data is False:
|
||||
msg = "Error getting printer object data with extra items"
|
||||
logging.info(msg)
|
||||
@ -1002,7 +1002,7 @@ class KlipperScreen(Gtk.Window):
|
||||
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
|
||||
# Force an 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.show_panel('main_panel', "main_menu", _("Home"), 2,
|
||||
items=self._config.get_menu_items("__main"), extrudercount=self.printer.get_extruder_count())
|
||||
@ -1073,8 +1073,8 @@ class KlipperScreen(Gtk.Window):
|
||||
os.system("xsetroot -cursor ks_includes/emptyCursor.xbm ks_includes/emptyCursor.xbm")
|
||||
return
|
||||
|
||||
def main():
|
||||
|
||||
def main():
|
||||
version = functions.get_software_version()
|
||||
parser = argparse.ArgumentParser(description="KlipperScreen - A GUI for Klipper")
|
||||
parser.add_argument(
|
||||
@ -1096,7 +1096,6 @@ def main():
|
||||
|
||||
logging.info("KlipperScreen version: %s" % version)
|
||||
|
||||
|
||||
win = KlipperScreen(args, version)
|
||||
win.connect("destroy", Gtk.main_quit)
|
||||
win.show_all()
|
||||
|
Loading…
x
Reference in New Issue
Block a user