printer_select: support custom icons #1240
This commit is contained in:
parent
4588ed537a
commit
3d241cecb4
@ -1,6 +1,19 @@
|
||||
# Theming
|
||||
|
||||
To create a custom theme, create a folder in: _${KlipperScreen_Directory}/styles/_
|
||||
## Custom printer select icons
|
||||
|
||||
When multiple printers are configured, their icons can be customized by placing an icon in:
|
||||
|
||||
_${KlipperScreen_Directory}/styles/printers/_
|
||||
|
||||
* The name of the icon must be the exact printer name configured in KlipperScreen.conf
|
||||
* The format should be svg or png.
|
||||
|
||||
## Custom themes
|
||||
|
||||
To create a custom theme, create a folder in:
|
||||
|
||||
_${KlipperScreen_Directory}/styles/_
|
||||
|
||||
The folder name will be the theme name, in that folder create another folder named `images` this is where the icons should be placed.
|
||||
The icons must be SVG files with specific names that are defined in the code, use the default theme as a reference for the names or check the code.
|
||||
|
@ -4,6 +4,7 @@ gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
from ks_includes.widgets.autogrid import AutoGrid
|
||||
from ks_includes.KlippyGtk import find_widget
|
||||
|
||||
|
||||
class Panel(ScreenPanel):
|
||||
@ -14,7 +15,13 @@ class Panel(ScreenPanel):
|
||||
printer_buttons = []
|
||||
for i, printer in enumerate(printers):
|
||||
name = list(printer)[0]
|
||||
self.labels[name] = self._gtk.Button("printer", name, f"color{1 + i % 4}", scale=2)
|
||||
scale = 3
|
||||
self.labels[name] = self._gtk.Button("printer", name, f"color{1 + i % 4}", scale=scale)
|
||||
scale *= self._gtk.img_scale
|
||||
pixbuf = self._gtk.PixbufFromIcon(f"../../printers/{name}", scale, scale)
|
||||
if pixbuf is not None:
|
||||
image = find_widget(self.labels[name], Gtk.Image)
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
self.labels[name].connect("clicked", self.connect_printer, name)
|
||||
printer_buttons.append(self.labels[name])
|
||||
grid = AutoGrid(printer_buttons, vertical=self._screen.vertical_mode)
|
||||
|
7
styles/printers/readme.md
Normal file
7
styles/printers/readme.md
Normal file
@ -0,0 +1,7 @@
|
||||
In this folder add the images for the printer selection screen when using multiple printers
|
||||
|
||||
** No images will be provided from the main repo **
|
||||
|
||||
1. Supported formats: SVG (preferred) or PNG
|
||||
2. The name of the image should be exactly equal to the printer name
|
||||
|
Loading…
x
Reference in New Issue
Block a user