Change panel layout. Add title and move back button

This commit is contained in:
Jordan Ruthe 2020-12-02 14:35:28 -05:00
parent 6d71022dbf
commit 08a7057668
25 changed files with 283 additions and 188 deletions

View File

@ -1,5 +1,8 @@
## Changelog
#### 2020 12 02
* Change panel layout: Added Title, Back, Emergency Stop, and Home to panels.
#### 2020 11 28
* Add option for enable in menu for configuration. This can hide certain options
* Add Power panel to control power devices via moonraker

View File

@ -7,6 +7,7 @@ bed = 90
extruder = 220
[menu __main]
name: Main Menu
[menu __main homing]
name: Homing
@ -122,6 +123,9 @@ confirm:
Klipper will reboot
[menu __print]
name: Print Control
[menu __print temperature]
name: Temperature
icon: heat-up

View File

@ -165,10 +165,12 @@ class KlippyGtk:
return b
@staticmethod
def HomogeneousGrid():
def HomogeneousGrid(width=None, height=None):
g = Gtk.Grid()
g.set_row_homogeneous(True)
g.set_column_homogeneous(True)
if width != None and height != None:
g.set_size_request(width, height)
return g
@staticmethod

View File

@ -56,6 +56,14 @@ class KlipperScreenConfig:
return menu_items
def get_menu_name(self, menu="__main", subsection=""):
name = ("menu %s %s" % (menu, subsection)) if subsection != "" else ("menu %s" % menu)
logger.debug("Menu name: %s" % name)
if name not in self.config:
return False
return self.config[name].get('name')
def get_preheat_options(self):
index = "preheat "
items = [i[len(index):] for i in self.config.sections() if i.startswith(index)]

View File

@ -85,8 +85,8 @@ class Printer:
if data['device'] in self.power_devices:
self.power_devices[data['device']]['status'] = data['status']
def get_config_section_list(self):
return list(self.config)
def get_config_section_list(self, search=""):
return [i for i in list(self.config) if i.startswith(search)]
def get_config_section(self, section):
if section not in self.config:

View File

@ -1,18 +1,50 @@
import gi
import logging
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib
from ks_includes.KlippyGtk import KlippyGtk
from ks_includes.KlippyGcodes import KlippyGcodes
logger = logging.getLogger("KlipperScreen.ScreenPanel")
class ScreenPanel:
def __init__(self, screen):
title_spacing = 50
def __init__(self, screen, title, back=True):
self._screen = screen
self.lang = self._screen.lang
self._printer = screen.printer
self.labels = {}
self.layout = Gtk.Layout()
self.layout.set_size(self._screen.width, self._screen.height)
if back == True:
b = KlippyGtk.ButtonImage('back', None, None, 40, 40)
b.connect("clicked", self._screen._menu_go_back)
self.layout.put(b, 0, 0)
h = KlippyGtk.ButtonImage('home', None, None, 40, 40)
h.connect("clicked", self.menu_return, True)
self.layout.put(h, self._screen.width - 55, 0)
e = KlippyGtk.ButtonImage('emergency', None, None, 40, 40)
e.connect("clicked", self.emergency_stop)
self.layout.put(e, int(self._screen.width/4*3) - 20, 0)
self.title = Gtk.Label()
self.title.set_size_request(self._screen.width, self.title_spacing)
self.title.set_hexpand(True)
self.title.set_halign(Gtk.Align.CENTER)
self.title.set_valign(Gtk.Align.CENTER)
self.set_title(title)
self.layout.put(self.title, 0, 0)
self.content = Gtk.Box(spacing=0)
self.content.set_size_request(self._screen.width, self._screen.height - self.title_spacing)
self.layout.put(self.content, 0, self.title_spacing)
def initialize(self, panel_name):
# Create gtk items here
@ -22,8 +54,7 @@ class ScreenPanel:
self._screen._ws.klippy.emergency_stop()
def get(self):
# Return gtk item
return self.panel
return self.layout
def home(self, widget):
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
@ -31,9 +62,20 @@ class ScreenPanel:
def menu_item_clicked(self, widget, panel, item):
print("### Creating panel "+ item['panel'])
if "items" in item:
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], 1, False, items=item['items'])
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], item['name'],
1, False, items=item['items'])
return
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], 1, False)
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], item['name'],
1, False)
def menu_return(self, widget, home=False):
if home == False:
self._screen._menu_go_back()
return
self._screen._menu_go_home()
def set_title(self, title):
self.title.set_label(title)
def update_image_text(self, label, text):
if label in self.labels and 'l' in self.labels[label]:

View File

@ -15,7 +15,7 @@ class BedLevelPanel(ScreenPanel):
def initialize(self, menu):
_ = self.lang.gettext
self.screws = None
self.panel = KlippyGtk.HomogeneousGrid()
grid = KlippyGtk.HomogeneousGrid()
self.disabled_motors = False
screws = []
@ -68,10 +68,10 @@ class BedLevelPanel(ScreenPanel):
self.labels['br'] = KlippyGtk.ButtonImage("bed-level-b-r")
self.labels['br'].connect("clicked", self.go_to_position, self.screws[1])
self.panel.attach(self.labels['tl'], 1, 0, 1, 1)
self.panel.attach(self.labels['tr'], 2, 0, 1, 1)
self.panel.attach(self.labels['bl'], 1, 1, 1, 1)
self.panel.attach(self.labels['br'], 2, 1, 1, 1)
grid.attach(self.labels['tl'], 1, 0, 1, 1)
grid.attach(self.labels['tr'], 2, 0, 1, 1)
grid.attach(self.labels['bl'], 1, 1, 1, 1)
grid.attach(self.labels['br'], 2, 1, 1, 1)
self.labels['home'] = KlippyGtk.ButtonImage("home",_("Home All"),"color2")
self.labels['home'].connect("clicked", self.home)
@ -79,16 +79,14 @@ class BedLevelPanel(ScreenPanel):
self.labels['dm'] = KlippyGtk.ButtonImage("motor-off", _("Disable XY"), "color3")
self.labels['dm'].connect("clicked", self.disable_motors)
self.panel.attach(self.labels['home'], 0, 0, 1, 1)
self.panel.attach(self.labels['dm'], 0, 1, 1, 1)
grid.attach(self.labels['home'], 0, 0, 1, 1)
grid.attach(self.labels['dm'], 0, 1, 1, 1)
self.labels['estop'] = KlippyGtk.ButtonImage("decrease",_("Emergency Stop"),"color4")
self.labels['estop'].connect("clicked", self.emergency_stop)
self.panel.attach(self.labels['estop'], 3, 0, 1, 1)
grid.attach(self.labels['estop'], 3, 0, 1, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
self.panel.attach(b, 3, 1, 1, 1)
self.content.add(grid)
def go_to_position(self, widget, position):
logger.debug("Going to position: %s", position)

View File

@ -17,4 +17,5 @@ class ExamplePanel(ScreenPanel):
def initialize(self, panel_name):
_ = self.lang.gettext
# Create gtk items here
return
self.content.add(Gtk.Box())

View File

@ -91,14 +91,7 @@ class ExtrudePanel(ScreenPanel):
grid.attach(box, 1, 2, 2, 1)
b = KlippyGtk.ButtonImage("back", "Back")
b.connect("clicked", self._screen._menu_go_back)
grid.attach(b, 3, 2, 1, 1)
self.panel = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
def process_update(self, action, data):

View File

@ -50,13 +50,10 @@ class FanPanel(ScreenPanel):
grid.attach(Gtk.Label(), 0, 0, 1, 1)
grid.attach(box, 0, 1, 4, 1)
grid.attach(self.labels["fanoff"], 0, 2, 1, 1)
grid.attach(self.labels["fanon"], 1, 2, 1, 1)
grid.attach(self.labels["fanon"], 3, 2, 1, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
grid.attach(b,3,2,1,1)
self.panel = grid
self.grid = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
def process_update(self, action, data):
@ -71,14 +68,14 @@ class FanPanel(ScreenPanel):
return
self.user_selecting = True
self.panel.attach(self.labels["apply"], 3, 0, 1, 1)
self.panel.attach(self.labels["cancel"], 0, 0, 1, 1)
self.grid.attach(self.labels["apply"], 3, 0, 1, 1)
self.grid.attach(self.labels["cancel"], 0, 0, 1, 1)
self._screen.show_all()
def cancel_select_fan_speed(self, widget):
self.user_selecting = False
self.panel.remove(self.labels["apply"])
self.panel.remove(self.labels["cancel"])
self.grid.remove(self.labels["apply"])
self.grid.remove(self.labels["cancel"])
def set_fan_speed(self, widget):

View File

@ -30,12 +30,13 @@ class FineTunePanel(ScreenPanel):
_ = self.lang.gettext
grid = KlippyGtk.HomogeneousGrid()
grid.set_row_homogeneous(False)
logger.debug("FineTunePanel")
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", _("Z+"), "color1")
self.labels['z+'].connect("clicked", self.change_babystepping, "+")
self.labels['zoffset'] = Gtk.Label(_("Z Offset") + ": 0.00" + _("mm"))
self.labels['zoffset'] = Gtk.Label("0.00" + _("mm"))
self.labels['zoffset'].get_style_context().add_class('temperature_entry')
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", _("Z-"), "color1")
self.labels['z-'].connect("clicked", self.change_babystepping, "-")
@ -46,7 +47,7 @@ class FineTunePanel(ScreenPanel):
self.labels['fan+'] = KlippyGtk.ButtonImage("fan-on", _("Fan +"), "color2")
self.labels['fan+'].connect("clicked", self.change_fan, "+")
self.labels['fanspeed'] = Gtk.Label(_("Fan") + ": 100%")
self.labels['fanspeed'] = Gtk.Label("100%")
self.labels['fanspeed'].get_style_context().add_class('temperature_entry')
self.labels['fan-'] = KlippyGtk.ButtonImage("fan-off", _("Fan -"), "color2")
self.labels['fan-'].connect("clicked", self.change_fan, "-")
@ -56,7 +57,7 @@ class FineTunePanel(ScreenPanel):
self.labels['speed+'] = KlippyGtk.ButtonImage("speed-step", _("Speed +"), "color3")
self.labels['speed+'].connect("clicked", self.change_speed, "+")
self.labels['speedfactor'] = Gtk.Label(_("Speed") + ": 100%")
self.labels['speedfactor'] = Gtk.Label("100%")
self.labels['speedfactor'].get_style_context().add_class('temperature_entry')
self.labels['speed-'] = KlippyGtk.ButtonImage("speed-step", _("Speed -"), "color3")
self.labels['speed-'].connect("clicked", self.change_speed, "-")
@ -66,7 +67,7 @@ class FineTunePanel(ScreenPanel):
self.labels['extrude+'] = KlippyGtk.ButtonImage("extrude", _("Extrusion +"), "color4")
self.labels['extrude+'].connect("clicked", self.change_extrusion, "+")
self.labels['extrudefactor'] = Gtk.Label(_("Extrusion") + ": 100%")
self.labels['extrudefactor'] = Gtk.Label("100%")
self.labels['extrudefactor'].get_style_context().add_class('temperature_entry')
self.labels['extrude-'] = KlippyGtk.ButtonImage("retract", _("Extrusion -"), "color4")
self.labels['extrude-'].connect("clicked", self.change_extrusion, "-")
@ -114,16 +115,10 @@ class FineTunePanel(ScreenPanel):
self.labels["1"].set_active(True)
grid.attach(deltgrid, 1, 3, 2, 1)
grid.attach(deltgrid, 1, 3, 3, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
grid.attach(b,3,3,1,1)
self.panel = grid
#self.panel = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
def process_update(self, action, data):
@ -134,17 +129,17 @@ class FineTunePanel(ScreenPanel):
if "gcode_move" in data:
if "homing_origin" in data["gcode_move"]:
self.labels['zoffset'].set_text(_("Z Offset") + ": %.2fmm" % data["gcode_move"]["homing_origin"][2])
self.labels['zoffset'].set_text("%.2fmm" % data["gcode_move"]["homing_origin"][2])
if "extrude_factor" in data["gcode_move"]:
self.extrusion = int(data["gcode_move"]["extrude_factor"]*100)
self.labels['extrudefactor'].set_text(_("Extrusion") + ": %3d%%" % self.extrusion)
self.labels['extrudefactor'].set_text("%3d%%" % self.extrusion)
if "speed_factor" in data["gcode_move"]:
self.speed = int(data["gcode_move"]["speed_factor"]*100)
self.labels['speedfactor'].set_text(_("Speed") + ": %3d%%" % self.speed)
self.labels['speedfactor'].set_text("%3d%%" % self.speed)
if "fan" in data and "speed" in data['fan']:
self.fan = int(round(data['fan']['speed'],2)*100)
self.labels['fanspeed'].set_text(_("Fan") + ": %3d%%" % self.fan)
self.labels['fanspeed'].set_text("%3d%%" % self.fan)
def change_babystepping(self, widget, dir):
if dir == "+":

View File

@ -82,14 +82,14 @@ class JobStatusPanel(ScreenPanel):
self.labels['cancel'] = KlippyGtk.ButtonImage("stop",_("Cancel"),"color2")
self.labels['cancel'].connect("clicked", self.cancel)
grid.attach(self.labels['cancel'], 1, 2, 1, 1)
self.labels['estop'] = KlippyGtk.ButtonImage("decrease",_("Emergency Stop"),"color4")
self.labels['estop'] = KlippyGtk.ButtonImage("emergency",_("Emergency Stop"),"color4")
self.labels['estop'].connect("clicked", self.emergency_stop)
grid.attach(self.labels['estop'], 2, 2, 1, 1)
self.labels['control'] = KlippyGtk.ButtonImage("control",_("Control"),"color3")
self.labels['control'].connect("clicked", self._screen._go_to_submenu, "")
grid.attach(self.labels['control'], 3, 2, 1, 1)
self.panel = grid
self.layout = grid
self._screen.add_subscription(panel_name)
@ -148,7 +148,7 @@ class JobStatusPanel(ScreenPanel):
def process_update(self, action, data):
if action != "notify_status_update":
return
self.update_temp("heater_bed",
self._printer.get_dev_stat("heater_bed","temperature"),
self._printer.get_dev_stat("heater_bed","target")

View File

@ -15,17 +15,16 @@ def create_panel(*args):
return MenuPanel(*args)
class MenuPanel(ScreenPanel):
def initialize(self, panel_name, items):
def initialize(self, panel_name, display_name, items):
_ = self.lang.gettext
self.activate()
grid = self.arrangeMenuItems(items, 4)
grid.set_size_request(self._screen.width, self._screen.height-45)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
grid.attach(b, 3, 1, 1, 1)
self.panel = grid
self.content.add(grid)
self.panel = self.layout
def activate(self):
self.j2_data = {

View File

@ -94,19 +94,13 @@ class MovePanel(ScreenPanel):
grid.attach(box, 0, 2, 3, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
grid.attach(b, 3, 2, 1, 1)
self.panel = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
def process_update(self, action, data):
if action != "notify_status_update":
return
if "toolhead" in data and "position" in data["toolhead"]:
self.labels['pos_x'].set_text("X: %.2f" % (data["toolhead"]["position"][0]))
self.labels['pos_y'].set_text("Y: %.2f" % (data["toolhead"]["position"][1]))

View File

@ -16,7 +16,8 @@ def create_panel(*args):
class NetworkPanel(ScreenPanel):
def initialize(self, menu):
_ = self.lang.gettext
self.panel = KlippyGtk.HomogeneousGrid()
grid = KlippyGtk.HomogeneousGrid()
grid.set_hexpand(True)
# Get Hostname
stream = os.popen('hostname -A')
@ -31,9 +32,6 @@ class NetworkPanel(ScreenPanel):
_("Network Info") + "\n\n%s%s" % (hostname, ip)
)
self.labels['networkinfo'].get_style_context().add_class('temperature_entry')
self.panel.attach(self.labels['networkinfo'], 1, 0, 1, 1)
grid.attach(self.labels['networkinfo'], 1, 0, 1, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
self.panel.attach(b, 1, 1, 1, 1)
self.content.add(grid)

View File

@ -18,20 +18,6 @@ class PowerPanel(ScreenPanel):
_ = self.lang.gettext
self.devices = {}
# Create bottom bar
bar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
bar.set_hexpand(True)
bar.set_vexpand(False)
bar.set_halign(Gtk.Align.END)
bar.set_margin_top(5)
bar.set_margin_bottom(5)
bar.set_margin_end(5)
# Add a back button to the bottom bar
back = KlippyGtk.ButtonImage('back', None, None, 60, 60)
back.connect("clicked", self._screen._menu_go_back)
bar.add(back)
# Create a scroll window for the power devices
scroll = Gtk.ScrolledWindow()
scroll.set_property("overlay-scrolling", False)
@ -45,11 +31,11 @@ class PowerPanel(ScreenPanel):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
box.set_vexpand(True)
box.pack_start(scroll, True, True, 0)
box.pack_end(bar, False, False, 0)
self.load_power_devices()
self.panel = box
self.content.add(box)
self._screen.add_subscription(panel_name)
def add_device(self, device):

View File

@ -54,18 +54,14 @@ class PreheatPanel(ScreenPanel):
cooldown = KlippyGtk.ButtonImage('cool-down', _('Cooldown'))
cooldown.connect("clicked", self.set_temperature, "cooldown")
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
row = int(i/2) if i%2 == 0 else int(i/2)+1
self.labels["control_grid"].attach(cooldown, 0, row, 1, 1)
self.labels["control_grid"].attach(b, 1, row, 1, 1)
self.labels["control_grid"].attach(cooldown, i%2, int(i/2), 1, 1)
grid.attach(eq_grid, 0, 0, 1, 1)
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
self.panel = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)

View File

@ -27,24 +27,10 @@ class PrintPanel(ScreenPanel):
box.set_vexpand(True)
box.pack_start(scroll, True, True, 0)
bar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
bar.set_hexpand(True)
bar.set_vexpand(False)
bar.set_halign(Gtk.Align.END)
bar.set_margin_top(5)
bar.set_margin_bottom(5)
bar.set_margin_end(5)
refresh = KlippyGtk.ButtonImage('refresh', None, None, 60, 60)
refresh.connect("clicked", self.reload_files)
#bar.add(refresh)
back = KlippyGtk.ButtonImage('back', None, None, 60, 60)
back.connect("clicked", self._screen._menu_go_back)
bar.add(back)
box.pack_end(bar, False, False, 0)
self.labels['filelist'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.labels['filelist'].set_vexpand(True)
@ -57,8 +43,7 @@ class PrintPanel(ScreenPanel):
scroll.add(self.labels['filelist'])
self.panel = box
self.content.add(box)
self._screen.files.add_file_callback(self._callback)

View File

@ -27,6 +27,7 @@ class SplashScreenPanel(ScreenPanel):
self.labels['text'].get_style_context().add_class("text")
self.labels['text'].set_line_wrap(True)
self.labels['text'].set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
self.labels['text'].set_halign(Gtk.Align.CENTER)
self.labels['actions'] = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
@ -45,7 +46,7 @@ class SplashScreenPanel(ScreenPanel):
box = Gtk.VBox()
box.add(main)
self.panel = box
self.layout = box
def update_text(self, text):
self.labels['text'].set_text(text)

View File

@ -24,34 +24,22 @@ class SystemPanel(ScreenPanel):
restart.connect("clicked", self.restart_klippy)
firmrestart = KlippyGtk.ButtonImage('restart',_('Firmware Restart'),'color2')
firmrestart.connect("clicked", self.restart_klippy, "firmware")
back = KlippyGtk.ButtonImage('back', 'Back')
back.connect("clicked", self._screen._menu_go_back)
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
info.set_vexpand(True)
title = Gtk.Label(_("System Information"))
title.set_margin_bottom(5)
title.set_margin_top(15)
self.labels['loadavg'] = Gtk.Label("temp")
self.update_system_load()
self.system_timeout = GLib.timeout_add(1000, self.update_system_load)
title.get_style_context().add_class('temperature_entry')
self.labels['loadavg'].get_style_context().add_class('temperature_entry')
self.labels['klipper_version'] = Gtk.Label(_("Klipper Version") +
(": %s" % self._screen.printer.get_klipper_version()))
self.labels['klipper_version'].set_margin_top(15)
self.labels['klipper_version'].get_style_context().add_class('temperature_entry')
self.labels['ks_version'] = Gtk.Label(_("KlipperScreen Version") + (": %s" % self._screen.version))
self.labels['ks_version'].set_margin_top(15)
self.labels['ks_version'].get_style_context().add_class('temperature_entry')
info.add(title)
info.add(self.labels['loadavg'])
info.add(self.labels['klipper_version'])
info.add(self.labels['ks_version'])
@ -60,9 +48,8 @@ class SystemPanel(ScreenPanel):
grid.attach(info, 0, 0, 4, 2)
grid.attach(restart, 0, 2, 1, 1)
grid.attach(firmrestart, 1, 2, 1, 1)
grid.attach(back, 3, 2, 1, 1)
self.panel = grid
self.content.add(grid)
def update_system_load(self):
_ = self.lang.gettext

View File

@ -73,20 +73,20 @@ class TemperaturePanel(ScreenPanel):
self.labels["deg" + self.tempdelta].set_active(True)
self.labels["control_grid"].attach(tempgrid, 2, 0, 1, 2)
vbox = Gtk.VBox()
vbox.pack_start(Gtk.Label("Temp °C"), False, False, 4)
vbox.pack_end(tempgrid, True, True, 0)
self.labels["control_grid"].attach(vbox, 2, 0, 1, 3)
self.labels["control_grid"].attach(self.labels["increase"], 3, 0, 1, 1)
self.labels["control_grid"].attach(self.labels["decrease"], 3, 1, 1, 1)
self.labels["control_grid"].attach(self.labels["npad"], 2, 2, 1, 1)
b = KlippyGtk.ButtonImage('back', _('Back'))
b.connect("clicked", self._screen._menu_go_back)
self.labels["control_grid"].attach(b, 3, 2, 1, 1)
self.labels["control_grid"].attach(self.labels["npad"], 3, 2, 1, 1)
grid.attach(eq_grid, 0, 0, 1, 1)
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
self.panel = grid
self.grid = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
@ -158,15 +158,15 @@ class TemperaturePanel(ScreenPanel):
self.labels["keypad"] = numpad
self.panel.remove_column(1)
#self.panel.attach(self.labels["keypad"], 1, 0, 1, 1)
self.panel.attach(box, 1, 0, 1, 1)
self.panel.show_all()
self.grid.remove_column(1)
#self.grid.attach(self.labels["keypad"], 1, 0, 1, 1)
self.grid.attach(box, 1, 0, 1, 1)
self.grid.show_all()
def hide_numpad(self, widget):
self.panel.remove_column(1)
self.panel.attach(self.labels["control_grid"], 1, 0, 1, 1)
self.panel.show_all()
self.grid.remove_column(1)
self.grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
self.grid.show_all()
def select_heater (self, widget, heater):
@ -185,7 +185,7 @@ class TemperaturePanel(ScreenPanel):
def process_update(self, action, data):
if action != "notify_status_update":
return
self.update_temp("heater_bed",
self._printer.get_dev_stat("heater_bed","temperature"),
self._printer.get_dev_stat("heater_bed","target")

View File

@ -19,18 +19,21 @@ class ZCalibratePanel(ScreenPanel):
distance = 1
distances = ['.01','.05','.1','.5','1','5']
def __init__(self, screen, title, back=True):
super().__init__(screen, title, False)
def initialize(self, panel_name):
_ = self.lang.gettext
grid = KlippyGtk.HomogeneousGrid()
label = Gtk.Label(_("Z Offset") + ": ")
label.get_style_context().add_class('temperature_entry')
self.labels['zpos'] = Gtk.Label(_("Homing"))
self.labels['zpos'].get_style_context().add_class('temperature_entry')
box = Gtk.Box()
label = Gtk.Label(_("Z Offset") + ": \n")
self.labels['zposition'] = Gtk.Label(_("Homing"))
box = Gtk.VBox()
box.set_vexpand(False)
box.set_valign(Gtk.Align.CENTER)
box.add(label)
box.add(self.labels['zpos'])
box.add(self.labels['zposition'])
zpos = KlippyGtk.ButtonImage('z-offset-decrease',_("Raise Nozzle"))
zpos.connect("clicked", self.move, "+")
@ -57,13 +60,11 @@ class ZCalibratePanel(ScreenPanel):
self.labels["1"].set_active(True)
space_grid = KlippyGtk.HomogeneousGrid()
space_grid.set_row_homogeneous(False)
space_grid.attach(Gtk.Label(_("Distance (mm)") + ":"),0,0,1,1)
space_grid.attach(distgrid,0,1,1,1)
space_grid.attach(Gtk.Label(" "),0,2,1,1)
estop = KlippyGtk.ButtonImage("decrease",_("Emergency Stop"),"color4")
estop.connect("clicked", self.emergency_stop)
complete = KlippyGtk.ButtonImage('complete',_('Accept'),'color2')
complete.connect("clicked", self.accept)
@ -71,22 +72,23 @@ class ZCalibratePanel(ScreenPanel):
b.connect("clicked", self.abort)
grid.attach(zpos, 1, 0, 1, 1)
grid.attach(box, 0, 1, 2, 1)
grid.attach(zneg, 1, 1, 1, 1)
grid.attach(estop, 3, 0, 1, 1)
grid.attach(complete, 3, 1, 1, 1)
#grid.set_row_homogeneous(False)
grid.attach(zpos, 0, 0, 1, 1)
grid.attach(box, 1, 0, 2, 2)
grid.attach(zneg, 0, 1, 1, 1)
grid.attach(complete, 3, 0, 1, 1)
grid.attach(space_grid, 0, 2, 3, 1)
grid.attach(b, 3, 2, 1, 1)
self.panel = grid
self.content.add(grid)
self._screen.add_subscription(panel_name)
def activate(self):
if self._screen.printer.get_stat("toolhead","homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE)
#if self._screen.printer.get_stat("toolhead","homed_axes") != "xyz":
# self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
#self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE)
print("nothing")
def process_update(self, action, data):
if action != "notify_status_update":
@ -96,7 +98,7 @@ class ZCalibratePanel(ScreenPanel):
self.updatePosition(data['toolhead']['position'])
def updatePosition(self, position):
self.labels['zpos'].set_text(str(round(position[2],2)))
self.labels['zposition'].set_text(str(round(position[2],2)))
def change_distance(self, widget, distance):
if self.distance == distance:
@ -121,9 +123,9 @@ class ZCalibratePanel(ScreenPanel):
def abort(self, widget):
logger.info("Aborting Z calibrate")
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_ABORT)
self._screen._menu_go_back(widget)
self.menu_return(widget)
def accept(self, widget):
logger.info("Accepting Z calibrate")
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_ACCEPT)
self._screen._menu_go_back(widget)
self.menu_return(widget)

View File

@ -152,9 +152,9 @@ class KlipperScreen(Gtk.Window):
raise Exception(msg)
def show_panel(self, panel_name, type, remove=None, pop=True, **kwargs):
def show_panel(self, panel_name, type, title, remove=None, pop=True, **kwargs):
if panel_name not in self.panels:
self.panels[panel_name] = self._load_panel(type, self)
self.panels[panel_name] = self._load_panel(type, self, title)
try:
if kwargs != {}:
@ -227,14 +227,14 @@ class KlipperScreen(Gtk.Window):
menu = "__print"
logger.info("#### Menu " + str(menu))
#self.show_panel("_".join(self._cur_panels) + '_' + name, "menu", 1, False, menu=menu)
disname = self._config.get_menu_name(menu, name)
menuitems = self._config.get_menu_items(menu, name)
if len(menuitems) == 0:
logger.info("No items in menu, returning.")
return
self.show_panel(self._cur_panels[-1] + '_' + name, "menu", 1, False, items=menuitems)
self.show_panel(self._cur_panels[-1] + '_' + name, "menu", disname, 1, False, display_name=disname,
items=menuitems)
return
grid = self.arrangeMenuItems(menu, 4)
@ -250,27 +250,27 @@ class KlipperScreen(Gtk.Window):
def _remove_all_panels(self):
while len(self._cur_panels) > 0:
self._remove_current_panel()
self._remove_current_panel(True, False)
self.show_all()
def _remove_current_panel(self, pop=True):
def _remove_current_panel(self, pop=True, show=True):
if len(self._cur_panels) > 0:
self.remove(
self.panels[
self._cur_panels[-1]
].get()
)
self.remove(self.panels[self._cur_panels[-1]].get())
if pop == True:
self._cur_panels.pop()
if len(self._cur_panels) > 0:
self.add(self.panels[self._cur_panels[-1]].get())
self.show_all()
if show == True:
self.show_all()
def _menu_go_back (self, widget):
def _menu_go_back (self, widget=None):
logger.info("#### Menu go back")
self._remove_current_panel()
def _menu_go_home(self):
logger.info("#### Menu go home")
while len(self._cur_panels) > 1:
self._remove_current_panel()
def add_subscription (self, panel_name):
add = True
@ -366,7 +366,7 @@ class KlipperScreen(Gtk.Window):
def printer_initializing(self, text=None):
self.shutdown = True
self.show_panel('splash_screen',"splash_screen", 2)
self.show_panel('splash_screen',"splash_screen", "Splash Screen", 2)
if text != None:
self.panels['splash_screen'].update_text(text)
self.panels['splash_screen'].show_restart_buttons()
@ -410,7 +410,7 @@ class KlipperScreen(Gtk.Window):
if printer_info['result']['state'] == "shutdown":
if "FIRMWARE_RESTART" in printer_info['result']['state_message']:
self.printer_initializing(
_("Klipper has encountered an error. Issue a FIRMWARE_RESTART to attempt fixing the issue.")
_("Klipper has encountered an error.\nIssue a FIRMWARE_RESTART to attempt fixing the issue.")
)
else:
self.printer_initializing(_("Klipper has shutdown"))
@ -426,12 +426,13 @@ class KlipperScreen(Gtk.Window):
return
self.files.add_timeout()
self.show_panel('main_panel', "main_menu", 2, items=self._config.get_menu_items("__main"), extrudercount=self.printer.get_extruder_count())
self.show_panel('main_panel', "main_menu", "Main Menu", 2, items=self._config.get_menu_items("__main"),
extrudercount=self.printer.get_extruder_count())
def printer_printing(self):
self.ws_subscribe()
self.files.remove_timeout()
self.show_panel('job_status',"job_status", 2)
self.show_panel('job_status',"job_status", "Print Status", 2)
def get_software_version():
prog = ('git', '-C', os.path.dirname(__file__), 'describe', '--always',

View File

@ -19,6 +19,10 @@ scrollbar slider {
background-color: #404E57;
}
label {
color: white;
}
frame {
color: #fff;
border-bottom: 1px solid #444;

View File

@ -0,0 +1,99 @@
<?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"
sodipodi:docname="emergency.svg"
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
version="1.1"
id="svg4160"
viewBox="0 0 60.137677 60.776516"
height="60.776516"
width="60.13768">
<defs
id="defs4162">
<rect
id="rect35"
height="75.089285"
width="56.160714"
y="3.7185006"
x="-24.056441" />
</defs>
<sodipodi:namedview
inkscape:document-rotation="0"
inkscape:snap-global="false"
inkscape:snap-bbox="true"
inkscape:window-maximized="1"
inkscape:window-y="-11"
inkscape:window-x="-11"
inkscape:window-height="2066"
inkscape:window-width="3840"
showguides="false"
units="in"
showgrid="true"
inkscape:current-layer="layer1"
inkscape:document-units="px"
inkscape:cy="30.217279"
inkscape:cx="2.3098192"
inkscape:zoom="11.313709"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base">
<inkscape:grid
originy="-29.820954"
originx="-9.9771178"
id="grid4712"
type="xygrid" />
</sodipodi:namedview>
<metadata
id="metadata4165">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-3.5328446,2.2636422)"
style="display:inline"
inkscape:label="Move"
id="layer2"
inkscape:groupmode="layer">
<g
id="g46"
transform="translate(-6.0411758,-15.071814)">
<path
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 22.795553,16.619161 3.21242,-1.25 3.212421,1.25 v 47.687531 l -3.212421,0.892857 -3.21242,-0.892857 z"
id="rect4760-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<ellipse
style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#d40000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4508"
cx="39.64286"
cy="43.19643"
rx="29.040764"
ry="29.130053" />
</g>
<text
transform="translate(47.1875,-4.8214286)"
style="font-style:normal;font-weight:normal;font-size:53px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect35);fill:#d40000;fill-opacity:1;stroke:none;"
id="text33"
xml:space="preserve"><tspan
x="-26"
y="52.376338"><tspan
style="font-weight:bold;font-size:53px;fill:#d40000">!</tspan></tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB