Support hiding by name using underscore (#437)

This commit is contained in:
Alfredo Monclus 2022-01-13 13:09:06 -03:00 committed by GitHub
parent 6b043d63bc
commit 8c489bc465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 1 deletions

31
docs/Quicktips.md Normal file
View File

@ -0,0 +1,31 @@
# Quicktips
quick tips, without much explanation
### Hide macros, outputs or fans
As you probably already noticed, you can show and hide the gcode macros in the interface settings, but there is more…
Did you know, that you can also hide gcode macros by prefixing the name with an underscore?
```
[gcode_macro MY_AWESOME_GCODE]
gcode:
_MY_HELPER_CODE
[gcode_macro _MY_HELPER_CODE]
gcode:
M300
```
MY_AWESOME_GCODE appears in your interface settings, _MY_HELPER_CODE not.
Another example:
Lets hide a temperature_fan:
```
[temperature_fan fan1]
[temperature_fan _fan2]
```
fan1 will show in the interface, but _fan2 will be hidden.

View File

@ -139,6 +139,10 @@ class FanPanel(ScreenPanel):
def load_fans(self):
fans = self._printer.get_fans()
for fan in fans:
# Support for hiding devices by name
name = " ".join(fan.split(" ")[1:]) if not (fan == "fan") else fan
if name.startswith("_"):
continue
self.add_fan(fan)
def set_fan_speed(self, widget, fan):

View File

@ -37,7 +37,9 @@ class MacroPanel(ScreenPanel):
self.load_gcode_macros()
def add_gcode_macro(self, macro):
# Support for hiding macros by name
if macro.startswith("_"):
return
frame = Gtk.Frame()
frame.set_property("shadow-type", Gtk.ShadowType.NONE)
frame.get_style_context().add_class("frame-item")

View File

@ -44,6 +44,9 @@ class SettingsPanel(ScreenPanel):
for macro in self._printer.get_config_section_list("gcode_macro "):
macro = macro[12:]
# Support for hiding macros by name
if macro.startswith("_"):
continue
self.macros[macro] = {
"name": macro,
"section": "displayed_macros %s" % self._screen.connected_printer,

View File

@ -235,6 +235,9 @@ class TemperaturePanel(ScreenPanel):
if not (device.startswith("extruder") or device.startswith("heater_bed")):
devname = " ".join(device.split(" ")[1:])
# Support for hiding devices by name
if devname.startswith("_"):
return
else:
devname = device