增加自适应调平的选项菜单
This commit is contained in:
parent
16db05c9e2
commit
f08191bf06
@ -106,6 +106,11 @@ name: {{ gettext('More') }}
|
||||
icon: more-settings
|
||||
panel: settings
|
||||
|
||||
[menu __main more advanced]
|
||||
name: {{ gettext('Advanced') }}
|
||||
icon: advanced_setting
|
||||
panel: advanced
|
||||
|
||||
[menu __main more network]
|
||||
name: {{ gettext('Network') }}
|
||||
icon: network
|
||||
|
@ -47,3 +47,9 @@ class KlippyGcodes:
|
||||
f'RED={color[0]} GREEN={color[1]} BLUE={color[2]} WHITE={color[3]} '
|
||||
f'SYNC=0 TRANSMIT=1'
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def set_save_variables(name, value):
|
||||
if isinstance(value, str):
|
||||
value = f"'{value}'"
|
||||
return f'SAVE_VARIABLE VARIABLE={name} VALUE=\"{value}\"'
|
||||
|
43
panels/advanced.py
Normal file
43
panels/advanced.py
Normal file
@ -0,0 +1,43 @@
|
||||
import logging
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
class Panel(ScreenPanel):
|
||||
def __init__(self, screen, title):
|
||||
title = title or _("Advanced")
|
||||
super().__init__(screen, title)
|
||||
self.advanced = {}
|
||||
self.menu_list ={}
|
||||
self.advanced_options = [
|
||||
{"adaptive_leveling": {"section": "main", "name": _("Adaptive Bed Leveling"), "type": "binary",
|
||||
"tooltip": _("Leveling Only in the Actual Print Area"),
|
||||
"value": "True", "callback": self.set_adaptive_leveling}},
|
||||
]
|
||||
options = self.advanced_options
|
||||
self.labels['advanced_menu'] = self._gtk.ScrolledWindow()
|
||||
self.labels['advanced'] = Gtk.Grid()
|
||||
self.labels['advanced_menu'].add(self.labels['advanced'])
|
||||
for option in options:
|
||||
name = list(option)[0]
|
||||
res = self.add_option('advanced', self.advanced, name, option[name])
|
||||
self.menu_list.update(res)
|
||||
self.content.add(self.labels['advanced_menu'])
|
||||
|
||||
def set_adaptive_leveling(self, *args):
|
||||
enable_adaptive_leveling = any(args)
|
||||
script_value = True if enable_adaptive_leveling else False
|
||||
script = KlippyGcodes.set_save_variables("adaptive_meshing", script_value)
|
||||
self._screen._send_action(None, "printer.gcode.script", {"script": script})
|
||||
logging.info(f"Set adaptive leveling: {script_value}")
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
if 'save_variables' in data and 'variables' in data['save_variables']:
|
||||
variables = data['save_variables']['variables']
|
||||
if 'adaptive_meshing' in variables:
|
||||
self.menu_list['adaptive_leveling'].set_active(variables['adaptive_meshing'])
|
@ -273,6 +273,7 @@ class KlipperScreen(Gtk.Window):
|
||||
"exclude_object": ["current_object", "objects", "excluded_objects"],
|
||||
"manual_probe": ['is_active'],
|
||||
"screws_tilt_adjust": ['results', 'error'],
|
||||
"save_variables": ['variables'],
|
||||
}
|
||||
}
|
||||
for extruder in self.printer.get_tools():
|
||||
@ -1072,6 +1073,7 @@ class KlipperScreen(Gtk.Window):
|
||||
'firmware_retraction',
|
||||
'exclude_object',
|
||||
'manual_probe',
|
||||
'save_variables',
|
||||
*self.printer.get_tools(),
|
||||
*self.printer.get_heaters(),
|
||||
*self.printer.get_temp_sensors(),
|
||||
|
14
styles/dark/images/advanced_setting.svg
Normal file
14
styles/dark/images/advanced_setting.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_2055_553)">
|
||||
<path d="M34.2857 40H5.7143C4.19877 40 2.74532 39.398 1.67368 38.3263C0.60204 37.2547 0 35.8012 0 34.2857L0 5.7143C0 4.19877 0.60204 2.74532 1.67368 1.67368C2.74532 0.60204 4.19877 0 5.7143 0L34.2857 0C35.8012 0 37.2547 0.60204 38.3263 1.67368C39.398 2.74532 40 4.19877 40 5.7143V34.2857C40 35.8012 39.398 37.2547 38.3263 38.3263C37.2547 39.398 35.8012 40 34.2857 40ZM5.7143 34.2857H28.5714V31.4286H5.7143V34.2857ZM5.7143 25.7143H34.2857V22.8571H5.7143V25.7143ZM17.1429 5.7143H5.7143V8.57145H17.1429V5.7143ZM34.2857 14.2857H5.7143V17.1429H34.2857V14.2857Z" fill="url(#paint0_linear_2055_553)"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2055_553" x1="20" y1="0" x2="20" y2="40" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.095" stop-color="#F5F5F5"/>
|
||||
<stop offset="0.93" stop-color="#A5A2A3"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_2055_553">
|
||||
<rect width="40" height="40" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
9
styles/light/images/advanced_setting.svg
Normal file
9
styles/light/images/advanced_setting.svg
Normal file
@ -0,0 +1,9 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15 0H2.5C0.999999 0 -5.85938e-08 1 0 2.5V22.5C0 24 1 25 2.5 25H15C16.5 25 17.5 24 17.5 22.5V2.5C17.5 0.999999 16.5 -5.85938e-08 15 0ZM37.5 15H25C23.5 15 22.5 16.25 22.5 17.75V37.25C22.5 38.75 23.5 40 25 40H37.5C39 40 40 38.75 40 37.25V17.75C40 16.25 39 15 37.5 15ZM15 30H2.5C0.999999 30 -5.85938e-08 31 0 32.5V37.5C0 39 1 40 2.5 40H15C16.5 40 17.5 39 17.5 37.5V32.5C17.5 31 16.5 30 15 30ZM37.5 0H25C23.5 0 22.5 1 22.5 2.5V7.5C22.5 9 23.5 10 25 10H37.5C39 10 40 9 40 7.5V2.5C40 0.999999 39 -5.85938e-08 37.5 0Z" fill="url(#paint0_linear_2109_548)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2109_548" x1="20" y1="0" x2="20" y2="40" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#7EB6FF"/>
|
||||
<stop offset="1" stop-color="#2570EC"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 871 B |
Loading…
x
Reference in New Issue
Block a user