Compare commits

...
61 Commits
Author SHA1 Message Date
alfrix 8af5c0b2d4 Trace memory 2023-03-24 08:12:19 -06:00
alfrix da9f970231 print: refactors 2023-03-22 06:51:34 -06:00
alfrix 3417765223 job_status: fix panel not showing and not updating thumbnails
safeguard against thumbnail corruption or other errors fixes #893
better system to update name and thumbnails fixes #889
2023-03-19 05:55:30 -06:00
alfrix b963c55140 job_status: fix save endstop not working fixes #929 2023-03-17 07:50:50 -06:00
alfrix 2d8419ca13 fix desktop icon not appearing 2023-03-17 07:50:50 -06:00
Jookiaandalfrix 5f3827a2cb screen: Only switch layouts if the window has been majorly resized (#913)
* screen: Only switch layouts if the window has been majorly resized

Changing the layout can cause the window to resize on some systems.
This can create a feedback loop on systems with square displays.

Keep track of the vertical aspect ratio associated with the current
mode and only switch between vertical and horizontal mode when a
significant aspect ratio change has been detected.

* fixup

---------

Co-authored-by: alfrix <alfredomonclus@gmail.com>
2023-03-17 07:49:28 -06:00
alfrix d6f7bdcfe6 macros: use the new get_macro instead of get_config due to recent issues 2023-03-11 16:53:08 -06:00
alfrix 87c3f03719 fix issues caused by dfe1ac8d
fix #924
fix #923
2023-03-11 16:40:06 -06:00
Alfredo Monclus 094b90cf86 network: integrate networkmanager (#917)
fixes #881
this should be temporary until an implementation of sdbus-networkmanager
2023-03-11 07:43:10 -06:00
alfrixandAndriy 3220f084ec Update Ukranian close #914
Re-done due to merge conflicts

Co-authored-by: Andriy <40995038+komandrik@users.noreply.github.com>
2023-03-10 20:29:18 -06:00
alfrix dfe1ac8d2c macros: fix list not loading when there are extra spaces fixes #909 2023-03-10 20:03:28 -06:00
alfrix be473bf626 bed_level: fix auto-detect when there is no config file fixes #918 2023-03-10 06:43:02 -06:00
alfrix b353f8526e timeout requests to prevent locking 2023-03-09 07:32:46 -06:00
alfrix 122752b000 leakfix 2023-03-09 07:32:46 -06:00
alfrix 0f0c6f9b6e always maintain printers data, should avoid a bunch of issues 2023-03-09 07:32:46 -06:00
alfrix 18af1d1410 bed_level: add center screw close #863 2023-03-08 06:36:54 -06:00
alfrix 926d78de01 bed_level: remove screws only if in list and simplify detection fixes #910 2023-03-08 06:11:23 -06:00
alfrix a5b639fba2 bed_level: fix compatibility with python 3.7 2023-03-03 08:12:41 -06:00
Alfredo Monclusandczaky 55af0d753c bed_level: improve screw detection (#908)
* Use max_distance for fitting screws to buttons

The max distance is at most 1/3 of the diagonal,
depending on how many screws are there in horizontal or
vertical orientation.

This is a safe guard to prevent assigning screws to buttons
that would confuse the users, for very skewed screw configs.

use a smaller button scale fixes #891

Co-authored-by: alfrix <alfredomonclus@gmail.com>

Co-authored-by: czaky <jendrzej.w@lczak.net>
2023-03-01 07:41:43 -06:00
alfrix d6693fbecc make the menu icon non-mandatory
this was caused by #866
fixes #902
2023-02-20 07:57:45 -06:00
alfrix e426b06b8b lint fix 2023-02-13 21:10:53 -06:00
alfrix c722674918 fix popup word wrap 2023-02-13 21:08:21 -06:00
Geoffrey Young 3d7e92f507 add ability to style and template menu buttons (#866)
* add ability to select button style for menu items

* allow for jinja template rendering for (nearly) all menu options
this shuffles params json checks to display time instead of config time
2023-02-13 21:06:33 -06:00
Thijs Triemstra fc7b8c5304 fix typos (#897) 2023-02-13 21:05:48 -06:00
alfrix a6bb0fd02e zcalibrate: fix dialog loop, fix popup errors not showing at end #844 2023-02-06 18:27:35 -06:00
dependabot[bot] dcb6d18709 build(deps): bump websocket-client from 1.5.0 to 1.5.1 (#888)
Bumps [websocket-client](https://github.com/websocket-client/websocket-client) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/websocket-client/websocket-client/releases)
- [Changelog](https://github.com/websocket-client/websocket-client/blob/master/ChangeLog)
- [Commits](https://github.com/websocket-client/websocket-client/compare/v1.5.0...v1.5.1)

---
updated-dependencies:
- dependency-name: websocket-client
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-06 16:35:20 -06:00
alfrix 69571c88b8 fix german keyboard issue caused by #886 2023-02-05 22:32:07 -06:00
Cyril Guislain c33b5d6311 Fix German Keyboard and Add French Keyboard (#886) 2023-02-05 21:47:11 -06:00
alfrix 49add980b3 theme: add light icon to material-dark fix:#884 2023-02-05 10:24:58 -06:00
dependabot[bot] 8d8d3bf9af build(deps): bump requests from 2.28.1 to 2.28.2 (#868)
Bumps [requests](https://github.com/psf/requests) from 2.28.1 to 2.28.2.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.28.1...v2.28.2)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-05 10:20:24 -06:00
alfrix 059f1a8026 update docs screenshot 2023-01-29 15:49:41 -06:00
alfrix eeffdd26dd mask modemmanager close #857 2023-01-29 15:49:41 -06:00
camerony 5de5e1e3eb Update on-screen keyboard.py (#874) 2023-01-29 09:54:53 -06:00
dependabot[bot] 485c82c53f build(deps): bump websocket-client from 1.4.2 to 1.5.0 (#877)
Bumps [websocket-client](https://github.com/websocket-client/websocket-client) from 1.4.2 to 1.5.0.
- [Release notes](https://github.com/websocket-client/websocket-client/releases)
- [Changelog](https://github.com/websocket-client/websocket-client/blob/master/ChangeLog)
- [Commits](https://github.com/websocket-client/websocket-client/compare/v1.4.2...v1.5.0)

---
updated-dependencies:
- dependency-name: websocket-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-29 09:43:04 -06:00
camerony 4e60f65404 network: fix button size, and update ipv4 address on network change (#879) 2023-01-29 09:42:49 -06:00
camerony 85cec193f9 Fix Changing wifi networks hangs 2023-01-29 09:40:45 -06:00
alfrix 34055277e0 Add czech and update ru .mo 2023-01-29 09:34:29 -06:00
AleksandrBukin 9b4c58369e Update Ru (#871)
line 626: "Show Heater Power" in RU "Показать мощность нагрева"
2023-01-29 09:16:18 -06:00
AntoszHUN b96adf55ed Update Hungarian Language (#848) 2022-12-13 20:04:48 -03:00
Alex Hornung f6afb4d4ab install: Fix Xwrapper.config existence test (#846) 2022-12-13 20:04:08 -03:00
alfrix 3c5449f0db job_status: cast float to zoffset 2022-12-12 19:53:34 -03:00
alfrix c828d8349c camera: fix for busters old libmpv fixes #840 2022-12-12 08:12:52 -03:00
alfrix 9fa047eb8b camera: fix libmpv-dev not installing fixes #842 2022-12-12 08:00:38 -03:00
alfrix 82b8cbcca5 zcalibrate: fix initial zhop causing issues for some machines fixes #837 2022-12-12 01:42:30 -03:00
alfrix 1f5a090bfd camera: always fullscreen, fix inverted vo logic, fixes #839 2022-12-12 01:25:36 -03:00
alfrix e4d5cd65ce fix a couple of errors that may happen if klipper fails to start or takes too long 2022-12-11 19:22:45 -03:00
alfrix 502d9699bd fix actions not appearing in printers without name after last commit fix #838 2022-12-11 15:25:28 -03:00
alfrix d2d2c82041 feat: camera support, using mpv as backend
it should be able to play any video or stream that mpv itself can handle

close #67 close #129
2022-12-11 09:20:06 -03:00
alfrix 1375c823c9 job_status: clear_file after error 2022-12-11 09:20:06 -03:00
alfrix 74338a7f3e splash: fix power_device appearing if configured in ks.conf but not available in the server 2022-12-11 09:20:06 -03:00
alfrix 778cd84ba8 panels do not call screen.show_all 2022-12-11 09:17:18 -03:00
alfrix a83f499c0c rename graph to heatergraph 2022-12-11 09:17:18 -03:00
alfrix 70d7564a78 shorten _screen.printer to _printer 2022-12-11 09:17:18 -03:00
alfrix f31ae7a829 hide popups from panel initialization
ideally the initialization should not contain this commands but at the moment klipper nor moonraker provide a way to identify the required status
2022-12-11 09:17:18 -03:00
alfrix 701ff35652 installer: if pip fails upgrade and retry once 2022-12-11 09:17:18 -03:00
alfrix 7120c424d4 gtk: resizability
doesn't rescale the fonts or images
2022-12-11 09:17:18 -03:00
alfrix 413e822fa5 screen: separate matchbox-keyboard 2022-12-11 09:17:18 -03:00
alfrix 75c716f9a1 screen: convert state execute into a function since it doesn't depend on self 2022-12-11 09:17:18 -03:00
alfrix 41a8ebf084 print: add move/rename, make delete a visible button close #636 2022-12-11 09:17:18 -03:00
Selim 57ce346d69 Turkish language update (#836) 2022-12-11 08:35:58 -03:00
alfrix 753be13a0c exclude: fix list not showing 2022-12-05 14:29:58 -03:00
46 changed files with 2922 additions and 511 deletions

No files matched your search

+6 -1
View File
@@ -79,7 +79,7 @@ calibrate_y_position: 100
# Bed Screws
# define the screw positons required for odd number of screws in a comma separated list
# possible values are: bl, br, bm, fl, fr, fm, lm, rm
# possible values are: bl, br, bm, fl, fr, fm, lm, rm, center
# they correspond to back-left, back-right, back-middle, front-left, front-right, front-middle, left-middle, right-middle
screw_positions: ""
@@ -90,6 +90,9 @@ screw_rotation: 0
# Define distances and speeds for the extrude panel. CSV list 2 to 4 integers
extrude_distances: 5, 10, 15, 25
extrude_speeds: 1, 2, 5, 25
# Camera configuration
camera_url: http://127.0.0.1/webcam/?action=stream
```
## Preheat Options
@@ -130,6 +133,8 @@ A menu item is configured as follows:
name: Item Name
icon: home
# Optional Parameters
# Icon style, defined as "button.mycolor4" (for example) in the theme css
style: mycolor4
# Panel from the panels listed below
panel: preheat
# Moonraker method to call when the item is selected
Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 13 KiB

+39 -49
View File
@@ -27,44 +27,52 @@ def format_label(widget, lines=2):
class KlippyGtk:
labels = {}
def __init__(self, screen, width, height, theme, cursor, fontsize_type):
def __init__(self, screen):
self.screen = screen
self.width = width
self.height = height
self.themedir = os.path.join(pathlib.Path(__file__).parent.resolve().parent, "styles", theme, "images")
self.cursor = cursor
self.font_size_type = fontsize_type
self.themedir = os.path.join(pathlib.Path(__file__).parent.resolve().parent, "styles", screen.theme, "images")
self.cursor = screen.show_cursor
self.font_size_type = screen._config.get_main_config().get("font_size", "medium")
self.width = screen.width
self.height = screen.height
self.font_ratio = [33, 49] if self.screen.vertical_mode else [43, 29]
self.font_size = min(self.width / self.font_ratio[0], self.height / self.font_ratio[1])
self.img_scale = self.font_size * 2
self.button_image_scale = 1.38
self.bsidescale = .65 # Buttons with image at the side
if fontsize_type == "max":
if self.font_size_type == "max":
self.font_size = self.font_size * 1.2
self.bsidescale = .7
elif fontsize_type == "extralarge":
elif self.font_size_type == "extralarge":
self.font_size = self.font_size * 1.14
self.img_scale = self.img_scale * 0.7
self.bsidescale = 1
elif fontsize_type == "large":
elif self.font_size_type == "large":
self.font_size = self.font_size * 1.09
self.img_scale = self.img_scale * 0.9
self.bsidescale = .8
elif fontsize_type == "small":
elif self.font_size_type == "small":
self.font_size = self.font_size * 0.91
self.bsidescale = .55
self.img_width = self.font_size * 3
self.img_height = self.font_size * 3
self.titlebar_height = self.font_size * 2
logging.info(f"Font size: {self.font_size} ({fontsize_type})")
logging.info(f"Font size: {self.font_size:.1f} ({self.font_size_type})")
if self.screen.vertical_mode:
self.action_bar_width = int(self.width)
self.action_bar_height = int(self.height * .1)
self.content_width = self.width
self.content_height = self.height - self.titlebar_height - self.action_bar_height
else:
self.action_bar_width = int(self.width * .1)
self.action_bar_height = int(self.height)
self.content_width = self.width - self.action_bar_width
self.content_height = self.height - self.titlebar_height
self.keyboard_height = self.content_height * 0.5
if (self.height / self.width) >= 3: # Ultra-tall
self.keyboard_height = self.keyboard_height * 0.5
self.color_list = {} # This is set by screen.py init_style()
for key in self.color_list:
@@ -72,35 +80,6 @@ class KlippyGtk:
rgb = [int(self.color_list[key]['base'][i:i + 2], 16) for i in range(0, 6, 2)]
self.color_list[key]['rgb'] = rgb
def get_action_bar_width(self):
return self.action_bar_width
def get_action_bar_height(self):
return self.action_bar_height
def get_content_width(self):
if self.screen.vertical_mode:
return self.width
return self.width - self.action_bar_width
def get_content_height(self):
if self.screen.vertical_mode:
return self.height - self.titlebar_height - self.action_bar_height
return self.height - self.titlebar_height
def get_font_size(self):
return self.font_size
def get_titlebar_height(self):
return self.titlebar_height
def get_keyboard_height(self):
if (self.height / self.width) >= 3:
# Ultra-tall
return self.get_content_height() * 0.25
else:
return self.get_content_height() * 0.5
def get_temp_color(self, device):
# logging.debug("Color list %s" % self.color_list)
if device not in self.color_list:
@@ -137,27 +116,38 @@ class KlippyGtk:
def Image(self, image_name=None, width=None, height=None):
if image_name is None:
return Gtk.Image()
pixbuf = self.PixbufFromIcon(image_name, width, height)
return Gtk.Image.new_from_pixbuf(pixbuf) if pixbuf is not None else Gtk.Image()
def PixbufFromIcon(self, filename, width=None, height=None):
width = width if width is not None else self.img_width
height = height if height is not None else self.img_height
filename = os.path.join(self.themedir, image_name)
filename = os.path.join(self.themedir, filename)
for ext in ["svg", "png"]:
with contextlib.suppress(Exception):
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(f"{filename}.{ext}", int(width), int(height))
if pixbuf is not None:
return Gtk.Image.new_from_pixbuf(pixbuf)
logging.error(f"Unable to find image {filename}.{ext}")
return Gtk.Image()
pixbuf = self.PixbufFromFile(f"{filename}.{ext}", int(width), int(height))
if pixbuf is not None:
return pixbuf
return None
@staticmethod
def PixbufFromFile(filename, width=-1, height=-1):
return GdkPixbuf.Pixbuf.new_from_file_at_size(filename, int(width), int(height))
try:
return GdkPixbuf.Pixbuf.new_from_file_at_size(filename, int(width), int(height))
except Exception as e:
logging.exception(e)
logging.error(f"Unable to find image {filename}")
return None
def PixbufFromHttp(self, resource, width=-1, height=-1):
response = self.screen.apiclient.get_thumbnail_stream(resource)
if response is False:
return None
stream = Gio.MemoryInputStream.new_from_data(response, None)
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(width), int(height), True)
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(width), int(height), True)
except Exception as e:
logging.exception(e)
return None
stream.close_async(2)
return pixbuf
+1 -1
View File
@@ -37,7 +37,7 @@ class KlippyRest:
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
data = False
try:
response = requests.get(url, headers=headers)
response = requests.get(url, headers=headers, timeout=3)
response.raise_for_status()
if json:
logging.debug(f"Sending request to {url}")
File diff suppressed because it is too large. Load diff
+5 -9
View File
@@ -165,7 +165,7 @@ class KlipperScreenConfig:
strs = (
'moonraker_api_key', 'moonraker_host', 'titlebar_name_type',
'screw_positions', 'power_devices', 'titlebar_items', 'z_babystep_values',
'extrude_distances', "extrude_speeds",
'extrude_distances', "extrude_speeds", "camera_url",
)
numbers = (
'moonraker_port', 'move_speed_xy', 'move_speed_z',
@@ -175,7 +175,7 @@ class KlipperScreenConfig:
strs = ('gcode', '')
numbers = [f'{option}' for option in self.config[section] if option != 'gcode']
elif section.startswith('menu '):
strs = ('name', 'icon', 'panel', 'method', 'params', 'enable', 'confirm')
strs = ('name', 'icon', 'panel', 'method', 'params', 'enable', 'confirm', 'style')
elif section == 'bed_screws':
# This section may be deprecated in favor of moving this options under the printer section
numbers = ('rotation', '')
@@ -549,13 +549,9 @@ class KlipperScreenConfig:
"panel": cfg.get("panel", None),
"method": cfg.get("method", None),
"confirm": cfg.get("confirm", None),
"enable": cfg.get("enable", "True")
"enable": cfg.get("enable", "True"),
"params": cfg.get("params", "{}"),
"style": cfg.get("style", None)
}
try:
item["params"] = json.loads(cfg.get("params", "{}"))
except Exception as e:
logging.exception(f"Unable to parse parameters for [{name}]:\n{e}")
item["params"] = {}
return {name[(len(menu) + 6):]: item}
+13
View File
@@ -128,6 +128,12 @@ icon: motor-off
method: printer.gcode.script
params: {"script":"M18"}
[menu __main actions camera]
name: {{ gettext('Camera') }}
icon: camera
panel: camera
enable: {{ camera_configured }}
[menu __main actions console]
name: {{ gettext('Console') }}
icon: console
@@ -231,6 +237,13 @@ icon: custom-script
panel: gcode_macros
enable: {{ printer.gcode_macros.count > 0 }}
[menu __print camera]
name: {{ gettext('Camera') }}
icon: camera
panel: camera
enable: {{ camera_configured }}
[menu __print console]
name: {{ gettext('Console') }}
icon: console
Binary file not shown.
@@ -0,0 +1,776 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: Czech\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-29 09:28-0600\n"
"PO-Revision-Date: 2023-01-29 09:27-0600\n"
"Last-Translator: \n"
"Language-Team: Jan Stanka (stanky@email.cz)\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n>=2 && n<=4 ? 1 : 2);\n"
"X-Generator: Poedit 2.4.2\n"
#, python-format
msgid "%s will be updated to version"
msgstr "%s bude aktualizováno na verzi"
msgid "(default)"
msgstr ""
msgid "24 Hour Time"
msgstr "24 hod formát"
msgid "A FIRMWARE_RESTART may fix the issue."
msgstr "FW restart může fixnout chyby."
msgid "ADXL Not Configured"
msgstr "ADXL není nastaven"
msgid "Abort"
msgstr "Zrušit"
msgid "Acceleration:"
msgstr "Zrychlení:"
msgid "Accept"
msgstr "Přijmout"
msgid "Actions"
msgstr "Akce"
msgid "Add profile"
msgstr "Přidat profil"
msgid "Apply"
msgstr "Použít"
#, python-format
msgid "Apply %.2f offset to Endstop?"
msgstr "Použít %.2f přesah k Endstop?"
#, python-format
msgid "Apply %s%.2f offset to Probe?"
msgstr "Použít %s%.2f přesah k Sondě?"
msgid "Are you sure do you want to exclude the object?"
msgstr "Opravdu chceš vyjmout objekt?"
msgid "Are you sure you want to run Emergency Stop?"
msgstr "Opravdu okamžitě zastavit?"
msgid "Are you sure you wish to cancel this print?"
msgstr "Opravdu chcete zrušit tisk?"
msgid "Are you sure you wish to disable motors?"
msgstr "Opravdu chcete uvolnit motory?"
msgid "Are you sure you wish to reboot the system?"
msgstr "Opravdu chcete rebootovat systém?"
msgid "Are you sure you wish to shutdown the system?"
msgstr "Opravdu chcete vypnout systém?"
msgid "Auto"
msgstr "Auto"
msgid "Auto-calibrate"
msgstr "Auto-kalibrace"
msgid "Auto-close notifications"
msgstr "Automaticky zavřít upozornění"
msgid "Auto-scroll"
msgstr "Auto posun"
msgid "Bed Level"
msgstr "Vyrovnání podložky"
msgid "Bed Mesh"
msgstr "Mapa podložky"
msgid "Bed screw configuration:"
msgstr "Vyrovnání šroubů podložky:"
msgid "Calibrate"
msgstr "Kalibrace"
msgid "Calibrated"
msgstr "Zkalibrováno"
msgid "Calibrated, save configuration to make it permanent"
msgstr "Zkalibrováno, uložit změny jako trvalé"
msgid "Calibrating"
msgstr "Kalibruji"
msgid "Camera"
msgstr ""
msgid "Can't set above the maximum:"
msgstr "Nemohu nastavit víc než max:"
msgid "Cancel"
msgstr "Zrušit"
msgid "Cancel Print"
msgstr "Zrušit tisk"
msgid "Cancelled"
msgstr "Zrušeno"
msgid "Cancelling"
msgstr "Ruším"
msgid "Cannot connect to Moonraker"
msgstr "Nelze se připojit k Moonraker"
msgid "Channel"
msgstr "Kanál"
msgid "Check ADXL Wiring"
msgstr "Zkontroluj zapojení ADXL"
msgid "Checking for updates, please wait..."
msgstr "Kontrola aktualizací, čekej ..."
msgid "Clear"
msgstr "Vymaž"
msgid "Close"
msgstr "Zavřít"
msgid "Complete"
msgstr "Hotovo"
msgid "Configuration"
msgstr "Konfigurace"
msgid "Confirm Emergency Stop"
msgstr "Potvrzovat Emergency Stop"
msgid "Connected"
msgstr "Připojeno"
#, python-format
msgid "Connecting to %s"
msgstr "Připojování k %s"
msgid "Console"
msgstr "Konsole"
msgid "Continue"
msgstr "Pokračuj"
msgid "Cooldown"
msgstr "Zchladit"
msgid "Date"
msgstr "Datum"
msgid "Delete Directory?"
msgstr ""
msgid "Delete File?"
msgstr "Smazat soubor?"
msgid "Deselect"
msgstr "Odznačit"
msgid "Disable Motors"
msgstr "Uvolnit motory"
msgid "Disable XY"
msgstr "Uvolnit XY"
msgid "Distance (mm)"
msgstr "Vzdálenost (mm)"
#, python-format
msgid "Do you want to recover %s?"
msgstr "Obnovit %s?"
msgid "Elapsed:"
msgstr "Uplynulo:"
msgid "Error"
msgstr "Chyba"
msgid "Estimated Time Method"
msgstr "Výpočet doby tisku"
msgid "Exclude Object"
msgstr "Vyloučit objekt"
msgid "Extra Large"
msgstr "Extra velký"
msgid "Extrude"
msgstr "Extruze"
msgid "Extrusion +"
msgstr "Extruze +"
msgid "Extrusion -"
msgstr "Extruze -"
msgid "Failed, adjust position first"
msgstr "Chyba, nastav nejprve pozici"
msgid "Fan"
msgstr "Větrák"
msgid "Filament Used"
msgstr "Typ filamentu"
msgid "Filament total:"
msgstr "Filament celkem:"
msgid "Filament used:"
msgstr "Použitý filament:"
msgid "Filament:"
msgstr "Filament:"
msgid "File"
msgstr "Soubor"
msgid "File:"
msgstr "Soubor:"
msgid "Finding ADXL"
msgstr "Hledání ADXL"
msgid "Fine Tuning"
msgstr "Ladění"
msgid "Finish"
msgstr "Konec"
msgid "Firmware Restart"
msgstr "Firmware Restart"
msgid "Flow:"
msgstr "Tok:"
msgid "Flowrate:"
msgstr "Rychlost toku:"
msgid "Font Size"
msgstr "Velikost fontu"
msgid "Full Update"
msgstr "Úplný update"
msgid "Fullscreen"
msgstr ""
msgid "Go Back"
msgstr "Zpět"
msgid "Height:"
msgstr "Výška:"
msgid "Hidden"
msgstr "Skrytý"
msgid "Hide"
msgstr "Skrýt"
msgid "Hide sensors in Temp."
msgstr "Skrýt senzory v Temp."
msgid "Hide temp."
msgstr "Skrýt teplotu"
msgid "Home All"
msgstr "Zaparkovat XYZ"
msgid "Home X"
msgstr "Zaparkovat X"
msgid "Home XY"
msgstr "Zaparkovat XY"
msgid "Home Y"
msgstr "Zaparkovat Y"
msgid "Home Z"
msgstr "Zaparkovat Z"
msgid "Homing"
msgstr "Domů"
msgid "Host"
msgstr "Host"
msgid "Hostname"
msgstr "Hostname"
msgid "Icon Theme"
msgstr "Sada ikon"
msgid "Initializing printer..."
msgstr "Startuji tiskárnu ..."
msgid "Input Shaper"
msgstr ""
msgid "Interface"
msgstr "Rozhraní"
msgid "Invalid"
msgstr "Špatně"
msgid "Invalid password"
msgstr "Špatné heslo"
msgid "Invert X"
msgstr "Otočit X"
msgid "Invert Y"
msgstr "Otočit Y"
msgid "Invert Z"
msgstr "Otočit Z"
msgid "Klipper Restart"
msgstr "Klipper Restart"
msgid "Klipper has disconnected"
msgstr "Klipper odpojen"
msgid "Klipper has encountered an error."
msgstr "Klipper zaznamenal chybu."
msgid "Klipper has shutdown"
msgstr "Klipper zastaven"
msgid "Klipper is attempting to start"
msgstr "Klipper startuje"
msgid "Klipper will reboot"
msgstr "Klipper se restartuje"
msgid "KlipperScreen will reboot"
msgstr "KlipperScreen se restartuje"
msgid "Language"
msgstr "Jazyk"
msgid "Large"
msgstr "Velký"
msgid "Layer:"
msgstr "Vrstva:"
msgid "Left:"
msgstr "Zbývá:"
msgid "Limits"
msgstr "Limity"
msgid "Load"
msgstr "Zasuň"
msgid "Lower Nozzle"
msgstr "Trysku níž"
msgid "Macro shortcut on sidebar"
msgstr "Macro shortcut on sidebar"
msgid "Macros"
msgstr "Makra"
msgid "Main Menu"
msgstr "Hlavní menu"
msgid "Max"
msgstr "Max"
msgid "Max Acceleration"
msgstr "Max. zrychlení"
msgid "Max Acceleration to Deceleration"
msgstr "Z max. zrychlení do zpomalení"
msgid "Max Velocity"
msgstr "Max. rychlost"
msgid "Maximum"
msgstr "Maximum"
msgid "Measure Both"
msgstr "Změřit oboje"
msgid "Measure X"
msgstr "Změřit X"
msgid "Measure Y"
msgstr "Změřit Y"
msgid "Medium"
msgstr "Střední"
msgid "Menu"
msgstr "Menu"
msgid "Mesh calibrate"
msgstr "Kalibrace sítě"
msgid "Modified"
msgstr "Změněno"
msgid "Moonraker: connected"
msgstr "Moonraker: připojen"
msgid "Move"
msgstr "Posun"
msgid "Move Distance (mm)"
msgstr "Vzdálenost posunu (mm)"
msgid "Name"
msgstr "Jméno"
msgid "Network"
msgstr "Síť"
msgid "Never"
msgstr "Nikdy"
msgid "New"
msgstr "Nový"
msgid ""
"Not supported for auto-detection, it needs to be configured in klipperscreen."
"conf"
msgstr "Nepodporováno autodetekcí, nakonfiguruj v klipperscreen.conf"
msgid "Nothing selected"
msgstr "Nevybráno nic"
#, python-format
msgid "Outdated by %d"
msgstr "Zastaralý %d"
msgid "PSK for"
msgstr "PSK pro"
msgid "Package will be updated"
msgid_plural "Packages will be updated"
msgstr[0] "Balíček bude aktualizován"
msgstr[1] "Balíčky budou aktualizovány"
msgstr[2] ""
msgid "Part Fan"
msgstr "Částečný ofuk"
msgid "Password saved"
msgstr "Heslo uloženo"
msgid "Pause"
msgstr "Pauza"
msgid "Paused"
msgstr "Pozastaveno"
msgid "Perform a full upgrade?"
msgstr "Úplně aktualizovat?"
msgid "Pins"
msgstr "Piny"
msgid "Please recompile and flash the micro-controller."
msgstr "Znovu přelož a flashni micro-controller."
msgid "Power"
msgstr "Zdroj"
msgid "Power On Printer"
msgstr "Zapni tiskárnu"
msgid "Pressure Advance:"
msgstr "Pressure Advance:"
msgid "Print"
msgstr "Tisk"
msgid "Print Control"
msgstr "Nastavení tisku"
msgid "Print Time"
msgstr "Čas tisku"
msgid "Printer"
msgstr "Tiskárna"
msgid "Printer Connections"
msgstr "Připojení"
msgid "Printer Select"
msgstr "Výběr tiskárny"
msgid "Printing"
msgstr "Probíhá tisk"
msgid "Probe Offset"
msgstr "Offset sondy"
msgid "Profile Name:"
msgstr "Jméno profilu:"
msgid "Provide KlipperScreen.log when asking for help.\n"
msgstr "Provide KlipperScreen.log when asking for help.\n"
msgid "Quad Gantry Level"
msgstr "Quad Gantry Level"
msgid "Raise Nozzle"
msgstr "Zvedni trysku"
msgid "Recover"
msgstr "Recover"
msgid "Recover Hard"
msgstr "Recover Hard"
msgid "Recover Soft"
msgstr "Recover Soft"
msgid "Reference"
msgstr "Reference"
msgid "Refresh"
msgstr "Obnovit"
msgid "Rename/Move:"
msgstr ""
msgid "Restart"
msgstr "Restart"
msgid "Resume"
msgstr "Pokračuj"
msgid "Retract"
msgstr "Retrakce"
msgid "Retraction"
msgstr "Retrakce"
msgid "Retraction Length"
msgstr "Délka retrakce"
msgid "Retraction Speed"
msgstr "Rychlost retrakce"
msgid "Retry"
msgstr "Znovu"
msgid "Retrying"
msgstr "Zkouším znovu"
msgid "Save"
msgstr "Uložit"
msgid "Save Config"
msgstr "Ulož nastavení"
msgid "Save Z"
msgstr "Uložit Z"
msgid "Save configuration?"
msgstr "Uložit nastavení?"
msgid "Saved"
msgstr "Uloženo"
#, python-format
msgid "Saved offset: %s"
msgstr "Uložený offset: %s"
msgid "Screen DPMS"
msgstr "Screen DPMS"
msgid "Screen Power Off Time"
msgstr "Čas vypnutí displeje"
msgid "Screws Adjust"
msgstr "Nastavit šrouby"
msgid "Select"
msgstr "Vyber"
msgid "Send"
msgstr "Odeslat"
msgid "Set Temp"
msgstr "Nastav teplotu"
msgid "Settings"
msgstr "Nastavení"
msgid "Show"
msgstr "Ukaž"
msgid "Show Heater Power"
msgstr "Ukaž odběr topení"
msgid "Shutdown"
msgstr "Shutdown"
msgid "Size"
msgstr "Velikost"
msgid "Slicer"
msgstr "Slicer"
msgid "Slicer Time correction (%)"
msgstr "Časová korekce Sliceru (%)"
msgid "Slicer:"
msgstr "Slicer:"
msgid "Small"
msgstr "Malý"
msgid "Speed (mm/s)"
msgstr "Rychlost (mm/s)"
msgid "Speed +"
msgstr "Rychlost ₊"
msgid "Speed -"
msgstr "Rychlost -"
msgid "Speed:"
msgstr "Rychlost:"
msgid "Square Corner Velocity"
msgstr ""
msgid "Start"
msgstr "Start"
msgid "Starting WiFi Association"
msgstr "Připojování k WiFi"
msgid "Starting recovery for"
msgstr "Obnovuji"
msgid "Starting update for"
msgstr "Aktualizuji"
msgid "System"
msgstr "Systém"
msgid "System Restart"
msgstr "Restart systému"
msgid "System Shutdown"
msgstr "Vypnutí"
msgid "Temp (°C)"
msgstr "Teplota (°C)"
msgid "Temperature"
msgstr "Teplota"
msgid "Total:"
msgstr "Total:"
msgid "Unknown Heater"
msgstr "Neznámé topení"
msgid "Unknown screw position"
msgstr "Neznámé nastavení šroubů"
msgid "Unload"
msgstr "Vysuň"
msgid "Unretract Extra Length"
msgstr "Vysuň extra délku"
msgid "Unretract Speed"
msgstr "Vysunovací rychlost"
msgid "Up To Date"
msgstr "Aktuální"
msgid "Update"
msgstr "Aktualizuj"
msgid "Updating"
msgstr "Aktualizuji"
msgid "Uploaded"
msgstr "Nahrané"
msgid "XY Move Speed (mm/s)"
msgstr "Rychlost pohybu XY (mm/s)"
msgid "XY Speed (mm/s)"
msgstr "Rychlost XY (mm/s)"
msgid "Z Calibrate"
msgstr "Kalibrace Z"
msgid "Z Move Speed (mm/s)"
msgstr "Rychlost pohybu Z (mm/s)"
msgid "Z Speed (mm/s)"
msgstr "Rychlost pohybu Z (mm/s)"
msgid "Z Tilt"
msgstr "Z Tilt"
msgid "Z offset:"
msgstr "Z offset:"
msgid "commit"
msgid_plural "commits"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgid "dBm"
msgstr "dBm"
msgid "hour"
msgid_plural "hours"
msgstr[0] "hodina"
msgstr[1] "hodiny"
msgstr[2] "hodin"
msgid "minutes"
msgstr "min"
msgid "mm"
msgstr "mm"
msgid "mm/s"
msgstr "mm/s"
msgid "mm/s²"
msgstr "mm/s²"
msgid "mm³/s"
msgstr "mm³/s"
#~ msgid "Decrease"
#~ msgstr "Snížit"
#~ msgid "Increase"
#~ msgstr "Zvětšit"
#, python-format
#~ msgid "Sending Power ON signal to: %s"
#~ msgstr "Odeslat ZAP do %s"
@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: KlipperScreen\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-30 18:17-0300\n"
"POT-Creation-Date: 2022-12-13 20:39-0300\n"
"PO-Revision-Date: \n"
"Last-Translator: AntoszHUN\n"
"Language-Team: \n"
@@ -202,7 +202,7 @@ msgid "Exclude Object"
msgstr "Objektum kizárása"
msgid "Extra Large"
msgstr ""
msgstr "Extra nagy"
msgid "Extrude"
msgstr "Száladagolás"
@@ -322,7 +322,7 @@ msgid "Invalid"
msgstr "Érvénytelen"
msgid "Invalid password"
msgstr ""
msgstr "Érvénytelen jelszó"
msgid "Invert X"
msgstr "Fordított X"
@@ -397,7 +397,7 @@ msgid "Max Velocity"
msgstr "Max sebesség"
msgid "Maximum"
msgstr ""
msgstr "Maximum"
msgid "Measure Both"
msgstr "Mindkettő mérése"
@@ -415,7 +415,7 @@ msgid "Menu"
msgstr "Menü"
msgid "Mesh calibrate"
msgstr ""
msgstr "Háló kalibrálása"
msgid "Modified"
msgstr "Módosított"
@@ -436,7 +436,7 @@ msgid "Network"
msgstr "Hálózat"
msgid "Never"
msgstr ""
msgstr "Soha"
msgid "New"
msgstr "Új"
@@ -521,7 +521,7 @@ msgid "Profile Name:"
msgstr "Profil név:"
msgid "Provide KlipperScreen.log when asking for help.\n"
msgstr ""
msgstr "Add meg a KlipperScreen.log-ot, amikor segítséget kérsz.\n"
msgid "Quad Gantry Level"
msgstr "Négy állású szint"
@@ -563,7 +563,7 @@ msgid "Retraction Speed"
msgstr "Visszahúzási sebesség"
msgid "Retry"
msgstr ""
msgstr "Újra"
msgid "Retrying"
msgstr "Újrapróbálkozás"
Binary file not shown.
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: KlipperScreen\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-30 18:17-0300\n"
"POT-Creation-Date: 2023-01-29 09:28-0600\n"
"PO-Revision-Date: 2022-11-30 18:15-0300\n"
"Last-Translator: Jakob Kais <schpuntik@freenet.de>\n"
"Language-Team: \n"
@@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 3.2.1\n"
"X-Poedit-Flags-xgettext: --add-comments\n"
@@ -112,6 +112,9 @@ msgstr "Откалибровано, сохраните конфигурацию,
msgid "Calibrating"
msgstr "Калибровка"
msgid "Camera"
msgstr ""
msgid "Can't set above the maximum:"
msgstr "Невозможно установить выше максимума:"
@@ -173,8 +176,8 @@ msgstr "Остудить"
msgid "Date"
msgstr "Дата"
msgid "Decrease"
msgstr "Уменьшить"
msgid "Delete Directory?"
msgstr ""
msgid "Delete File?"
msgstr "Удалить Файл?"
@@ -267,6 +270,9 @@ msgstr "Размер шрифта"
msgid "Full Update"
msgstr "Полный Обновлять"
msgid "Fullscreen"
msgstr ""
msgid "Go Back"
msgstr "Назад"
@@ -312,9 +318,6 @@ msgstr "Имя хоста"
msgid "Icon Theme"
msgstr "Темы"
msgid "Increase"
msgstr "Поднять"
msgid "Initializing printer..."
msgstr "Принтер стартует..."
@@ -551,6 +554,9 @@ msgstr "Ссылка"
msgid "Refresh"
msgstr "Обновить"
msgid "Rename/Move:"
msgstr ""
msgid "Restart"
msgstr "Перезагрузка"
@@ -609,10 +615,6 @@ msgstr "Выбирать"
msgid "Send"
msgstr "Отправить"
#, python-format
msgid "Sending Power ON signal to: %s"
msgstr "Отправка сигнала включения питания на: %s"
msgid "Set Temp"
msgstr "Заданная температура"
@@ -623,7 +625,7 @@ msgid "Show"
msgstr "Показывать"
msgid "Show Heater Power"
msgstr "Показать мощьность нагрева"
msgstr "Показать мощность нагрева"
msgid "Shutdown"
msgstr "Выключить"
@@ -766,6 +768,16 @@ msgstr "мм/с²"
msgid "mm³/s"
msgstr "мм/с³"
#~ msgid "Decrease"
#~ msgstr "Уменьшить"
#~ msgid "Increase"
#~ msgstr "Поднять"
#, python-format
#~ msgid "Sending Power ON signal to: %s"
#~ msgstr "Отправка сигнала включения питания на: %s"
#~ msgid "Sort:"
#~ msgstr "Сортировать:"
Binary file not shown.
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-30 18:17-0300\n"
"PO-Revision-Date: 2022-11-30 18:15-0300\n"
"PO-Revision-Date: 2022-12-10 14:52+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: tr\n"
@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.2.1\n"
"X-Generator: Poedit 3.2\n"
#, python-format
msgid "%s will be updated to version"
@@ -327,7 +327,7 @@ msgid "Invalid"
msgstr "Geçersiz"
msgid "Invalid password"
msgstr ""
msgstr "Geçersiz şifre"
msgid "Invert X"
msgstr "X Ters çevir"
@@ -526,7 +526,7 @@ msgid "Profile Name:"
msgstr "Profil ismi:"
msgid "Provide KlipperScreen.log when asking for help.\n"
msgstr ""
msgstr "Yardım isterken KlipperScreen.log dosyasını sağlayın.\n"
msgid "Quad Gantry Level"
msgstr "Dörtlü Köprü Seviyesi"
Binary file not shown.
@@ -8,16 +8,16 @@ msgstr ""
"Project-Id-Version: 2022-09-04 14:53-0300\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-30 18:17-0300\n"
"PO-Revision-Date: 2022-11-30 18:16-0300\n"
"PO-Revision-Date: 2023-03-10 20:26-0600\n"
"Last-Translator: Andrii Komarovskyi\n"
"Language-Team: Andrii Komarovskyi\n"
"Language: uk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 3.2.1\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 2.4.2\n"
#, python-format
msgid "%s will be updated to version"
@@ -62,7 +62,7 @@ msgid "Apply %s%.2f offset to Probe?"
msgstr "Застосувати зміщення %s%.2f до зонда?"
msgid "Are you sure do you want to exclude the object?"
msgstr ""
msgstr "Ви впевнені, що бажаєте виключити об’єкт?"
msgid "Are you sure you want to run Emergency Stop?"
msgstr "Ви впевнені, що хочете зробити аварійну зупинку?"
@@ -208,7 +208,7 @@ msgid "Exclude Object"
msgstr "Виключити об’єкт"
msgid "Extra Large"
msgstr ""
msgstr "Дуже Великий"
msgid "Extrude"
msgstr ""
@@ -332,7 +332,7 @@ msgid "Invalid"
msgstr "Недійсний"
msgid "Invalid password"
msgstr ""
msgstr "Недійсний пароль"
msgid "Invert X"
msgstr "Інвертувати X"
@@ -409,7 +409,7 @@ msgid "Max Velocity"
msgstr "Макс. швидкість"
msgid "Maximum"
msgstr ""
msgstr "Максимум"
msgid "Measure Both"
msgstr "Виміряти все"
@@ -427,7 +427,7 @@ msgid "Menu"
msgstr "Меню"
msgid "Mesh calibrate"
msgstr ""
msgstr "Калібрування сітки столу"
msgid "Modified"
msgstr "Змінено"
@@ -445,10 +445,10 @@ msgid "Name"
msgstr "Ім'я"
msgid "Network"
msgstr "Сітка"
msgstr "Мережа"
msgid "Never"
msgstr ""
msgstr "Ніколи"
msgid "New"
msgstr "Новий"
@@ -518,13 +518,13 @@ msgid "Print Time"
msgstr "Час друку"
msgid "Printer"
msgstr ""
msgstr "Принтер"
msgid "Printer Connections"
msgstr "Підключення принтера"
msgid "Printer Select"
msgstr ""
msgstr "Вибір Принтера"
msgid "Printing"
msgstr "Друк"
@@ -536,7 +536,7 @@ msgid "Profile Name:"
msgstr "Ім'я профілю:"
msgid "Provide KlipperScreen.log when asking for help.\n"
msgstr ""
msgstr "Надайте KlipperScreen.log, коли звертаєтесь по допомогу.\n"
msgid "Quad Gantry Level"
msgstr "Портальне вирівнювання"
@@ -557,7 +557,9 @@ msgid "Reference"
msgstr "Довідка"
msgid "Refresh"
msgstr "Оновити"
msgstr ""
"Перевірка\n"
"Оновлень"
msgid "Restart"
msgstr "Перезапуск"
@@ -580,7 +582,7 @@ msgid "Retraction Speed"
msgstr "Швидкість втягування"
msgid "Retry"
msgstr ""
msgstr "Повторіть спробу"
msgid "Retrying"
msgstr "Повторна спроба"
@@ -633,10 +635,10 @@ msgid "Show"
msgstr "Показати"
msgid "Show Heater Power"
msgstr ""
msgstr "Показати Потужність Нагрівача"
msgid "Shutdown"
msgstr "вимкнувся"
msgstr "Вимкнути"
msgid "Size"
msgstr "Розмір"
@@ -714,7 +716,7 @@ msgid "Unretract Speed"
msgstr "Швидкість повернення"
msgid "Up To Date"
msgstr "Оновити"
msgstr "Актуально"
msgid "Update"
msgstr "Оновлення"
+20 -27
View File
@@ -7,12 +7,12 @@ from gi.repository import GLib
class Printer:
def __init__(self, state_cb):
self.config = None
self.data = None
def __init__(self, state_cb, state_callbacks, busy_cb):
self.config = {}
self.data = {}
self.state = "disconnected"
self.state_cb = state_cb
self.state_callbacks = None
self.state_callbacks = state_callbacks
self.devices = {}
self.power_devices = {}
self.tools = []
@@ -22,28 +22,9 @@ class Printer:
self.output_pin_count = 0
self.store_timeout = None
self.tempstore = {}
self.busy_cb = None
self.busy = None
self.temperature_store_size = None
def reset(self):
self.config = None
self.data = None
self.state = None
self.state_cb = None
self.state_callbacks = None
self.devices = None
self.power_devices = None
self.tools = None
self.extrudercount = None
self.tempdevcount = None
self.fancount = None
self.output_pin_count = None
self.store_timeout = None
self.tempstore = None
self.busy_cb = None
self.busy = None
self.temperature_store_size = None
self.busy_cb = busy_cb
self.busy = False
self.tempstore_size = 1200
def reinit(self, printer_info, data):
self.config = data['configfile']['config']
@@ -101,6 +82,8 @@ class Printer:
logging.info(f"# Output pins: {self.output_pin_count}")
def process_update(self, data):
if self.data is None:
return
for x in (self.get_tools() + self.get_heaters() + self.get_filament_sensors()):
if x in data:
for i in data[x]:
@@ -172,6 +155,16 @@ class Printer:
def get_config_section(self, section):
return self.config[section] if section in self.config else False
def get_macro(self, macro):
return next(
(
self.config[key]
for key in self.config.keys()
if key.find(macro) > -1
),
False,
)
def get_fans(self):
fans = []
if self.config_section_exists("fan"):
@@ -316,7 +309,7 @@ class Printer:
return True
def init_temp_store(self, tempstore):
if 'result' in tempstore:
if tempstore and 'result' in tempstore:
if self.tempstore and list(self.tempstore) != list(tempstore['result']):
logging.debug("Tempstore has changed")
self.tempstore = tempstore['result']
+2 -7
View File
@@ -26,8 +26,6 @@ class ScreenPanel:
self.title = title
self.devices = {}
self.active_heaters = []
self.layout = Gtk.Layout()
self.layout.set_size(screen.width, screen.height)
self.content = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.content.get_style_context().add_class("content")
self.content.set_hexpand(True)
@@ -51,11 +49,11 @@ class ScreenPanel:
def get_file_image(self, filename, width=None, height=None, small=False):
if not self._files.has_thumbnail(filename):
return None
width = width if width is not None else self._gtk.img_width
height = height if height is not None else self._gtk.img_height
loc = self._files.get_thumbnail_location(filename, small)
if loc is None:
return None
width = width if width is not None else self._gtk.img_width
height = height if height is not None else self._gtk.img_height
if loc[0] == "file":
return self._gtk.PixbufFromFile(loc[1], width, height)
if loc[0] == "http":
@@ -65,9 +63,6 @@ class ScreenPanel:
def menu_item_clicked(self, widget, panel, item):
self._screen.show_panel(panel, item['panel'], item['name'], 1, False)
def show_all(self):
self._screen.show_all()
def load_menu(self, widget, name, title=None):
if f"{name}_menu" not in self.labels:
return
File renamed without changes.
+47 -14
View File
@@ -8,7 +8,7 @@ from gi.repository import Gtk, GLib
class Keyboard(Gtk.Box):
langs = ["de", "en", "es"]
langs = ["de", "en", "fr", "es"]
def __init__(self, screen, close_cb, entry=None):
super().__init__(orientation=Gtk.Orientation.VERTICAL)
@@ -26,42 +26,73 @@ class Keyboard(Gtk.Box):
[
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü", "⌫"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
["ABC", "y", "x", "c", "v", "b", "n", "m", ",", ".", "?123"],
["ABC", "123", "#+=", "y", "x", "c", "v", "b", "n", "m"],
],
[
["Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", "Ü", "⌫"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", "Ö", "Ä"],
["?123", "Y", "X", "C", "V", "B", "N", "M", ",", ".", "abc"],
["abc", "123", "#+=", "Y", "X", "C", "V", "B", "N", "M"],
],
[
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "ß", "⌫"],
["=", "-", "+", "*", "/", "\\", ":", ";", "'", "\"", "ẞ"],
["abc", "(", ")", "#", "$", "!", "?", "@", "_", ",", "ABC"],
["-", "/", ":", ";", "(", ")", "$", "&", "@", "\"", "ẞ"],
["ABC", "abc", "#+=", ".", ",", "?", "!", "'"],
],
[
["[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "⌫"],
["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"],
["ABC", "abc", "123", ".", ",", "?", "!", "'"],
]
]
elif language == "fr":
self.keys = [
[
["a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "⌫"],
["q", "s", "d", "f", "g", "h", "j", "k", "l", "m"],
["ABC", "123", "#+=", "w", "x", "c", "v", "b", "n"],
],
[
["A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "⌫"],
["Q", "S", "D", "F", "G", "H", "J", "K", "L", "M"],
["abc", "123", "#+=", "W", "X", "C", "V", "B", "N"],
],
[
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "⌫"],
["-", "/", ":", ";", "(", ")", "$", "&", "@", "\""],
["ABC", "abc", "#+=", ".", ",", "?", "!", "'"],
],
[
["[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "⌫"],
["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"],
["ABC", "abc", "123", ".", ",", "?", "!", "'"],
]
]
else:
self.keys = [
[
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "⌫"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "'"],
["ABC", "z", "x", "c", "v", "b", "n", "m", ",", ".", "?123"],
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
["ABC", "123", "#+=", "z", "x", "c", "v", "b", "n", "m"],
],
[
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "⌫"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", "'"],
["?123", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "abc"],
["A", "S", "D", "F", "G", "H", "J", "K", "L"],
["abc", "123", "#+=", "Z", "X", "C", "V", "B", "N", "M"],
],
[
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "⌫"],
["=", "-", "+", "*", "/", "\\", ":", ";", "'", "\""],
["abc", "(", ")", "#", "$", "!", "?", "@", "_", ",", "ABC"],
["-", "/", ":", ";", "(", ")", "$", "&", "@", "\""],
["ABC", "abc", "#+=", ".", ",", "?", "!", "'"],
],
[
["[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "⌫"],
["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"],
["ABC", "abc", "123", ".", ",", "?", "!", "'"],
]
]
if language == "es":
self.keys[0][1].remove("'")
self.keys[0][1].append("ñ")
self.keys[1][1].remove("'")
self.keys[1][1].append("Ñ")
for pallet in self.keys:
@@ -152,7 +183,9 @@ class Keyboard(Gtk.Box):
self.set_pallet(0)
elif key == "ABC":
self.set_pallet(1)
elif key == "?123":
elif key == "123":
self.set_pallet(2)
elif key == "#+=":
self.set_pallet(3)
else:
Gtk.Entry.do_insert_at_cursor(self.entry, key)
+1 -1
View File
@@ -110,7 +110,7 @@ class WifiManager:
logging.info(f"Attempting to connect to wifi: {netid}")
self.callback("connecting_status", f"Attempting to connect to {ssid}")
self.wpa_cli(f"SELECT_NETWORK {id}")
self.wpa_cli(f"SELECT_NETWORK {netid}")
self.save_wpa_conf()
def delete_network(self, ssid):
+1 -1
View File
@@ -5,7 +5,7 @@ import contextlib
import logging
import uuid
import NetworkManager
from ks_includes import NetworkManager
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gi
+13 -19
View File
@@ -59,9 +59,8 @@ class BasePanel(ScreenPanel):
else:
self.action_bar.set_hexpand(False)
self.action_bar.set_vexpand(True)
self.action_bar.set_size_request(self._gtk.get_action_bar_width(), self._gtk.get_action_bar_height())
self.action_bar.get_style_context().add_class('action_bar')
self.action_bar.set_size_request(self._gtk.action_bar_width, self._gtk.action_bar_height)
self.action_bar.add(self.control['back'])
self.action_bar.add(self.control['home'])
self.show_back(False)
@@ -88,7 +87,7 @@ class BasePanel(ScreenPanel):
self.control['time_box'].pack_end(self.control['time'], True, True, 10)
self.titlebar = Gtk.Box(spacing=5)
self.titlebar.set_size_request(self._gtk.get_content_width(), self._gtk.get_titlebar_height())
self.titlebar.get_style_context().add_class("title_bar")
self.titlebar.set_valign(Gtk.Align.CENTER)
self.titlebar.add(self.control['temp_box'])
self.titlebar.add(self.titlelbl)
@@ -96,9 +95,6 @@ class BasePanel(ScreenPanel):
# Main layout
self.main_grid = Gtk.Grid()
# To achieve rezisability this needs to be removed
# The main issue is that currently the content doesn't expand correctly
self.main_grid.set_size_request(self._screen.width, self._screen.height)
if self._screen.vertical_mode:
self.main_grid.attach(self.titlebar, 0, 0, 1, 1)
@@ -111,19 +107,17 @@ class BasePanel(ScreenPanel):
self.main_grid.attach(self.titlebar, 1, 0, 1, 1)
self.main_grid.attach(self.content, 1, 1, 1, 1)
# Layout is and content are on screen_panel
self.layout.add(self.main_grid)
self.update_time()
def show_heaters(self, show=True):
try:
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._printer.get_temp_store_devices() is None:
return
img_size = self._gtk.img_scale * self.bts
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
self.labels[device] = Gtk.Label(label="100º")
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
@@ -137,18 +131,18 @@ class BasePanel(ScreenPanel):
nlimit = int(round(log(self._screen.width, 10) * 5 - 10.5))
n = 0
if self._screen.printer.get_tools():
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
if self._printer.get_tools():
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
if self.current_extruder and f"{self.current_extruder}_box" in self.labels:
self.control['temp_box'].add(self.labels[f"{self.current_extruder}_box"])
n += 1
if self._screen.printer.has_heated_bed():
if self._printer.has_heated_bed():
self.control['temp_box'].add(self.labels['heater_bed_box'])
n += 1
# Options in the config have priority
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
# Users can fill the bar if they want
if n >= nlimit + 1:
break
@@ -160,7 +154,7 @@ class BasePanel(ScreenPanel):
break
# If there is enough space fill with heater_generic
for device in self._screen.printer.get_temp_store_devices():
for device in self._printer.get_temp_store_devices():
if n >= nlimit:
break
if device.startswith("heater_generic"):
@@ -172,7 +166,7 @@ class BasePanel(ScreenPanel):
def get_icon(self, device, img_size):
if device.startswith("extruder"):
if self._screen.printer.extrudercount > 1:
if self._printer.extrudercount > 1:
if device == "extruder":
device = "extruder0"
return self._gtk.Image(f"extruder-{device[8:]}", img_size, img_size)
@@ -233,10 +227,10 @@ class BasePanel(ScreenPanel):
if action != "notify_status_update" or self._screen.printer is None:
return
devices = self._screen.printer.get_temp_store_devices()
devices = self._printer.get_temp_store_devices()
if devices is not None:
for device in devices:
temp = self._screen.printer.get_dev_stat(device, "temperature")
temp = self._printer.get_dev_stat(device, "temperature")
if temp is not None and device in self.labels:
name = ""
if not (device.startswith("extruder") or device.startswith("heater_bed")):
@@ -248,7 +242,7 @@ class BasePanel(ScreenPanel):
name = f"{name[:1].upper()}: "
self.labels[device].set_label(f"{name}{int(temp)}°")
with contextlib.suppress(KeyError):
with contextlib.suppress(Exception):
if data["toolhead"]["extruder"] != self.current_extruder:
self.control['temp_box'].remove(self.labels[f"{self.current_extruder}_box"])
self.current_extruder = data["toolhead"]["extruder"]
+121 -76
View File
@@ -1,5 +1,6 @@
import logging
import re
import math
import gi
@@ -14,6 +15,29 @@ def create_panel(*args):
return BedLevelPanel(*args)
# Find the screw closest to the point,
# but return None if the distance is above max_distance.
# If remove is set to true, the screw is also removed
# from the list of passed in screws.
def find_closest(screws, point, max_distance, remove=False):
if len(screws) == 0:
return None
closest = screws[0]
min_distance = math.hypot(closest[0] - point[0], closest[1] - point[1])
for screw in screws[1:]:
distance = math.hypot(screw[0] - point[0], screw[1] - point[1])
if distance < min_distance:
closest = screw
min_distance = distance
if min_distance > max_distance:
return None
if remove:
screws.remove(closest)
return closest
class BedLevelPanel(ScreenPanel):
def __init__(self, screen, title):
@@ -33,7 +57,7 @@ class BedLevelPanel(ScreenPanel):
grid = self._gtk.HomogeneousGrid()
grid.attach(self.buttons['dm'], 0, 0, 1, 1)
if "screws_tilt_adjust" in self._screen.printer.get_config_section_list():
if "screws_tilt_adjust" in self._printer.get_config_section_list():
self.buttons['screws'] = self._gtk.Button("refresh", _("Screws Adjust"), "color4")
self.buttons['screws'].connect("clicked", self.screws_tilt_calculate)
grid.attach(self.buttons['screws'], 0, 1, 1, 1)
@@ -41,7 +65,7 @@ class BedLevelPanel(ScreenPanel):
self.screws = self._get_screws("screws_tilt_adjust")
logging.info(f"screws_tilt_adjust: {self.screws}")
probe = self._screen.printer.get_probe()
probe = self._printer.get_probe()
if probe:
if "x_offset" in probe:
self.x_offset = round(float(probe['x_offset']), 1)
@@ -49,7 +73,8 @@ class BedLevelPanel(ScreenPanel):
self.y_offset = round(float(probe['y_offset']), 1)
logging.debug(f"offset X: {self.x_offset} Y: {self.y_offset}")
# bed_screws uses NOZZLE positions
# screws_tilt_adjust uses PROBE positions and to be offseted for the buttons to work equal to bed_screws
# screws_tilt_adjust uses PROBE positions and
# to be offseted for the buttons to work equal to bed_screws
new_screws = [
[round(screw[0] + self.x_offset, 1), round(screw[1] + self.y_offset, 1)]
for screw in self.screws
@@ -57,9 +82,38 @@ class BedLevelPanel(ScreenPanel):
self.screws = new_screws
logging.info(f"screws with offset: {self.screws}")
elif "bed_screws" in self._screen.printer.get_config_section_list():
elif "bed_screws" in self._printer.get_config_section_list():
self.screws = self._get_screws("bed_screws")
logging.info(f"bed_screws: {self.screws}")
nscrews = len(self.screws)
# KS config
valid_positions = True
valid_screws = ["bl", "fl", "fr", "br", "bm", "fm", "lm", "rm", "center"]
if self.ks_printer_cfg is not None:
screw_positions = self.ks_printer_cfg.get("screw_positions", "")
if screw_positions:
screw_positions = [str(i.strip()) for i in screw_positions.split(',')]
logging.info(f"Positions: {screw_positions}")
for screw in screw_positions:
if screw not in valid_screws:
logging.error(f"Unknown screw: {screw}")
self._screen.show_popup_message(_("Unknown screw position") + f": {screw}")
valid_positions = False
if not (3 <= len(screw_positions) <= 9):
valid_positions = False
else:
if nscrews in (3, 5, 7):
valid_positions = False
screw_positions = valid_screws
rotation = self.ks_printer_cfg.getint("screw_rotation", 0)
logging.info(f"Rotation: {rotation}")
else:
if nscrews in (3, 5, 7):
valid_positions = False
screw_positions = valid_screws
if 'bed_screws' in self._config.get_config():
rotation = self._config.get_config()['bed_screws'].getint("rotation", 0)
logging.debug(f"Rotation: {rotation}")
# get dimensions
x_positions = {x[0] for x in self.screws}
@@ -70,89 +124,73 @@ class BedLevelPanel(ScreenPanel):
min_x = min(x_positions)
max_x = max(x_positions)
mid_x = round((min_x + max_x) / 2)
min_y = min(y_positions)
max_y = max(y_positions)
mid_y = round((min_y + max_y) / 2)
fl = [min_x, min_y]
bl = [min_x, max_y]
br = [max_x, max_y]
fr = [max_x, min_y]
max_distance = math.ceil(
math.hypot(max_x - min_x, max_y - min_y)
/ min(self.x_cnt, self.y_cnt, 3)
)
if self.x_cnt == 3:
mid_x = [x for x in list(zip(*self.screws))[0] if x not in (min_x, max_x)][0]
fm = [mid_x, min_y]
bm = [mid_x, max_y]
else:
fm = bm = None
if self.y_cnt == 3:
mid_y = [y for y in list(zip(*self.screws))[1] if y not in (min_y, max_y)][0]
lm = [min_x, mid_y]
rm = [max_x, mid_y]
else:
lm = rm = None
logging.debug(f"Using max_distance: {max_distance} to fit: {len(self.screws)} screws.")
logging.debug(f"Using {len(self.screws)}-screw locations [x,y] [{self.x_cnt}x{self.y_cnt}]")
remaining_screws = self.screws[:]
self.buttons['bl'] = self._gtk.Button("bed-level-t-l", scale=2.5)
self.buttons['br'] = self._gtk.Button("bed-level-t-r", scale=2.5)
self.buttons['fl'] = self._gtk.Button("bed-level-b-l", scale=2.5)
self.buttons['fr'] = self._gtk.Button("bed-level-b-r", scale=2.5)
self.buttons['lm'] = self._gtk.Button("bed-level-l-m", scale=2.5)
self.buttons['rm'] = self._gtk.Button("bed-level-r-m", scale=2.5)
self.buttons['fm'] = self._gtk.Button("bed-level-b-m", scale=2.5)
self.buttons['bm'] = self._gtk.Button("bed-level-t-m", scale=2.5)
fl = find_closest(remaining_screws, (min_x, min_y), max_distance, remove="fl" in screw_positions)
bl = find_closest(remaining_screws, (min_x, max_y), max_distance, remove="bl" in screw_positions)
br = find_closest(remaining_screws, (max_x, max_y), max_distance, remove="br" in screw_positions)
fr = find_closest(remaining_screws, (max_x, min_y), max_distance, remove="fr" in screw_positions)
valid_positions = True
if self.ks_printer_cfg is not None:
screw_positions = self.ks_printer_cfg.get("screw_positions", "")
screw_positions = [str(i.strip()) for i in screw_positions.split(',')]
logging.info(f"Positions: {screw_positions}")
for screw in screw_positions:
if screw not in ("bl", "fl", "fr", "br", "bm", "fm", "lm", "rm", ""):
logging.error(f"Unknown screw: {screw}")
self._screen.show_popup_message(_("Unknown screw position") + f": {screw}")
valid_positions = False
if not (3 <= len(screw_positions) <= 8):
valid_positions = False
rotation = self.ks_printer_cfg.getint("screw_rotation", 0)
logging.info(f"Rotation: {rotation}")
else:
valid_positions = False
if 'bed_screws' in self._config.get_config():
rotation = self._config.get_config()['bed_screws'].getint("rotation", 0)
logging.debug(f"Rotation: {rotation}")
fm = find_closest(remaining_screws, (mid_x, min_y), max_distance, remove="fm" in screw_positions)
bm = find_closest(remaining_screws, (mid_x, max_y), max_distance, remove="bm" in screw_positions)
lm = find_closest(remaining_screws, (min_x, mid_y), max_distance, remove="lm" in screw_positions)
rm = find_closest(remaining_screws, (max_x, mid_y), max_distance, remove="rm" in screw_positions)
center = find_closest(remaining_screws, (mid_x, mid_y), max_distance, remove="center" in screw_positions)
if len(remaining_screws) != 0:
logging.debug(f"Screws not used: {remaining_screws}")
logging.debug(f"Using {len(self.screws) - len(remaining_screws)}/{len(self.screws)}-screw locations")
button_scale = 2
self.buttons['bl'] = self._gtk.Button("bed-level-t-l", scale=button_scale)
self.buttons['br'] = self._gtk.Button("bed-level-t-r", scale=button_scale)
self.buttons['fl'] = self._gtk.Button("bed-level-b-l", scale=button_scale)
self.buttons['fr'] = self._gtk.Button("bed-level-b-r", scale=button_scale)
self.buttons['lm'] = self._gtk.Button("bed-level-l-m", scale=button_scale)
self.buttons['rm'] = self._gtk.Button("bed-level-r-m", scale=button_scale)
self.buttons['fm'] = self._gtk.Button("bed-level-b-m", scale=button_scale)
self.buttons['bm'] = self._gtk.Button("bed-level-t-m", scale=button_scale)
self.buttons['center'] = self._gtk.Button("increase", scale=button_scale)
bedgrid = Gtk.Grid()
nscrews = len(self.screws)
if valid_positions:
if "bl" in screw_positions:
if "bl" in screw_positions and bl:
bedgrid.attach(self.buttons['bl'], 1, 0, 1, 1)
if "fl" in screw_positions:
if "fl" in screw_positions and fl:
bedgrid.attach(self.buttons['fl'], 1, 2, 1, 1)
if "fr" in screw_positions:
if "fr" in screw_positions and fr:
bedgrid.attach(self.buttons['fr'], 3, 2, 1, 1)
if "br" in screw_positions:
if "br" in screw_positions and br:
bedgrid.attach(self.buttons['br'], 3, 0, 1, 1)
if "bm" in screw_positions:
if "bm" in screw_positions and bm:
bedgrid.attach(self.buttons['bm'], 2, 0, 1, 1)
if "fm" in screw_positions:
if "fm" in screw_positions and fm:
bedgrid.attach(self.buttons['fm'], 2, 2, 1, 1)
if "lm" in screw_positions:
bedgrid.attach(self.buttons['lm'], 1, 1, 1, 1)
if "rm" in screw_positions:
bedgrid.attach(self.buttons['rm'], 3, 1, 1, 1)
elif nscrews in {4, 6, 8}:
bedgrid.attach(self.buttons['bl'], 1, 0, 1, 1)
bedgrid.attach(self.buttons['fl'], 1, 2, 1, 1)
bedgrid.attach(self.buttons['fr'], 3, 2, 1, 1)
bedgrid.attach(self.buttons['br'], 3, 0, 1, 1)
if self.x_cnt == 3:
bedgrid.attach(self.buttons['bm'], 2, 0, 1, 1)
bedgrid.attach(self.buttons['fm'], 2, 2, 1, 1)
if self.y_cnt == 3:
if "lm" in screw_positions and lm:
bedgrid.attach(self.buttons['lm'], 1, 1, 1, 1)
if "rm" in screw_positions and rm:
bedgrid.attach(self.buttons['rm'], 3, 1, 1, 1)
if "center" in screw_positions and center:
bedgrid.attach(self.buttons['center'], 2, 1, 1, 1)
self.buttons['center'].connect("clicked", self.go_to_position, center)
else:
label = Gtk.Label(
_("Bed screw configuration:") + f" {nscrews}\n\n"
@@ -253,7 +291,7 @@ class BedLevelPanel(ScreenPanel):
'fl': fl,
'lm': lm
}
self.screw_dict['center'] = center
grid.attach(bedgrid, 1, 0, 3, 2)
self.content.add(grid)
@@ -261,9 +299,16 @@ class BedLevelPanel(ScreenPanel):
for key, value in self.screw_dict.items():
self.buttons[key].set_label(f"{value}")
def go_to_position(self, widget, position):
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
def home(self):
# Test if all axes have been homed. Home if necessary.
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
# do Z_TILT_CALIBRATE if applicable.
if self._printer.config_section_exists("z_tilt"):
self._screen._ws.klippy.gcode_script(KlippyGcodes.Z_TILT)
def go_to_position(self, widget, position):
self.home()
logging.debug(f"Going to position: {position}")
script = [
f"{KlippyGcodes.MOVE_ABSOLUTE}",
@@ -284,8 +329,9 @@ class BedLevelPanel(ScreenPanel):
def process_busy(self, busy):
for button in self.buttons:
if button == "screws":
self.buttons[button].set_sensitive(self._printer.config_section_exists("screws_tilt_adjust")
and (not busy))
self.buttons[button].set_sensitive(
self._printer.config_section_exists("screws_tilt_adjust")
and (not busy))
continue
self.buttons[button].set_sensitive((not busy))
@@ -335,7 +381,7 @@ class BedLevelPanel(ScreenPanel):
def _get_screws(self, config_section_name):
screws = []
config_section = self._screen.printer.get_config_section(config_section_name)
config_section = self._printer.get_config_section(config_section_name)
for item in config_section:
logging.debug(f"{config_section_name}: {config_section[item]}")
result = re.match(r"([\-0-9\.]+)\s*,\s*([\-0-9\.]+)", config_section[item])
@@ -347,8 +393,7 @@ class BedLevelPanel(ScreenPanel):
return sorted(screws, key=lambda s: (float(s[1]), float(s[0])))
def screws_tilt_calculate(self, widget):
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self.home()
self.response_count = 0
self.buttons['screws'].set_sensitive(False)
self._screen._ws.klippy.gcode_script("SCREWS_TILT_CALCULATE")
+5 -5
View File
@@ -54,11 +54,11 @@ class BedMeshPanel(ScreenPanel):
grid = self._gtk.HomogeneousGrid()
grid.set_row_homogeneous(False)
grid.attach(topbar, 0, 0, 2, 1)
self.labels['map'] = BedMap(self._gtk.get_font_size(), self.active_mesh)
self.labels['map'] = BedMap(self._gtk.font_size, self.active_mesh)
if self._screen.vertical_mode:
grid.attach(self.labels['map'], 0, 2, 2, 1)
grid.attach(scroll, 0, 3, 2, 1)
self.labels['map'].set_size_request(self._gtk.get_content_width(), self._gtk.get_content_height() * .4)
self.labels['map'].set_size_request(self._gtk.content_width, self._gtk.content_height * .4)
else:
grid.attach(self.labels['map'], 0, 2, 1, 1)
grid.attach(scroll, 1, 2, 1, 1)
@@ -68,7 +68,7 @@ class BedMeshPanel(ScreenPanel):
def activate(self):
self.load_meshes()
with contextlib.suppress(KeyError):
self.activate_mesh(self._screen.printer.get_stat("bed_mesh", "profile_name"))
self.activate_mesh(self._printer.get_stat("bed_mesh", "profile_name"))
def activate_mesh(self, profile):
if self.active_mesh is not None:
@@ -268,13 +268,13 @@ class BedMeshPanel(ScreenPanel):
def calibrate_mesh(self, widget):
self._screen.show_popup_message(_("Calibrating"), level=1)
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self._screen._ws.klippy.gcode_script("BED_MESH_CALIBRATE")
# Load zcalibrate to do a manual mesh
if not self._screen.printer.get_probe():
if not self._printer.get_probe():
self.menu_item_clicked(widget, "refresh", {"name": _("Mesh calibrate"), "panel": "zcalibrate"})
def send_clear_mesh(self, widget):
+91
View File
@@ -0,0 +1,91 @@
import mpv
import logging
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk
from ks_includes.screen_panel import ScreenPanel
def create_panel(*args):
return CameraPanel(*args)
class CameraPanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
self.mpv = None
self.da = Gtk.DrawingArea()
self.da.set_hexpand(True)
self.da.set_vexpand(True)
fs = self._gtk.Button("move", _("Fullscreen"), None, self.bts, Gtk.PositionType.LEFT, 1)
fs.connect("clicked", self.play)
fs.set_hexpand(True)
fs.set_vexpand(False)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
box.add(self.da)
box.add(fs)
self.content.add(box)
self.content.show_all()
self.url = self.ks_printer_cfg.get("camera_url", "http://127.0.0.1/webcam/?action=stream").replace('"', '')
# wayland has no primary monitor with that we can detect it
self.wayland = Gdk.Display.get_default().get_primary_monitor() is None
# gpu output driver doesn't work on a pi3 and the autoselected sdl doesn't size correctly
# consider adding a software switch to enable the gpu backend if set by the user
self.vo = 'wlshm' if self.wayland else 'x11'
logging.debug(f"Camera URL: {self.url} vo: {self.vo} wayland: {self.wayland}")
def activate(self):
self.play()
def deactivate(self):
if self.mpv:
self.mpv.terminate()
self.mpv = None
def play(self, fs=None):
if self.mpv:
self.mpv.terminate()
self.mpv = None
# Create mpv after show or the 'window' property will be None
try:
self.mpv = mpv.MPV(
log_handler=self.log,
vo=self.vo,
profile='sw-fast',
)
except ValueError:
self.mpv = mpv.MPV(
log_handler=self.log,
vo=self.vo,
)
# On wayland mpv cannot be embedded at least for now
# https://github.com/mpv-player/mpv/issues/9654
# if fs or self.wayland:
self.mpv.fullscreen = True
@self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
def clicked():
self.mpv.quit(0)
# else:
# self.mpv.wid = f'{self.da.get_property("window").get_xid()}'
#
# @self.mpv.on_key_press('MBTN_LEFT' or 'MBTN_LEFT_DBL')
# def clicked():
# self._screen.show_popup_message(self.url, level=1)
self.mpv.play(self.url)
# if fs or self.wayland:
try:
self.mpv.wait_for_playback()
except mpv.ShutdownError:
logging.info('Exiting Fullscreen')
except Exception as e:
logging.exception(e)
self.mpv.terminate()
self.mpv = None
self._screen._menu_go_back()
@staticmethod
def log(loglevel, component, message):
logging.debug(f'[{loglevel}] {component}: {message}')
+4 -3
View File
@@ -43,18 +43,18 @@ class ExcludeObjectPanel(ScreenPanel):
grid.attach(Gtk.Separator(), 0, 1, 2, 1)
if self.objects and "polygon" in self.objects[0]:
self.labels['map'] = ObjectMap(self._screen, self._printer, self._gtk.get_font_size())
self.labels['map'] = ObjectMap(self._screen, self._printer, self._gtk.font_size)
if self._screen.vertical_mode:
grid.attach(self.labels['map'], 0, 2, 2, 1)
grid.attach(scroll, 0, 3, 2, 1)
scroll.set_size_request(self._gtk.get_content_width(), -1)
scroll.set_size_request(self._gtk.content_width, -1)
else:
grid.attach(self.labels['map'], 0, 2, 1, 1)
grid.attach(scroll, 1, 2, 1, 1)
scroll.set_size_request((self._screen.width * .9) // 2, -1)
else:
grid.attach(scroll, 0, 2, 2, 1)
scroll.set_size_request(self._gtk.get_content_width(), -1)
scroll.set_size_request(self._gtk.content_width, -1)
self.content.add(grid)
self.content.show_all()
@@ -102,6 +102,7 @@ class ExcludeObjectPanel(ScreenPanel):
for obj in self.objects:
logging.info(f"Adding {obj['name']}")
self.add_object(obj["name"])
self.content.show_all()
with contextlib.suppress(KeyError):
# Update current objects
if data["exclude_object"]["current_object"]:
+3 -3
View File
@@ -19,7 +19,7 @@ class ExtrudePanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
macros = self._screen.printer.get_gcode_macros()
macros = self._printer.get_gcode_macros()
self.load_filament = any("LOAD_FILAMENT" in macro.upper() for macro in macros)
self.unload_filament = any("UNLOAD_FILAMENT" in macro.upper() for macro in macros)
@@ -134,8 +134,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(Pango.EllipsizeMode.END)
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_property("width-request", round(self._gtk.font_size * 2))
self.labels[x]['switch'].set_property("height-request", round(self._gtk.font_size))
self.labels[x]['switch'].connect("notify::active", self.enable_disable_fs, name, x)
self.labels[x]['box'].pack_start(self.labels[x]['label'], True, True, 5)
self.labels[x]['box'].pack_start(self.labels[x]['switch'], False, False, 5)
+8 -3
View File
@@ -83,7 +83,12 @@ class MacroPanel(ScreenPanel):
"params": {},
}
pattern = r'params\.(?P<param>..*)\|default\((?P<default>..*)\).*'
gcode = self._printer.get_config_section(f"gcode_macro {macro}")["gcode"].split("\n")
gcode = self._printer.get_macro(macro)
if gcode and "gcode" in gcode:
gcode = gcode["gcode"].split("\n")
else:
logging.debug(f"Couldn't load {macro}\n{gcode}")
return
i = 0
for line in gcode:
if line.startswith("{") and "params." in line:
@@ -165,8 +170,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.font_size * 7))
switch.set_property("height-request", round(self._gtk.font_size * 3.5))
box.add(switch)
dev = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
+4 -10
View File
@@ -113,7 +113,7 @@ class InputShaperPanel(ScreenPanel):
def start_calibration(self, widget, method):
self.labels['popover'].popdown()
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self.calibrating_axis = method
if method == "x":
@@ -152,17 +152,11 @@ class InputShaperPanel(ScreenPanel):
def activate(self):
# This will return the current values
self._screen._ws.klippy.gcode_script(
'SET_INPUT_SHAPER'
)
self._screen._ws.klippy.gcode_script('SET_INPUT_SHAPER')
# Check for the accelerometer
self._screen._ws.klippy.gcode_script(
'ACCELEROMETER_QUERY'
)
self._screen._ws.klippy.gcode_script('ACCELEROMETER_QUERY')
# Send at least two commands, with my accelerometer the first command after a reboot will fail
self._screen._ws.klippy.gcode_script(
'MEASURE_AXES_NOISE'
)
self._screen._ws.klippy.gcode_script('MEASURE_AXES_NOISE')
def process_update(self, action, data):
if action != "notify_gcode_response":
+40 -32
View File
@@ -119,10 +119,10 @@ class JobStatusPanel(ScreenPanel):
overlay.add_overlay(box)
self.grid.attach(overlay, 0, 0, 1, 1)
self.labels['thumbnail'] = self._gtk.Image("file", self._screen.width / 4, self._screen.height / 4)
self.labels['thumbnail'] = self._gtk.Image()
self.labels['info_grid'] = Gtk.Grid()
self.labels['info_grid'].attach(self.labels['thumbnail'], 0, 0, 1, 1)
if self._screen.printer.get_tools():
if self._printer.get_tools():
self.current_extruder = self._printer.get_stat("toolhead", "extruder")
diameter = float(self._printer.get_config_section(self.current_extruder)['filament_diameter'])
self.fila_section = pi * ((diameter / 2) ** 2)
@@ -159,7 +159,7 @@ class JobStatusPanel(ScreenPanel):
nlimit = 2 if self._screen.width <= 480 else 3
n = 0
self.buttons['extruder'] = {}
if self._screen.printer.get_tools():
if self._printer.get_tools():
for i, extruder in enumerate(self._printer.get_tools()):
self.labels[extruder] = Gtk.Label("-")
self.buttons['extruder'][extruder] = self._gtk.Button(f"extruder-{i}", "", None, self.bts,
@@ -183,7 +183,7 @@ class JobStatusPanel(ScreenPanel):
self.buttons['heater']['heater_bed'].set_halign(Gtk.Align.START)
self.labels['temp_grid'].attach(self.buttons['heater']['heater_bed'], n, 0, 1, 1)
n += 1
for dev in self._screen.printer.get_heaters():
for dev in self._printer.get_heaters():
if n >= nlimit:
break
if dev.startswith("heater_generic"):
@@ -201,7 +201,7 @@ class JobStatusPanel(ScreenPanel):
if titlebar_items is not None:
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
logging.info(f"Titlebar items: {titlebar_items}")
for device in self._screen.printer.get_heaters():
for device in self._printer.get_heaters():
if device.startswith("temperature_sensor"):
name = " ".join(device.split(" ")[1:])
for item in titlebar_items:
@@ -227,9 +227,9 @@ class JobStatusPanel(ScreenPanel):
szfe.set_column_homogeneous(True)
szfe.attach(self.buttons['speed'], 0, 0, 3, 1)
szfe.attach(self.buttons['z'], 2, 0, 2, 1)
if self._screen.printer.get_tools():
if self._printer.get_tools():
szfe.attach(self.buttons['extrusion'], 0, 1, 3, 1)
if self._screen.printer.get_fans():
if self._printer.get_fans():
szfe.attach(self.buttons['fan'], 2, 1, 2, 1)
info = Gtk.Grid()
@@ -340,7 +340,7 @@ class JobStatusPanel(ScreenPanel):
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.set_line_width(self._gtk.font_size * .75)
ctx.translate(w / 2, h / 2)
ctx.arc(0, 0, r, 0, 2 * pi)
ctx.stroke()
@@ -351,9 +351,14 @@ class JobStatusPanel(ScreenPanel):
def activate(self):
ps = self._printer.get_stat("print_stats")
self.set_state(ps['state'])
if 'filename' in ps and (ps['filename'] != self.filename):
logging.debug(f"Changing filename: '{self.filename}' to '{ps['filename']}'")
self.update_filename()
if self.flow_timeout is None:
self.flow_timeout = GLib.timeout_add_seconds(2, self.update_flow)
self._screen.base_panel_show_all()
logging.debug("Job_status panel")
self._screen.memory_trace()
def deactivate(self):
if self.flow_timeout is not None:
@@ -394,7 +399,7 @@ class JobStatusPanel(ScreenPanel):
+ "\n\n"
+ _("Saved offset: %s") % saved_z_offset)
elif device == "endstop":
label.set_label(_("Apply %.2f offset to Endstop?") % (sign, abs(self.zoffset)))
label.set_label(_("Apply %s%.2f offset to Endstop?") % (sign, abs(self.zoffset)))
label.set_hexpand(True)
label.set_halign(Gtk.Align.CENTER)
label.set_vexpand(True)
@@ -422,6 +427,9 @@ class JobStatusPanel(ScreenPanel):
def restart(self, widget):
if self.filename != "none":
if self.state == "error":
script = {"script": "SDCARD_RESET_FILE"}
self._screen._send_action(None, "printer.gcode.script", script)
self._screen._ws.klippy.print_start(self.filename)
self.new_print()
@@ -556,7 +564,7 @@ class JobStatusPanel(ScreenPanel):
)
self.buttons['speed'].set_label(self.labels['req_speed'].get_label())
with contextlib.suppress(KeyError):
self.zoffset = data["gcode_move"]["homing_origin"][2]
self.zoffset = float(data["gcode_move"]["homing_origin"][2])
self.labels['zoffset'].set_label(f"{self.zoffset:.2f} {self.mm}")
if "motion_report" in data:
with contextlib.suppress(KeyError):
@@ -583,7 +591,7 @@ class JobStatusPanel(ScreenPanel):
fan_label = ""
for fan in self.fans:
with contextlib.suppress(KeyError):
self.fans[fan]['speed'] = f"{self._screen.printer.get_fan_speed(fan) * 100:3.0f}%"
self.fans[fan]['speed'] = f"{self._printer.get_fan_speed(fan) * 100:3.0f}%"
fan_label += f" {self.fans[fan]['name']}{self.fans[fan]['speed']}"
if fan_label:
self.buttons['fan'].set_label(fan_label[:12])
@@ -607,13 +615,11 @@ class JobStatusPanel(ScreenPanel):
f"{1 + round((self.pos_z - self.f_layer_h) / self.layer_h)} / {self.labels['total_layers'].get_text()}")
if 'print_duration' in ps:
total_duration = ps['total_duration']
print_duration = ps['print_duration']
if 'filament_used' in ps:
self.labels['filament_used'].set_label(f"{float(ps['filament_used']) / 1000:.1f} m")
self.update_time_left(total_duration, print_duration, ps['filament_used'])
self.update_time_left(ps['total_duration'], ps['print_duration'], ps['filament_used'])
else:
self.update_time_left(total_duration, print_duration)
self.update_time_left(ps['total_duration'], ps['print_duration'])
elapsed_label = f"{self.labels['elapsed'].get_text()} {self.labels['duration'].get_text()}"
self.buttons['elapsed'].set_label(elapsed_label)
@@ -742,16 +748,16 @@ class JobStatusPanel(ScreenPanel):
self.enable_button("resume", "cancel")
self.can_close = False
else:
offset = self._screen.printer.get_stat("gcode_move", "homing_origin")
offset = self._printer.get_stat("gcode_move", "homing_origin")
self.zoffset = float(offset[2]) if offset else 0
if self.zoffset != 0:
endstop = (self._screen.printer.config_section_exists("stepper_z") and
not self._screen.printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"))
endstop = (self._printer.config_section_exists("stepper_z") and
not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"))
if endstop:
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._screen.printer.get_probe():
if self._printer.get_probe():
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)
@@ -764,19 +770,21 @@ class JobStatusPanel(ScreenPanel):
if self.state != "cancelling":
self.buttons['button_grid'].attach(self.buttons['menu'], 3, 0, 1, 1)
self.can_close = True
self.show_all()
self.content.show_all()
def show_file_thumbnail(self):
if self._files.has_thumbnail(self.filename):
if self._screen.vertical_mode:
width = self._screen.width * 0.9
height = self._screen.height / 4
else:
width = self._screen.width / 3
height = self._gtk.get_content_height() * 0.47
pixbuf = self.get_file_image(self.filename, width, height)
if pixbuf is not None:
self.labels['thumbnail'].set_from_pixbuf(pixbuf)
if self._screen.vertical_mode:
width = self._screen.width * 0.9
height = self._screen.height / 4
else:
width = self._screen.width / 3
height = self._gtk.content_height * 0.47
pixbuf = self.get_file_image(self.filename, width, height)
logging.debug(self.filename)
if pixbuf is None:
logging.debug("no pixbuf")
pixbuf = self._gtk.PixbufFromIcon("file", width / 2, height / 2)
self.labels['thumbnail'].set_from_pixbuf(pixbuf)
def update_filename(self):
self.filename = self._printer.get_stat('print_stats', 'filename')
@@ -785,7 +793,7 @@ class JobStatusPanel(ScreenPanel):
"complete": self.labels['file'].get_label(),
"current": self.labels['file'].get_label(),
"position": 0,
"limit": (self._screen.width * 37 / 480) // (self._gtk.get_font_size() / 11),
"limit": (self._screen.width * 37 / 480) // (self._gtk.font_size / 11),
"length": len(self.labels['file'].get_label())
}
if self.animation_timeout is None and (self.filename_label['length'] - self.filename_label['limit']) > 0:
@@ -809,7 +817,6 @@ class JobStatusPanel(ScreenPanel):
logging.info(f"Update Metadata. File: {self.filename} Size: {self.file_metadata['size']}")
if "estimated_time" in self.file_metadata and self.timeleft_type == "slicer":
self.labels["est_time"].set_label(self.format_time(self.file_metadata['estimated_time']))
self.show_file_thumbnail()
if "object_height" in self.file_metadata:
self.oheight = float(self.file_metadata['object_height'])
self.labels['height'].set_label(f"{self.oheight} {self.mm}")
@@ -826,6 +833,7 @@ class JobStatusPanel(ScreenPanel):
self.file_metadata = {}
logging.debug("Cannot find file metadata. Listening for updated metadata")
self._screen.files.add_file_callback(self._callback_metadata)
self.show_file_thumbnail()
def update_percent_complete(self):
if self.state not in ["printing", "paused"]:
+3 -4
View File
@@ -6,7 +6,7 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
from panels.menu import MenuPanel
from ks_includes.widgets.graph import HeaterGraph
from ks_includes.widgets.heatergraph import HeaterGraph
from ks_includes.widgets.keypad import Keypad
@@ -47,7 +47,6 @@ class MainPanel(MenuPanel):
grid.attach(self.labels['menu'], 1, 0, 1, 1)
self.grid = grid
self.content.add(self.grid)
self.layout.show_all()
def update_graph_visibility(self):
if self.left_panel is None or not self._printer.get_temp_store_devices():
@@ -209,12 +208,12 @@ class MainPanel(MenuPanel):
name = Gtk.Label("")
temp = Gtk.Label(_("Temp (°C)"))
temp.set_size_request(self._gtk.font_size * 6, -1)
temp.get_style_context().add_class("heater-grid-temp")
self.labels['devices'].attach(name, 0, 0, 1, 1)
self.labels['devices'].attach(temp, 1, 0, 1, 1)
self.labels['da'] = HeaterGraph(self._printer, self._gtk.get_font_size())
self.labels['da'] = HeaterGraph(self._printer, self._gtk.font_size)
self.labels['da'].set_vexpand(True)
scroll = self._gtk.ScrolledWindow()
+25 -11
View File
@@ -2,6 +2,8 @@ import logging
import gi
import json
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from jinja2 import Environment, Template
@@ -31,10 +33,6 @@ class MenuPanel(ScreenPanel):
self.content.add(scroll)
def activate(self):
self.j2_data = self._printer.get_printer_status_data()
self.j2_data.update({
'moonraker_connected': self._screen._ws.connected
})
if self._screen.vertical_mode:
self.arrangeMenuItems(self.items, 3)
else:
@@ -69,7 +67,7 @@ class MenuPanel(ScreenPanel):
self.grid.attach(self.labels[key], col, row, width, height)
i += 1
self.j2_data = None
return self.grid
def create_menu_items(self):
@@ -79,14 +77,29 @@ class MenuPanel(ScreenPanel):
env = Environment(extensions=["jinja2.ext.i18n"], autoescape=True)
env.install_gettext_translations(self._config.get_lang())
j2_temp = env.from_string(item['name'])
parsed_name = j2_temp.render()
b = self._gtk.Button(item['icon'], parsed_name, f"color{(i % 4) + 1}")
printer = self._printer.get_printer_status_data()
name = env.from_string(item['name']).render(printer)
icon = env.from_string(item['icon']).render(printer) if item['icon'] else None
style = env.from_string(item['style']).render(printer) if item['style'] else None
b = self._gtk.Button(icon, name, (style if style else f"color{(i % 4) + 1}"))
if item['panel'] is not None:
b.connect("clicked", self.menu_item_clicked, item['panel'], item)
panel = env.from_string(item['panel']).render(printer)
b.connect("clicked", self.menu_item_clicked, panel, item)
elif item['method'] is not None:
params = item['params'] if item['params'] is not False else {}
params = {}
if item['params'] is not False:
try:
p = env.from_string(item['params']).render(printer)
params = json.loads(p)
except Exception as e:
logging.exception(f"Unable to parse parameters for [{name}]:\n{e}")
params = {}
if item['confirm'] is not None:
b.connect("clicked", self._screen._confirm_send_action, item['confirm'], item['method'], params)
else:
@@ -99,7 +112,8 @@ class MenuPanel(ScreenPanel):
if enable == "{{ moonraker_connected }}":
logging.info(f"moonraker connected {self._screen._ws.connected}")
return self._screen._ws.connected
elif enable == "{{ camera_configured }}":
return self.ks_printer_cfg and self.ks_printer_cfg.get("camera_url", None) is not None
self.j2_data = self._printer.get_printer_status_data()
try:
j2_temp = Template(enable, autoescape=True)
+4 -4
View File
@@ -82,7 +82,7 @@ class MovePanel(ScreenPanel):
grid.attach(self.buttons['z_tilt'], 2, 0, 1, 1)
elif self._printer.config_section_exists("quad_gantry_level"):
grid.attach(self.buttons['quad_gantry_level'], 2, 0, 1, 1)
elif "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
elif "delta" in self._printer.get_config_section("printer")['kinematics']:
grid.attach(self.buttons['motors_off'], 2, 0, 1, 1)
else:
grid.attach(self.buttons['home_xy'], 2, 0, 1, 1)
@@ -164,7 +164,7 @@ class MovePanel(ScreenPanel):
return
if action != "notify_status_update":
return
homed_axes = self._screen.printer.get_stat("toolhead", "homed_axes")
homed_axes = self._printer.get_stat("toolhead", "homed_axes")
if homed_axes == "xyz":
if "gcode_move" in data and "gcode_position" in data["gcode_move"]:
self.labels['pos_x'].set_text(f"X: {data['gcode_move']['gcode_position'][0]:.2f}")
@@ -233,8 +233,8 @@ 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.font_size * 7))
switch.set_property("height-request", round(self._gtk.font_size * 3.5))
box.add(switch)
dev.add(box)
elif option['type'] == "scale":
+5 -3
View File
@@ -159,14 +159,13 @@ class NetworkPanel(ScreenPanel):
labels.set_valign(Gtk.Align.CENTER)
labels.set_halign(Gtk.Align.START)
connect = self._gtk.Button("load", style="color3")
connect = self._gtk.Button("load", None, "color3", .66)
connect.connect("clicked", self.connect_network, ssid)
connect.set_hexpand(False)
connect.set_halign(Gtk.Align.END)
delete = self._gtk.Button("delete", style="color3")
delete = self._gtk.Button("delete", None, "color3", .66)
delete.connect("clicked", self.remove_wifi_network, ssid)
delete.set_size_request(60, 0)
delete.set_hexpand(False)
delete.set_halign(Gtk.Align.END)
@@ -179,6 +178,7 @@ class NetworkPanel(ScreenPanel):
buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
if network_id != -1 or netinfo['connected']:
buttons.pack_end(connect, False, False, 0)
buttons.pack_end(delete, False, False, 0)
else:
buttons.pack_end(connect, False, False, 0)
@@ -387,6 +387,7 @@ class NetworkPanel(ScreenPanel):
ifadd = netifaces.ifaddresses(self.interface)
if netifaces.AF_INET in ifadd and len(ifadd[netifaces.AF_INET]) > 0:
ipv4 = f"<b>IPv4:</b> {ifadd[netifaces.AF_INET][0]['addr']} "
self.labels['ip'].set_text(f"IP: {ifadd[netifaces.AF_INET][0]['addr']} ")
if netifaces.AF_INET6 in ifadd and len(ifadd[netifaces.AF_INET6]) > 0:
ipv6 = f"<b>IPv6:</b> {ifadd[netifaces.AF_INET6][0]['addr'].split('%')[0]} "
info = '<b>' + _("Hostname") + f':</b> {hostname}\n{ipv4}\n{ipv6}\n'
@@ -414,6 +415,7 @@ class NetworkPanel(ScreenPanel):
ipv6 = ""
if netifaces.AF_INET in ifadd and len(ifadd[netifaces.AF_INET]) > 0:
ipv4 = f"<b>IPv4:</b> {ifadd[netifaces.AF_INET][0]['addr']} "
self.labels['ip'].set_text(f"IP: {ifadd[netifaces.AF_INET][0]['addr']} ")
if netifaces.AF_INET6 in ifadd and len(ifadd[netifaces.AF_INET6]) > 0:
ipv6 = f"<b>IPv6:</b> {ifadd[netifaces.AF_INET6][0]['addr'].split('%')[0]} "
connected = (
+6 -6
View File
@@ -30,10 +30,10 @@ class PowerPanel(ScreenPanel):
self.content.add(scroll)
def activate(self):
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
for x in devices:
self.devices[x]['switch'].disconnect_by_func(self.on_switch)
self.devices[x]['switch'].set_active(self._screen.printer.get_power_device_status(x) == "on")
self.devices[x]['switch'].set_active(self._printer.get_power_device_status(x) == "on")
self.devices[x]['switch'].connect("notify::active", self.on_switch, x)
@@ -49,10 +49,10 @@ class PowerPanel(ScreenPanel):
switch = Gtk.Switch()
switch.set_hexpand(False)
switch.set_active(self._screen.printer.get_power_device_status(device) == "on")
switch.set_active(self._printer.get_power_device_status(device) == "on")
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.font_size * 7))
switch.set_property("height-request", round(self._gtk.font_size * 3.5))
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
labels.add(name)
@@ -77,7 +77,7 @@ class PowerPanel(ScreenPanel):
self.labels['devices'].show_all()
def load_power_devices(self):
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
for x in devices:
self.add_device(x)
+115 -37
View File
@@ -37,6 +37,7 @@ class PrintPanel(ScreenPanel):
self.directories = {}
self.labels['directories'] = {}
self.labels['files'] = {}
self.source = ""
self.time_24 = self._config.get_main_config().getboolean("24htime", True)
logging.info(f"24h time is {self.time_24}")
@@ -62,23 +63,26 @@ class PrintPanel(ScreenPanel):
pbox.add(self.labels['path'])
self.labels['path_box'] = pbox
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
box.set_vexpand(True)
box.pack_start(sbox, False, False, 0)
box.pack_start(pbox, False, False, 0)
box.pack_start(self.scroll, True, True, 0)
self.main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
self.main.set_vexpand(True)
self.main.pack_start(sbox, False, False, 0)
self.main.pack_start(pbox, False, False, 0)
self.main.pack_start(self.scroll, True, True, 0)
self.dir_panels['gcodes'] = Gtk.Grid()
GLib.idle_add(self.reload_files)
self.scroll.add(self.dir_panels['gcodes'])
self.content.add(box)
self.content.add(self.main)
self._screen.files.add_file_callback(self._callback)
self.showing_rename = False
def activate(self):
if self.cur_directory != "gcodes":
self.change_dir(None, "gcodes")
self._refresh_files()
logging.debug("Print panel")
def add_directory(self, directory, show=True):
parent_dir = os.path.dirname(directory)
@@ -126,8 +130,10 @@ class PrintPanel(ScreenPanel):
if self.time_24:
time = f':<b> {datetime.fromtimestamp(fileinfo["modified"]):%Y-%m-%d %H:%M}</b>'
else:
time = f':<b> {datetime.fromtimestamp(fileinfo["modified"]):%Y-%m-%d %I:%M %p}<b>'
self.labels['directories'][curdir]['info'].set_markup(_("Modified") + time)
time = f':<b> {datetime.fromtimestamp(fileinfo["modified"]):%Y-%m-%d %I:%M %p}</b>'
info = _("Modified") + time
info += "\n" + _("Size") + f':<b> {self.format_size(fileinfo["size"])}</b>'
self.labels['directories'][curdir]['info'].set_markup(info)
self.filelist[directory]['files'].append(filename)
if filepath not in self.files:
@@ -160,49 +166,59 @@ class PrintPanel(ScreenPanel):
name.set_line_wrap_mode(Pango.WrapMode.CHAR)
info = Gtk.Label()
info.set_hexpand(True)
info.set_halign(Gtk.Align.START)
info.get_style_context().add_class("print-info")
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
labels.add(name)
labels.add(info)
labels.set_vexpand(True)
labels.set_valign(Gtk.Align.CENTER)
labels.set_halign(Gtk.Align.START)
delete = self._gtk.Button("delete", style="color1", scale=self.bts)
delete.set_hexpand(False)
rename = self._gtk.Button("files", style="color2", scale=self.bts)
rename.set_hexpand(False)
actions = self._gtk.Button("load", style="color3")
actions.set_hexpand(False)
actions.set_halign(Gtk.Align.END)
if filename:
action = self._gtk.Button("print", style="color3")
action.connect("clicked", self.confirm_print, fullpath)
info.set_markup(self.get_file_info_str(fullpath))
actions.connect("clicked", self.confirm_print, fullpath)
icon = Gtk.Button()
icon.connect("clicked", self.confirm_delete_file, f"gcodes/{fullpath}")
icon.connect("clicked", self.confirm_print, fullpath)
delete.connect("clicked", self.confirm_delete_file, f"gcodes/{fullpath}")
rename.connect("clicked", self.show_rename, f"gcodes/{fullpath}")
GLib.idle_add(self.image_load, fullpath)
else:
actions.connect("clicked", self.change_dir, fullpath)
action = self._gtk.Button("load", style="color3")
action.connect("clicked", self.change_dir, fullpath)
icon = self._gtk.Button("folder")
icon.connect("clicked", self.confirm_delete_directory, fullpath)
icon.connect("clicked", self.change_dir, fullpath)
delete.connect("clicked", self.confirm_delete_directory, fullpath)
rename.connect("clicked", self.show_rename, fullpath)
icon.set_hexpand(False)
action.set_hexpand(False)
action.set_halign(Gtk.Align.END)
delete.connect("clicked", self.confirm_delete_file, f"gcodes/{fullpath}")
row = Gtk.Grid()
row.get_style_context().add_class("frame-item")
row.set_hexpand(True)
row.set_vexpand(False)
row.attach(icon, 0, 0, 1, 2)
row.attach(name, 1, 0, 3, 1)
row.attach(info, 1, 1, 1, 1)
row.attach(rename, 2, 1, 1, 1)
row.attach(delete, 3, 1, 1, 1)
file = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
file.get_style_context().add_class("frame-item")
file.set_hexpand(True)
file.set_vexpand(False)
file.add(icon)
file.add(labels)
if not filename or (filename and os.path.splitext(filename)[1] in [".gcode", ".g", ".gco"]):
file.add(actions)
row.attach(action, 4, 0, 1, 2)
if filename is not None:
self.files[fullpath] = file
self.files[fullpath] = row
self.labels['files'][fullpath] = {
"icon": icon,
"info": info,
"name": name
}
else:
self.directories[fullpath] = file
self.directories[fullpath] = row
self.labels['directories'][fullpath] = {
"info": info,
"name": name
@@ -237,6 +253,9 @@ class PrintPanel(ScreenPanel):
)
def back(self):
if self.showing_rename:
self.hide_rename()
return True
if os.path.dirname(self.cur_directory):
self.change_dir(None, os.path.dirname(self.cur_directory))
return True
@@ -314,7 +333,10 @@ class PrintPanel(ScreenPanel):
directory = os.path.join("gcodes", os.path.dirname(filename)) if os.path.dirname(filename) else "gcodes"
if directory not in self.filelist or os.path.basename(filename).startswith("."):
return
self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename)))
try:
self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename)))
except Exception as e:
logging.exception(e)
dir_parts = directory.split(os.sep)
i = len(dir_parts)
while i > 1:
@@ -334,7 +356,10 @@ class PrintPanel(ScreenPanel):
self.dir_panels[parent_dir].show_all()
i -= 1
self.dir_panels[directory].remove(self.files[filename])
try:
self.dir_panels[directory].remove(self.files[filename])
except Exception as e:
logging.exception(e)
self.dir_panels[directory].show_all()
self.files.pop(filename)
@@ -388,10 +413,63 @@ class PrintPanel(ScreenPanel):
for file in updatedfiles:
self.update_file(file)
def _refresh_files(self, widget):
def _refresh_files(self, widget=None):
self._files.refresh_files()
self._screen.memory_trace()
def process_update(self, action, data):
if action == "notify_gcode_response" and "unknown" in data.lower():
self._screen.show_popup_message(data)
return
def show_rename(self, widget, fullpath):
self.source = fullpath
logging.info(self.source)
for child in self.content.get_children():
self.content.remove(child)
if "rename_file" not in self.labels:
self._create_rename_box(fullpath)
self.content.add(self.labels['rename_file'])
self.labels['new_name'].set_text(fullpath[7:])
self.labels['new_name'].grab_focus_without_selecting()
self.showing_rename = True
def _create_rename_box(self, fullpath):
lbl = self._gtk.Label(_("Rename/Move:"))
lbl.set_halign(Gtk.Align.START)
lbl.set_hexpand(False)
self.labels['new_name'] = Gtk.Entry()
self.labels['new_name'].set_text(fullpath)
self.labels['new_name'].set_hexpand(True)
self.labels['new_name'].connect("activate", self.rename)
self.labels['new_name'].connect("focus-in-event", self._screen.show_keyboard)
save = self._gtk.Button("complete", _("Save"), "color3")
save.set_hexpand(False)
save.connect("clicked", self.rename)
box = Gtk.Box()
box.pack_start(self.labels['new_name'], True, True, 5)
box.pack_start(save, False, False, 5)
self.labels['rename_file'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
self.labels['rename_file'].set_valign(Gtk.Align.CENTER)
self.labels['rename_file'].set_hexpand(True)
self.labels['rename_file'].set_vexpand(True)
self.labels['rename_file'].pack_start(lbl, True, True, 5)
self.labels['rename_file'].pack_start(box, True, True, 5)
def hide_rename(self):
self._screen.remove_keyboard()
for child in self.content.get_children():
self.content.remove(child)
self.content.add(self.main)
self.content.show()
self.showing_rename = False
def rename(self, widget):
params = {"source": self.source, "dest": f"gcodes/{self.labels['new_name'].get_text()}"}
self._screen._send_action(
widget,
"server.files.move",
params
)
self.back()
GLib.timeout_add_seconds(2, self._refresh_files)
+6 -6
View File
@@ -17,7 +17,7 @@ class SplashScreenPanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
image = self._gtk.Image("klipper", self._gtk.get_content_width() * .2, self._gtk.get_content_height() * .5)
image = self._gtk.Image("klipper", self._gtk.content_width * .2, self._gtk.content_height * .5)
self.labels['text'] = Gtk.Label(_("Initializing printer..."))
self.labels['text'].set_line_wrap(True)
self.labels['text'].set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
@@ -42,7 +42,7 @@ class SplashScreenPanel(ScreenPanel):
self.labels['actions'].set_vexpand(False)
self.labels['actions'].set_halign(Gtk.Align.CENTER)
self.labels['actions'].set_homogeneous(True)
self.labels['actions'].set_size_request(self._gtk.get_content_width(), -1)
self.labels['actions'].set_size_request(self._gtk.content_width, -1)
scroll = self._gtk.ScrolledWindow()
scroll.set_hexpand(True)
@@ -74,7 +74,7 @@ class SplashScreenPanel(ScreenPanel):
self.clear_action_bar()
if self.ks_printer_cfg is not None and self._screen._ws.connected:
power_devices = self.ks_printer_cfg.get("power_devices", "")
if power_devices:
if power_devices and self._printer.get_power_devices():
logging.info(f"Associated power devices: {power_devices}")
self.add_power_button(power_devices)
@@ -103,13 +103,13 @@ class SplashScreenPanel(ScreenPanel):
def check_power_status(self):
if 'power' in self.labels:
devices = self._screen.printer.get_power_devices()
devices = self._printer.get_power_devices()
if devices is not None:
for device in devices:
if self._screen.printer.get_power_device_status(device) == "off":
if self._printer.get_power_device_status(device) == "off":
self.labels['power'].set_sensitive(True)
break
elif self._screen.printer.get_power_device_status(device) == "on":
elif self._printer.get_power_device_status(device) == "on":
self.labels['power'].set_sensitive(False)
def firmware_restart(self, widget):
+4 -5
View File
@@ -7,7 +7,7 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
from ks_includes.screen_panel import ScreenPanel
from ks_includes.widgets.graph import HeaterGraph
from ks_includes.widgets.heatergraph import HeaterGraph
from ks_includes.widgets.keypad import Keypad
@@ -43,7 +43,7 @@ class TemperaturePanel(ScreenPanel):
self.show_preheat = True
selection.extend(self._printer.get_heaters())
else:
current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
current_extruder = self._printer.get_stat("toolhead", "extruder")
if current_extruder:
selection.append(current_extruder)
@@ -64,7 +64,6 @@ class TemperaturePanel(ScreenPanel):
self.grid.attach(self.create_right_panel(), 1, 0, 1, 1)
self.content.add(self.grid)
self.layout.show_all()
def create_right_panel(self):
cooldown = self._gtk.Button('cool-down', _('Cooldown'), "color4", self.bts, Gtk.PositionType.LEFT, 1)
@@ -428,12 +427,12 @@ class TemperaturePanel(ScreenPanel):
name = Gtk.Label("")
temp = Gtk.Label(_("Temp (°C)"))
temp.set_size_request(self._gtk.font_size * 6, -1)
temp.get_style_context().add_class("heater-grid-temp")
self.labels['devices'].attach(name, 0, 0, 1, 1)
self.labels['devices'].attach(temp, 1, 0, 1, 1)
self.labels['da'] = HeaterGraph(self._printer, self._gtk.get_font_size())
self.labels['da'] = HeaterGraph(self._printer, self._gtk.font_size)
self.labels['da'].set_vexpand(True)
scroll = self._gtk.ScrolledWindow()
+13 -12
View File
@@ -21,7 +21,7 @@ class ZCalibratePanel(ScreenPanel):
def __init__(self, screen, title):
super().__init__(screen, title)
self.z_offset = None
self.probe = self._screen.printer.get_probe()
self.probe = self._printer.get_probe()
if self.probe:
self.z_offset = float(self.probe['z_offset'])
logging.info(f"Z offset: {self.z_offset}")
@@ -51,7 +51,7 @@ class ZCalibratePanel(ScreenPanel):
functions = []
pobox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
if self._printer.config_section_exists("stepper_z") \
and not self._screen.printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"):
and not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"):
self._add_button("Endstop", "endstop", pobox)
functions.append("endstop")
if self.probe:
@@ -61,7 +61,7 @@ class ZCalibratePanel(ScreenPanel):
# This is used to do a manual bed mesh if there is no probe
self._add_button("Bed mesh", "mesh", pobox)
functions.append("mesh")
if "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
if "delta" in self._printer.get_config_section("printer")['kinematics']:
if "probe" in functions:
self._add_button("Delta Automatic", "delta", pobox)
functions.append("delta")
@@ -132,7 +132,7 @@ class ZCalibratePanel(ScreenPanel):
def start_calibration(self, widget, method):
self.labels['popover'].popdown()
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
if method == "probe":
@@ -166,8 +166,8 @@ class ZCalibratePanel(ScreenPanel):
speed = self.probe['speed']
# Use safe_z_home position
if "safe_z_home" in self._screen.printer.get_config_section_list():
safe_z = self._screen.printer.get_config_section("safe_z_home")
if "safe_z_home" in self._printer.get_config_section_list():
safe_z = self._printer.get_config_section("safe_z_home")
safe_z_xy = safe_z['home_xy_position']
safe_z_xy = [str(i.strip()) for i in safe_z_xy.split(',')]
if x_position is None:
@@ -183,12 +183,14 @@ class ZCalibratePanel(ScreenPanel):
speed = 15 if speed is None else speed
z_hop = 5 if z_hop is None else z_hop
self._screen._ws.klippy.gcode_script(f"G0 Z{z_hop} F{float(speed) * 60}")
self._screen._ws.klippy.gcode_script(f"G91\nG0 Z{z_hop} F{float(speed) * 60}")
if self._printer.get_stat("gcode_move", "absolute_coordinates"):
self._screen._ws.klippy.gcode_script("G90")
if x_position is not None and y_position is not None:
logging.debug(f"Configured probing position X: {x_position} Y: {y_position}")
self._screen._ws.klippy.gcode_script(f'G0 X{x_position} Y{y_position} F3000')
elif "delta" in self._screen.printer.get_config_section("printer")['kinematics']:
elif "delta" in self._printer.get_config_section("printer")['kinematics']:
logging.info("Detected delta kinematics calibrating at 0,0")
self._screen._ws.klippy.gcode_script('G0 X0 Y0 F3000')
else:
@@ -197,8 +199,8 @@ class ZCalibratePanel(ScreenPanel):
def _calculate_position(self):
logging.debug("Position not configured, probing the middle of the bed")
try:
xmax = float(self._screen.printer.get_config_section("stepper_x")['position_max'])
ymax = float(self._screen.printer.get_config_section("stepper_y")['position_max'])
xmax = float(self._printer.get_config_section("stepper_x")['position_max'])
ymax = float(self._printer.get_config_section("stepper_y")['position_max'])
except KeyError:
logging.error("Couldn't get max position from stepper_x and stepper_y")
return
@@ -231,7 +233,7 @@ class ZCalibratePanel(ScreenPanel):
self.process_busy(data)
return
if action == "notify_status_update":
if self._screen.printer.get_stat("toolhead", "homed_axes") != "xyz":
if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self.widgets['zposition'].set_text("Z: ?")
elif "gcode_move" in data and "gcode_position" in data['gcode_move']:
self.update_position(data['gcode_move']['gcode_position'])
@@ -242,7 +244,6 @@ class ZCalibratePanel(ScreenPanel):
logging.info(data)
elif "save_config" in data:
self.buttons_not_calibrating()
self._screen.show_popup_message(_("Calibrated, save configuration to make it permanent"), level=1)
elif "out of range" in data:
self._screen.show_popup_message(data)
self.buttons_not_calibrating()
+127 -99
View File
@@ -10,6 +10,7 @@ import traceback # noqa
import locale
import sys
import gi
import tracemalloc
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango
@@ -66,6 +67,10 @@ def set_text_direction(lang=None):
return True
def state_execute(callback):
callback()
class KlipperScreen(Gtk.Window):
""" Class for creating a screen for Klipper via HDMI """
_cur_panels = []
@@ -78,7 +83,7 @@ class KlipperScreen(Gtk.Window):
panels = {}
popup_message = None
screensaver = None
printer = None
printers = printer = None
subscriptions = []
updating = False
_ws = None
@@ -86,8 +91,11 @@ class KlipperScreen(Gtk.Window):
reinit_count = 0
max_retries = 4
initialized = False
initial_snapshot = None
switch_count = 0
def __init__(self, args, version):
tracemalloc.start()
try:
super().__init__(title="KlipperScreen")
except Exception as e:
@@ -106,6 +114,7 @@ class KlipperScreen(Gtk.Window):
self.lang_ltr = set_text_direction(self._config.get_main_config().get("language", None))
self.connect("key-press-event", self._key_press_event)
self.connect("configure_event", self.update_size)
monitor = Gdk.Display.get_default().get_primary_monitor()
if monitor is None:
monitor = Gdk.Display.get_default().get_monitor(0)
@@ -114,22 +123,22 @@ class KlipperScreen(Gtk.Window):
self.width = self._config.get_main_config().getint("width", monitor.get_geometry().width)
self.height = self._config.get_main_config().getint("height", monitor.get_geometry().height)
self.set_default_size(self.width, self.height)
self.set_resizable(False)
self.set_resizable(True)
if not (self._config.get_main_config().get("width") or self._config.get_main_config().get("height")):
self.fullscreen()
self.vertical_mode = self.width < self.height
self.aspect_ratio = self.width / self.height
self.vertical_mode = self.aspect_ratio < 1.0
logging.info(f"Screen resolution: {self.width}x{self.height}")
self.theme = self._config.get_main_config().get('theme')
show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False)
self.gtk = KlippyGtk(self, self.width, self.height, self.theme, show_cursor,
self._config.get_main_config().get("font_size", "medium"))
self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False)
self.gtk = KlippyGtk(self)
self.init_style()
self.set_icon_from_file(os.path.join(klipperscreendir, "styles", "icon.svg"))
self.base_panel = BasePanel(self, title="Base Panel")
self.add(self.base_panel.layout)
self.add(self.base_panel.main_grid)
self.show_all()
if show_cursor:
if self.show_cursor:
self.get_window().set_cursor(
Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.ARROW))
os.system("xsetroot -cursor_name arrow")
@@ -147,13 +156,24 @@ class KlipperScreen(Gtk.Window):
self.initial_connection()
def initial_connection(self):
printers = self._config.get_printers()
self.printers = self._config.get_printers()
state_callbacks = {
"disconnected": self.state_disconnected,
"error": self.state_error,
"paused": self.state_paused,
"printing": self.state_printing,
"ready": self.state_ready,
"startup": self.state_startup,
"shutdown": self.state_shutdown
}
for printer in self.printers:
printer["data"] = Printer(state_execute, state_callbacks, self.process_busy_state)
default_printer = self._config.get_main_config().get('default_printer')
logging.debug(f"Default printer: {default_printer}")
if [True for p in printers if default_printer in p]:
if [True for p in self.printers if default_printer in p]:
self.connect_printer(default_printer)
elif len(printers) == 1:
pname = list(printers[0])[0]
elif len(self.printers) == 1:
pname = list(self.printers[0])[0]
self.connect_printer(pname)
else:
self.base_panel.show_printer_select(True)
@@ -164,40 +184,27 @@ class KlipperScreen(Gtk.Window):
if self._ws is not None and self._ws.connected:
self._ws.close()
self.connected_printer = None
self.printer.state = "disconnected"
if self.files:
self.files.reset()
self.files = None
if self.printer:
self.printer.reset()
self.printer = None
self.connecting = True
self.initialized = False
data = {
"moonraker_host": "127.0.0.1",
"moonraker_port": "7125",
"moonraker_api_key": False
}
logging.info(f"Connecting to printer: {name}")
for printer in self._config.get_printers():
pname = list(printer)[0]
if pname != name:
continue
data = printer[pname]
break
for printer in self.printers:
if name == list(printer)[0]:
ind = self.printers.index(printer)
break
self.printer = self.printers[ind]["data"]
self.apiclient = KlippyRest(
self.printers[ind][name]["moonraker_host"],
self.printers[ind][name]["moonraker_port"],
self.printers[ind][name]["moonraker_api_key"],
)
self.apiclient = KlippyRest(data["moonraker_host"], data["moonraker_port"], data["moonraker_api_key"])
self.printer = Printer(self.state_execute)
self.printer.state_callbacks = {
"disconnected": self.state_disconnected,
"error": self.state_error,
"paused": self.state_paused,
"printing": self.state_printing,
"ready": self.state_ready,
"startup": self.state_startup,
"shutdown": self.state_shutdown
}
self.printer.busy_cb = self.process_busy_state
self.printer_initializing(_("Connecting to %s") % name, remove=True)
self._ws = KlippyWebsocket(self,
@@ -206,13 +213,30 @@ class KlipperScreen(Gtk.Window):
"on_message": self._websocket_callback,
"on_close": self.websocket_disconnected
},
data["moonraker_host"],
data["moonraker_port"]
self.printers[ind][name]["moonraker_host"],
self.printers[ind][name]["moonraker_port"],
)
self.files = KlippyFiles(self)
self._ws.initial_connect()
def memory_trace(self):
snapshot = tracemalloc.take_snapshot()
snapshot = snapshot.filter_traces((
tracemalloc.Filter(False, "<frozen importlib._bootstrap_external>"),
tracemalloc.Filter(False, "<unknown>"),
tracemalloc.Filter(False, tracemalloc.__file__),
))
if self.initial_snapshot is None:
self.initial_snapshot = snapshot
logging.debug("[ Initial memory snapshot ]")
else:
self.switch_count += 1
logging.debug("[ Top 10 memory diffs (Shown: %d times)]", self.switch_count)
top_stats = snapshot.compare_to(self.initial_snapshot, 'lineno')
for stat in top_stats[:10]:
logging.debug(stat)
def ws_subscribe(self):
requested_updates = {
"objects": {
@@ -312,33 +336,25 @@ class KlipperScreen(Gtk.Window):
msg.set_vexpand(True)
msg.get_child().set_line_wrap(True)
msg.get_child().set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
msg.get_child().set_max_width_chars(40)
msg.connect("clicked", self.close_popup_message)
close = Gtk.Button(label="<b><big>X</big></b>")
close.set_hexpand(False)
close.set_vexpand(True)
close.get_child().set_use_markup(True)
close.set_can_focus(False)
close.connect("clicked", self.close_popup_message)
box = Gtk.Box()
box.set_size_request(self.width, -1)
box.set_halign(Gtk.Align.CENTER)
box.get_style_context().add_class("message_popup")
msg.get_style_context().add_class("message_popup")
if level == 1:
box.get_style_context().add_class("message_popup_echo")
msg.get_style_context().add_class("message_popup_echo")
elif level == 2:
box.get_style_context().add_class("message_popup_warning")
msg.get_style_context().add_class("message_popup_warning")
else:
box.get_style_context().add_class("message_popup_error")
msg.get_style_context().add_class("message_popup_error")
box.add(msg)
box.add(close)
popup = Gtk.Popover.new(self.base_panel.titlebar)
popup.get_style_context().add_class("message_popup_popover")
popup.set_size_request(self.width * .9, -1)
popup.set_halign(Gtk.Align.CENTER)
popup.add(msg)
popup.popup()
self.base_panel.layout.put(box, 0, 0)
self.show_all()
self.popup_message = box
self.popup_message = popup
self.popup_message.show_all()
if self._config.get_main_config().getboolean('autoclose_popups', True):
GLib.timeout_add_seconds(10, self.close_popup_message)
@@ -348,8 +364,7 @@ class KlipperScreen(Gtk.Window):
def close_popup_message(self, widget=None):
if self.popup_message is None:
return
self.base_panel.layout.remove(self.popup_message)
self.popup_message.popdown()
self.popup_message = None
def show_error_modal(self, err, e=""):
@@ -444,7 +459,7 @@ class KlipperScreen(Gtk.Window):
style_options['graph_colors']['sensor']['colors'][i]
)
css_data = css_data.replace("KS_FONT_SIZE", f"{self.gtk.get_font_size()}")
css_data = css_data.replace("KS_FONT_SIZE", f"{self.gtk.font_size}")
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css_data.encode())
@@ -534,7 +549,8 @@ class KlipperScreen(Gtk.Window):
box.pack_start(close, True, True, 0)
box.set_halign(Gtk.Align.CENTER)
box.get_style_context().add_class("screensaver")
self.base_panel.layout.put(box, 0, 0)
self.remove(self.base_panel.main_grid)
self.add(box)
# Avoid leaving a cursor-handle
close.grab_focus()
@@ -547,8 +563,9 @@ class KlipperScreen(Gtk.Window):
if self.screensaver is None:
return False
logging.debug("Closing Screensaver")
self.base_panel.layout.remove(self.screensaver)
self.remove(self.screensaver)
self.screensaver = None
self.add(self.base_panel.main_grid)
if self.use_dpms:
self.wake_screen()
else:
@@ -624,17 +641,12 @@ class KlipperScreen(Gtk.Window):
def process_busy_state(self, busy):
self.process_update("notify_busy", busy)
def state_execute(self, callback):
callback()
def websocket_disconnected(self, msg):
self.printer_initializing(msg, remove=True)
self.connecting = True
self.connected_printer = None
self.files.reset()
self.files = None
self.printer.reset()
self.printer = None
self.initialized = False
self.connect_printer(self.connecting_to_printer)
@@ -731,7 +743,10 @@ class KlipperScreen(Gtk.Window):
self.show_popup_message(data[6:], 1)
elif data.startswith("!! "):
self.show_popup_message(data[3:], 3)
if "SAVE_CONFIG" in data and self.printer.state == "ready":
elif "unknown" in data.lower() and \
not ("TESTZ" in data or "MEASURE_AXES_NOISE" in data or "ACCELEROMETER_QUERY" in data):
self.show_popup_message(data)
elif "SAVE_CONFIG" in data and self.printer.state == "ready":
script = {"script": "SAVE_CONFIG"}
self._confirm_send_action(
None,
@@ -911,35 +926,10 @@ class KlipperScreen(Gtk.Window):
return
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
box.set_size_request(self.gtk.get_content_width(), self.gtk.get_keyboard_height())
box.set_size_request(self.gtk.content_width, self.gtk.keyboard_height)
if self._config.get_main_config().getboolean("use-matchbox-keyboard", False):
env = os.environ.copy()
usrkbd = os.path.expanduser("~/.matchbox/keyboard.xml")
if os.path.isfile(usrkbd):
env["MB_KBD_CONFIG"] = usrkbd
else:
env["MB_KBD_CONFIG"] = "ks_includes/locales/keyboard.xml"
p = subprocess.Popen(["matchbox-keyboard", "--xid"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
xid = int(p.stdout.readline())
logging.debug(f"XID {xid}")
logging.debug(f"PID {p.pid}")
keyboard = Gtk.Socket()
box.get_style_context().add_class("keyboard_matchbox")
box.pack_start(keyboard, True, True, 0)
self.base_panel.content.pack_end(box, False, False, 0)
self.show_all()
keyboard.add_id(xid)
self.keyboard = {
"box": box,
"process": p,
"socket": keyboard
}
return
return self._show_matchbox_keyboard(box)
if entry is None:
logging.debug("Error: no entry provided for keyboard")
return
@@ -949,6 +939,34 @@ class KlipperScreen(Gtk.Window):
self.base_panel.content.pack_end(box, False, False, 0)
self.base_panel.content.show_all()
def _show_matchbox_keyboard(self, box):
env = os.environ.copy()
usrkbd = os.path.expanduser("~/.matchbox/keyboard.xml")
if os.path.isfile(usrkbd):
env["MB_KBD_CONFIG"] = usrkbd
else:
env["MB_KBD_CONFIG"] = "ks_includes/locales/keyboard.xml"
p = subprocess.Popen(["matchbox-keyboard", "--xid"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
xid = int(p.stdout.readline())
logging.debug(f"XID {xid}")
logging.debug(f"PID {p.pid}")
keyboard = Gtk.Socket()
box.get_style_context().add_class("keyboard_matchbox")
box.pack_start(keyboard, True, True, 0)
self.base_panel.content.pack_end(box, False, False, 0)
self.show_all()
keyboard.add_id(xid)
self.keyboard = {
"box": box,
"process": p,
"socket": keyboard
}
return
def remove_keyboard(self, widget=None, event=None):
if self.keyboard is None:
return
@@ -964,6 +982,16 @@ class KlipperScreen(Gtk.Window):
elif keyval_name == "BackSpace" and len(self._cur_panels) > 1 and self.keyboard is None:
self.base_panel.back()
def update_size(self, *args):
self.width, self.height = self.get_size()
new_ratio = self.width / self.height
new_mode = new_ratio < 1.0
ratio_delta = abs(self.aspect_ratio - new_ratio)
if ratio_delta > 0.1 and self.vertical_mode != new_mode:
self.reload_panels()
self.vertical_mode = new_mode
self.aspect_ratio = new_ratio
def main():
version = functions.get_software_version()
+24 -13
View File
@@ -9,11 +9,11 @@ FBDEV="xserver-xorg-video-fbdev"
PYTHON="python3-virtualenv virtualenv python3-distutils"
PYGOBJECT="libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0"
MISC="librsvg2-common libopenjp2-7 libatlas-base-dev wireless-tools libdbus-glib-1-dev autoconf"
OPTIONAL="xserver-xorg-legacy fonts-nanum fonts-ipafont"
OPTIONAL="xserver-xorg-legacy fonts-nanum fonts-ipafont libmpv-dev"
# moonraker will check this list when updating
# if new packages are required for existing installs add them below too.
PKGLIST="libdbus-glib-1-dev autoconf fonts-ipafont"
PKGLIST="libdbus-glib-1-dev autoconf fonts-ipafont libmpv-dev"
Red='\033[0;31m'
Green='\033[0;32m'
@@ -43,7 +43,7 @@ install_packages()
echo_text "Checking for broken packages..."
output=$(dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | grep -E ^.[^nci])
if [ $? -eq 0 ]; then
echo_text "Detectected broken pacakges. Attempting to fix"
echo_text "Detected broken packages. Attempting to fix"
sudo apt-get -f install
output=$(dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | grep -E ^.[^nci])
if [ $? -eq 0 ]; then
@@ -73,16 +73,16 @@ install_packages()
fi
sudo apt-get install -y $PYTHON
if [ $? -eq 0 ]; then
echo_ok "Installed Python dependincies"
echo_ok "Installed Python dependencies"
else
echo_error "Installation of Python dependincies failed ($PYTHON)"
echo_error "Installation of Python dependencies failed ($PYTHON)"
exit 1
fi
sudo apt-get install -y $PYGOBJECT
if [ $? -eq 0 ]; then
echo_ok "Installed PyGobject dependincies"
echo_ok "Installed PyGobject dependencies"
else
echo_error "Installation of PyGobject dependincies failed ($PYGOBJECT)"
echo_error "Installation of PyGobject dependencies failed ($PYGOBJECT)"
exit 1
fi
sudo apt-get install -y $MISC
@@ -92,6 +92,10 @@ install_packages()
echo_error "Installation of Misc packages failed ($MISC)"
exit 1
fi
# ModemManager interferes with klipper comms
# on buster it's installed as a dependency of mpv
# it doesn't happen on bullseye
sudo systemctl mask ModemManager.service
}
create_virtualenv()
@@ -109,10 +113,16 @@ create_virtualenv()
source ${KSENV}/bin/activate
pip --disable-pip-version-check install -r ${KSPATH}/scripts/KlipperScreen-requirements.txt
if [ $? -gt 0 ]; then
echo "Error: pip install exited with status code $?"
echo "Unable to install dependencies, aborting install."
deactivate
exit 1
echo_error "Error: pip install exited with status code $?"
echo_text "Trying again with new tools..."
sudo apt-get install -y build-essential cmake
pip install --upgrade pip setuptools
pip install -r ${KSPATH}/scripts/KlipperScreen-requirements.txt
if [ $? -gt 0 ]; then
echo_error "Unable to install dependencies, aborting install."
deactivate
exit 1
fi
fi
deactivate
echo_ok "Virtual enviroment created"
@@ -143,7 +153,7 @@ modify_user()
update_x11()
{
if [ -e /etc/X11/Xwrapper.conf ]
if [ -e /etc/X11/Xwrapper.config ]
then
echo_text "Updating X11 Xwrapper"
sudo sed -i 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config
@@ -158,6 +168,7 @@ add_desktop_file()
DESKTOP=$(<$SCRIPTPATH/KlipperScreen.desktop)
mkdir -p $HOME/.local/share/applications/
echo "$DESKTOP" | tee $HOME/.local/share/applications/KlipperScreen.desktop > /dev/null
sudo cp $SCRIPTPATH/../styles/icon.svg /usr/share/icons/hicolor/scalable/apps/KlipperScreen.svg
}
start_KlipperScreen()
@@ -167,7 +178,7 @@ start_KlipperScreen()
sudo systemctl start KlipperScreen
}
if [ "$EUID" == 0 ]
then echo_error "Plaease do not run this script as root"
then echo_error "Please do not run this script as root"
exit 1
fi
install_packages
+5 -3
View File
@@ -1,7 +1,9 @@
jinja2==3.1.2
netifaces==0.11.0
requests==2.28.1
websocket-client==1.4.2
requests==2.28.2
websocket-client==1.5.1
pycairo==1.22.0
PyGObject==3.42.2
python-networkmanager==2.2
python-mpv==0.5.2
six==1.16.0
dbus-python==1.3.2
+1 -1
View File
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=KlipperScreen
GenericName=Touch screen GUI for Klipper via Moonraker
Icon=$HOME/KlipperScreen/styles/icon.svg
Icon=KlipperScreen
Exec=sh -c "$HOME/.KlipperScreen-env/bin/python $HOME/KlipperScreen/screen.py"
Terminal=false
Type=Application
+20 -2
View File
@@ -203,7 +203,12 @@ trough {
}
.action_bar {
/*border-right: 2px solid #444;*/
/* min-width: 4.5em; */
/* min-height: 4.5em; */
}
.title_bar {
min-height: 2em;
}
.content {
@@ -293,6 +298,10 @@ trough {
padding: 0 .5em;
}
.heater-grid-temp {
min-width: 8em;
}
.keyboard_box {
margin-top: 35px;
}
@@ -307,8 +316,17 @@ trough {
border-radius: 0.7em;
}
.message_popup_popover {
border: 0;
background-color: Transparent;
padding: 0;
}
.message_popup {
border-bottom: .1em solid white;
border: .1em solid white;
border-radius: 1em;
padding: 1em;
margin: 0;
}
.message_popup button{
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="24"
height="24"
viewBox="0 0 24 24"
id="svg4"
sodipodi:docname="light.svg"
inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)">
<metadata
id="metadata6">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
id="namedview6"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
showgrid="false"
inkscape:zoom="26"
inkscape:cx="12"
inkscape:cy="12"
inkscape:window-width="1920"
inkscape:window-height="1018"
inkscape:window-x="-6"
inkscape:window-y="-6"
inkscape:window-maximized="1"
inkscape:current-layer="svg4"
inkscape:document-rotation="0" />
<path
d="m 12,2 c 3.865993,0 7,3.1340068 7,7 0,2.38 -1.19,4.47 -3,5.74 V 17 c 0,0.552285 -0.447715,1 -1,1 H 9 C 8.4477153,18 8,17.552285 8,17 V 14.74 C 6.19,13.47 5,11.38 5,9 5,5.1340068 8.1340068,2 12,2 M 9,21 v -1 h 6 v 1 c 0,0.552285 -0.447715,1 -1,1 H 10 C 9.4477153,22 9,21.552285 9,21"
id="path2"
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:#e2e2e2;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;stop-color:#000000;stop-opacity:1"
sodipodi:nodetypes="cscsssscsccccsssc" />
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB