UI scaling (#28)
* Initial UI scaling commit * temperature: updates to styling * screen: fix dialog creation * bed_level: scale images * job_status: updates to scaling
This commit is contained in:
parent
ea465b0f4d
commit
238badb110
@ -1,30 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
|
||||
import os
|
||||
klipperscreendir = os.getcwd()
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.KlippyGtk")
|
||||
|
||||
class KlippyGtk:
|
||||
labels = {}
|
||||
font_ratio = 51
|
||||
width_ratio = 16
|
||||
height_ratio = 9.375
|
||||
|
||||
@staticmethod
|
||||
def Label(label, style):
|
||||
def __init__(self, width, height):
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
self.font_size = int(round(self.width / self.font_ratio))
|
||||
self.header_size = int(round((self.width / self.width_ratio) / 1.33))
|
||||
self.img_width = int(round(self.width / self.width_ratio))
|
||||
self.img_height = int(round(self.height / self.height_ratio))
|
||||
self.header_image_scale_width = .625
|
||||
self.header_image_scale_height = .625
|
||||
|
||||
logger.debug("img width: %s height: %s" % (self.img_width, self.img_height))
|
||||
|
||||
def get_header_size(self):
|
||||
return self.header_size
|
||||
|
||||
def get_header_image_scale(self):
|
||||
return [self.header_image_scale_width, self.header_image_scale_height]
|
||||
|
||||
def get_image_width(self):
|
||||
return self.img_width
|
||||
|
||||
def get_image_height(self):
|
||||
return self.img_height
|
||||
|
||||
def get_font_size(self):
|
||||
return self.font_size
|
||||
|
||||
def Label(self, label, style):
|
||||
l = Gtk.Label(label)
|
||||
if style != False:
|
||||
l.get_style_context().add_class(style)
|
||||
return l
|
||||
|
||||
@staticmethod
|
||||
def ImageLabel(image_name, text, size=20, style=False):
|
||||
def ImageLabel(self, image_name, text, size=20, style=False, width_scale=.32, height_scale=.32):
|
||||
box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||
image = Gtk.Image()
|
||||
#TODO: update file reference
|
||||
image.set_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
"%s/styles/z-bolt/images/%s.svg" % (klipperscreendir, str(image_name)),
|
||||
int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg", 20, 20, True)
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
image = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_text(text)
|
||||
@ -37,35 +68,26 @@ class KlippyGtk:
|
||||
|
||||
return {"l": label, "b": box1}
|
||||
|
||||
@staticmethod
|
||||
def Image(image_name, style=False, width=None, height=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
def Image(self, image_name, style=False, width_scale=1, height_scale=1):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
"%s/styles/z-bolt/images/%s.svg" % (klipperscreendir, str(image_name)),
|
||||
int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def ImageFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
def ImageFromFile(self, filename, style=False, width_scale=1, height_scale=1):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename,
|
||||
int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def PixbufFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
def PixbufFromFile(self, filename, style=False, width_scale=1, height_scale=1):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, int(round(self.img_width * width_scale)),
|
||||
int(round(self.img_height * height_scale)), True)
|
||||
|
||||
return pixbuf
|
||||
|
||||
@staticmethod
|
||||
def ProgressBar(style=False):
|
||||
def ProgressBar(self, style=False):
|
||||
bar = Gtk.ProgressBar()
|
||||
|
||||
if style != False:
|
||||
@ -74,8 +96,7 @@ class KlippyGtk:
|
||||
|
||||
return bar
|
||||
|
||||
@staticmethod
|
||||
def Button(label=None, style=None):
|
||||
def Button(self, label=None, style=None):
|
||||
b = Gtk.Button(label=label)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
@ -87,13 +108,14 @@ class KlippyGtk:
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def ButtonImage(image_name, label=None, style=None, height=None, width=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
def ButtonImage(self, image_name, label=None, style=None, width_scale=1, height_scale=1):
|
||||
filename = "%s/styles/z-bolt/images/%s.svg" % (klipperscreendir, str(image_name))
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filename,
|
||||
int(round(self.img_width * width_scale)),
|
||||
int(round(self.img_height * height_scale)),
|
||||
True
|
||||
)
|
||||
|
||||
img = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@ -111,8 +133,7 @@ class KlippyGtk:
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def Dialog(screen, buttons, content, callback=None, *args):
|
||||
def Dialog(self, screen, buttons, content, callback=None, *args):
|
||||
dialog = Gtk.Dialog()
|
||||
dialog.set_default_size(screen.width - 15, screen.height - 15)
|
||||
dialog.set_resizable(False)
|
||||
@ -144,9 +165,16 @@ class KlippyGtk:
|
||||
return dialog, grid
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ToggleButtonImage(image_name, label, style=False):
|
||||
img = Gtk.Image.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
def ToggleButtonImage(self, image_name, label, style=False, width_scale=1, height_scale=1):
|
||||
filename = "%s/styles/z-bolt/images/%s.svg" % (klipperscreendir, str(image_name))
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filename,
|
||||
int(round(self.img_width * width_scale)),
|
||||
int(round(self.img_height * height_scale)),
|
||||
True
|
||||
)
|
||||
|
||||
img = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
b = Gtk.ToggleButton(label=label)
|
||||
#b.props.relief = Gtk.RELIEF_NONE
|
||||
@ -164,8 +192,7 @@ class KlippyGtk:
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def HomogeneousGrid(width=None, height=None):
|
||||
def HomogeneousGrid(self, width=None, height=None):
|
||||
g = Gtk.Grid()
|
||||
g.set_row_homogeneous(True)
|
||||
g.set_column_homogeneous(True)
|
||||
@ -173,16 +200,14 @@ class KlippyGtk:
|
||||
g.set_size_request(width, height)
|
||||
return g
|
||||
|
||||
@staticmethod
|
||||
def ToggleButton(text):
|
||||
def ToggleButton(self, text):
|
||||
b = Gtk.ToggleButton(text)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def formatFileName(name):
|
||||
def formatFileName(self, name):
|
||||
name = name.split('/')[-1] if "/" in name else name
|
||||
name = name.split('.gcod')[0] if ".gcode" in name else name
|
||||
if len(name) > 25:
|
||||
@ -190,8 +215,7 @@ class KlippyGtk:
|
||||
return name
|
||||
|
||||
|
||||
@staticmethod
|
||||
def formatTimeString(seconds):
|
||||
def formatTimeString(self, seconds):
|
||||
time = int(seconds)
|
||||
text = ""
|
||||
if int(time/3600) !=0:
|
||||
@ -199,8 +223,7 @@ class KlippyGtk:
|
||||
text += str(int(time/60)%60)+"m "+str(time%60)+"s"
|
||||
return text
|
||||
|
||||
@staticmethod
|
||||
def formatTemperatureString(temp, target):
|
||||
def formatTemperatureString(self, temp, target):
|
||||
if (target > temp-2 and target < temp+2) or round(target,0) == 0:
|
||||
return str(round(temp,2)) + "°C" #°C →"
|
||||
return str(round(temp)) + " → " + str(round(target)) + "°C"
|
||||
|
@ -42,6 +42,9 @@ class KlipperScreenConfig:
|
||||
logger.info("Found configuration file at: %s" % file)
|
||||
return file
|
||||
|
||||
def get_main_config(self):
|
||||
return self.config['main']
|
||||
|
||||
def get_main_config_option(self, option, default=None):
|
||||
return self.config['main'].get(option, default)
|
||||
|
||||
|
@ -18,22 +18,26 @@ class ScreenPanel:
|
||||
self.lang = self._screen.lang
|
||||
self._printer = screen.printer
|
||||
self.labels = {}
|
||||
self._gtk = screen.gtk
|
||||
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
|
||||
button_scale = self._gtk.get_header_image_scale()
|
||||
logger.debug("Button scale: %s" % button_scale)
|
||||
if back == True:
|
||||
self.control['back'] = KlippyGtk.ButtonImage('back', None, None, 40, 40)
|
||||
self.control['back'] = self._gtk.ButtonImage('back', None, None, button_scale[0], button_scale[1])
|
||||
self.control['back'].connect("clicked", self._screen._menu_go_back)
|
||||
self.layout.put(self.control['back'], 0, 0)
|
||||
|
||||
self.control['home'] = KlippyGtk.ButtonImage('home', None, None, 40, 40)
|
||||
self.control['home'] = self._gtk.ButtonImage('home', None, None, button_scale[0], button_scale[1])
|
||||
self.control['home'].connect("clicked", self.menu_return, True)
|
||||
self.layout.put(self.control['home'], self._screen.width - 55, 0)
|
||||
self.layout.put(self.control['home'], self._screen.width - round(
|
||||
self._gtk.get_image_width() * button_scale[0] * 1.45), 0)
|
||||
|
||||
self.control['estop'] = KlippyGtk.ButtonImage('emergency', None, None, 40, 40)
|
||||
self.control['estop'] = self._gtk.ButtonImage('emergency', None, None, button_scale[0], button_scale[1])
|
||||
self.control['estop'].connect("clicked", self.emergency_stop)
|
||||
self.layout.put(self.control['estop'], int(self._screen.width/4*3) - 20, 0)
|
||||
self.layout.put(self.control['estop'], int(self._screen.width/4*3 - button_scale[0]/2), 0)
|
||||
|
||||
self.title = Gtk.Label()
|
||||
self.title.set_size_request(self._screen.width, self.title_spacing)
|
||||
@ -85,4 +89,4 @@ class ScreenPanel:
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
|
@ -6,7 +6,6 @@ gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.BedLevelPanel")
|
||||
@ -22,7 +21,7 @@ class BedLevelPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
self.panel_name = panel_name
|
||||
self.screws = None
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
self.disabled_motors = False
|
||||
|
||||
screws = []
|
||||
@ -82,13 +81,13 @@ class BedLevelPanel(ScreenPanel):
|
||||
logger.debug("Configured screw locations [x,y]: %s", screws)
|
||||
|
||||
|
||||
self.labels['bl'] = KlippyGtk.ButtonImage("bed-level-t-l", None, None, )
|
||||
self.labels['bl'] = self._gtk.ButtonImage("bed-level-t-l", None, None, 3, 3)
|
||||
self.labels['bl'].connect("clicked", self.go_to_position, self.screws[2])
|
||||
self.labels['br'] = KlippyGtk.ButtonImage("bed-level-t-r")
|
||||
self.labels['br'] = self._gtk.ButtonImage("bed-level-t-r", None, None, 3, 3)
|
||||
self.labels['br'].connect("clicked", self.go_to_position, self.screws[3])
|
||||
self.labels['fl'] = KlippyGtk.ButtonImage("bed-level-b-l")
|
||||
self.labels['fl'] = self._gtk.ButtonImage("bed-level-b-l", None, None, 3, 3)
|
||||
self.labels['fl'].connect("clicked", self.go_to_position, self.screws[0])
|
||||
self.labels['fr'] = KlippyGtk.ButtonImage("bed-level-b-r")
|
||||
self.labels['fr'] = self._gtk.ButtonImage("bed-level-b-r", None, None, 3, 3)
|
||||
self.labels['fr'].connect("clicked", self.go_to_position, self.screws[1])
|
||||
|
||||
grid.attach(self.labels['bl'], 1, 0, 1, 1)
|
||||
@ -96,17 +95,17 @@ class BedLevelPanel(ScreenPanel):
|
||||
grid.attach(self.labels['fl'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['fr'], 2, 1, 1, 1)
|
||||
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home",_("Home All"),"color2")
|
||||
self.labels['home'] = self._gtk.ButtonImage("home",_("Home All"),"color2")
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
self.labels['dm'] = KlippyGtk.ButtonImage("motor-off", _("Disable XY"), "color3")
|
||||
self.labels['dm'] = self._gtk.ButtonImage("motor-off", _("Disable XY"), "color3")
|
||||
self.labels['dm'].connect("clicked", self.disable_motors)
|
||||
|
||||
grid.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
grid.attach(self.labels['dm'], 0, 1, 1, 1)
|
||||
|
||||
if self._printer.config_section_exists("screws_tilt_adjust"):
|
||||
self.labels['screws'] = KlippyGtk.ButtonImage("refresh",_("Screws Adjust"),"color4")
|
||||
self.labels['screws'] = self._gtk.ButtonImage("refresh",_("Screws Adjust"),"color4")
|
||||
self.labels['screws'].connect("clicked", self.screws_tilt_calculate)
|
||||
grid.attach(self.labels['screws'], 3, 0, 1, 1)
|
||||
|
||||
|
@ -4,7 +4,6 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -71,25 +70,25 @@ class BedMeshPanel(ScreenPanel):
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
load = KlippyGtk.ButtonImage("load",None,"color2")
|
||||
load = self._gtk.ButtonImage("load","Load","color2")
|
||||
load.connect("clicked", self.send_load_mesh, profile)
|
||||
load.set_size_request(60,0)
|
||||
load.set_hexpand(False)
|
||||
load.set_halign(Gtk.Align.END)
|
||||
|
||||
refresh = KlippyGtk.ButtonImage("refresh",None,"color4")
|
||||
refresh = self._gtk.ButtonImage("refresh","Calibrate","color4")
|
||||
refresh.connect("clicked", self.calibrate_mesh)
|
||||
refresh.set_size_request(60,0)
|
||||
refresh.set_hexpand(False)
|
||||
refresh.set_halign(Gtk.Align.END)
|
||||
|
||||
info = KlippyGtk.ButtonImage("info",None,"color3")
|
||||
info = self._gtk.ButtonImage("info",None,"color3")
|
||||
info.connect("clicked", self.show_mesh, profile)
|
||||
info.set_size_request(60,0)
|
||||
info.set_hexpand(False)
|
||||
info.set_halign(Gtk.Align.END)
|
||||
|
||||
save = KlippyGtk.ButtonImage("sd",None,"color3")
|
||||
save = self._gtk.ButtonImage("sd","Save","color3")
|
||||
save.connect("clicked", self.send_save_mesh, profile)
|
||||
save.set_size_request(60,0)
|
||||
save.set_hexpand(False)
|
||||
@ -153,7 +152,6 @@ class BedMeshPanel(ScreenPanel):
|
||||
def process_update(self, action, data):
|
||||
if action == "notify_status_update":
|
||||
if "bed_mesh" in data and "profile_name" in data['bed_mesh']:
|
||||
logger.debug("bed_mesh: %s" % data)
|
||||
if data['bed_mesh']['profile_name'] != self.active_mesh:
|
||||
self.activate_mesh(data['bed_mesh']['profile_name'])
|
||||
|
||||
@ -173,7 +171,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
buttons = [
|
||||
{"name": _("Close"), "response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
dialog = KlippyGtk.Dialog(self._screen, buttons, self.graphs[profile], self._close_dialog)
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, self.graphs[profile], self._close_dialog)
|
||||
|
||||
def _close_dialog(self, widget, response):
|
||||
widget.destroy()
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -28,15 +27,15 @@ class ExtrudePanel(ScreenPanel):
|
||||
_("Fast"): "1400"
|
||||
}
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
self.labels['tool0'] = KlippyGtk.ButtonImage("extruder-1",_("Tool 1"),"color1")
|
||||
self.labels['tool0'] = self._gtk.ButtonImage("extruder-1",_("Tool 1"),"color1")
|
||||
self.labels['tool0'].get_style_context().add_class("button_active")
|
||||
self.labels['extrude'] = KlippyGtk.ButtonImage("extrude",_("Extrude"),"color3")
|
||||
self.labels['extrude'] = self._gtk.ButtonImage("extrude",_("Extrude"),"color3")
|
||||
self.labels['extrude'].connect("clicked", self.extrude, "+")
|
||||
self.labels['retract'] = KlippyGtk.ButtonImage("retract",_("Retract"),"color2")
|
||||
self.labels['retract'] = self._gtk.ButtonImage("retract",_("Retract"),"color2")
|
||||
self.labels['retract'].connect("clicked", self.extrude, "-")
|
||||
self.labels['temperature'] = KlippyGtk.ButtonImage("heat-up",_("Temperature"),"color4")
|
||||
self.labels['temperature'] = self._gtk.ButtonImage("heat-up",_("Temperature"),"color4")
|
||||
self.labels['temperature'].connect("clicked", self.menu_item_clicked, "temperature", {
|
||||
"name": "Temperature",
|
||||
"panel": "temperature"
|
||||
@ -52,7 +51,7 @@ class ExtrudePanel(ScreenPanel):
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.distances:
|
||||
self.labels["dist"+str(i)] = KlippyGtk.ToggleButton(i)
|
||||
self.labels["dist"+str(i)] = self._gtk.ToggleButton(i)
|
||||
self.labels["dist"+str(i)].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels["dist"+str(i)].get_style_context()
|
||||
if j == 0:
|
||||
@ -70,7 +69,7 @@ class ExtrudePanel(ScreenPanel):
|
||||
speedgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.speeds:
|
||||
self.labels["speed"+str(i)] = KlippyGtk.ToggleButton(i)
|
||||
self.labels["speed"+str(i)] = self._gtk.ToggleButton(i)
|
||||
self.labels["speed"+str(i)].connect("clicked", self.change_speed, i)
|
||||
ctx = self.labels["speed"+str(i)].get_style_context()
|
||||
if j == 0:
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -20,7 +19,7 @@ class FanPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
box.set_hexpand(True)
|
||||
@ -33,17 +32,17 @@ class FanPanel(ScreenPanel):
|
||||
self.labels["scale"].get_style_context().add_class("fan_slider")
|
||||
box.add(self.labels["scale"])
|
||||
|
||||
self.labels["fanoff"] = KlippyGtk.ButtonImage("fan-off", _("Fan Off"))
|
||||
self.labels["fanoff"] = self._gtk.ButtonImage("fan-off", _("Fan Off"))
|
||||
self.labels["fanoff"].get_style_context().add_class("color1")
|
||||
self.labels["fanoff"].connect("clicked", self.set_fan_on, False)
|
||||
self.labels["fanon"] = KlippyGtk.ButtonImage("fan", _("Fan On"))
|
||||
self.labels["fanon"] = self._gtk.ButtonImage("fan", _("Fan On"))
|
||||
self.labels["fanon"].get_style_context().add_class("color3")
|
||||
self.labels["fanon"].connect("clicked", self.set_fan_on, True)
|
||||
|
||||
self.labels["apply"] = KlippyGtk.ButtonImage("resume", _("Set Speed"))
|
||||
self.labels["apply"] = self._gtk.ButtonImage("resume", _("Set Speed"))
|
||||
self.labels["apply"].get_style_context().add_class("color2")
|
||||
self.labels["apply"].connect("clicked", self.set_fan_speed)
|
||||
self.labels["cancel"] = KlippyGtk.ButtonImage("stop", _("Cancel Change"))
|
||||
self.labels["cancel"] = self._gtk.ButtonImage("stop", _("Cancel Change"))
|
||||
self.labels["cancel"].get_style_context().add_class("color4")
|
||||
self.labels["cancel"].connect("clicked", self.cancel_select_fan_speed)
|
||||
self.labels["cancel"].hide()
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -29,37 +28,37 @@ class FineTunePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
grid.set_row_homogeneous(False)
|
||||
logger.debug("FineTunePanel")
|
||||
|
||||
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", _("Z+"), "color1")
|
||||
self.labels['z+'] = self._gtk.ButtonImage("move-z-", _("Z+"), "color1")
|
||||
self.labels['z+'].connect("clicked", self.change_babystepping, "+")
|
||||
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-'] = self._gtk.ButtonImage("move-z+", _("Z-"), "color1")
|
||||
self.labels['z-'].connect("clicked", self.change_babystepping, "-")
|
||||
|
||||
grid.attach(self.labels['z+'], 0, 0, 1, 1)
|
||||
grid.attach(self.labels['zoffset'], 0, 1, 1, 1)
|
||||
grid.attach(self.labels['z-'], 0, 2, 1, 1)
|
||||
|
||||
self.labels['speed+'] = KlippyGtk.ButtonImage("speed-step", _("Speed +"), "color3")
|
||||
self.labels['speed+'] = self._gtk.ButtonImage("speed-step", _("Speed +"), "color3")
|
||||
self.labels['speed+'].connect("clicked", self.change_speed, "+")
|
||||
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-'] = self._gtk.ButtonImage("speed-step", _("Speed -"), "color3")
|
||||
self.labels['speed-'].connect("clicked", self.change_speed, "-")
|
||||
grid.attach(self.labels['speed+'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['speedfactor'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['speed-'], 1, 2, 1, 1)
|
||||
|
||||
self.labels['extrude+'] = KlippyGtk.ButtonImage("extrude", _("Extrusion +"), "color4")
|
||||
self.labels['extrude+'] = self._gtk.ButtonImage("extrude", _("Extrusion +"), "color4")
|
||||
self.labels['extrude+'].connect("clicked", self.change_extrusion, "+")
|
||||
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-'] = self._gtk.ButtonImage("retract", _("Extrusion -"), "color4")
|
||||
self.labels['extrude-'].connect("clicked", self.change_extrusion, "-")
|
||||
grid.attach(self.labels['extrude+'], 2, 0, 1, 1)
|
||||
grid.attach(self.labels['extrudefactor'], 2, 1, 1, 1)
|
||||
@ -70,7 +69,7 @@ class FineTunePanel(ScreenPanel):
|
||||
bsgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.bs_deltas:
|
||||
self.labels[i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_bs_delta, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
@ -89,7 +88,7 @@ class FineTunePanel(ScreenPanel):
|
||||
deltgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.percent_deltas:
|
||||
self.labels[i] = KlippyGtk.ToggleButton("%s%%" % i)
|
||||
self.labels[i] = self._gtk.ToggleButton("%s%%" % i)
|
||||
self.labels[i].connect("clicked", self.change_percent_delta, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
|
@ -4,7 +4,6 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.JobStatusPanel")
|
||||
@ -20,26 +19,22 @@ class JobStatusPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
grid.set_size_request(self._screen.width, self._screen.height)
|
||||
|
||||
self.labels['progress'] = KlippyGtk.ProgressBar("printing-progress-bar")
|
||||
#self.labels['progress'].set_vexpand(True)
|
||||
#self.labels['progress'].set_valign(Gtk.Align.CENTER)
|
||||
self.labels['progress'] = self._gtk.ProgressBar("printing-progress-bar")
|
||||
self.labels['progress'].set_show_text(False)
|
||||
#self.labels['progress'].set_margin_top(10)
|
||||
self.labels['progress'].set_margin_end(20)
|
||||
self.labels['progress_text'] = Gtk.Label()
|
||||
self.labels['progress_text'].get_style_context().add_class("printing-progress-text")
|
||||
overlay = Gtk.Overlay()
|
||||
overlay.add(self.labels['progress'])
|
||||
overlay.add_overlay(self.labels['progress_text'])
|
||||
|
||||
self.labels['file'] = KlippyGtk.ImageLabel("file","",20,"printing-status-label")
|
||||
self.labels['time_label'] = KlippyGtk.ImageLabel("speed-step",_("Time Elapsed"),20,"printing-status-label")
|
||||
self.labels['time'] = KlippyGtk.Label(_("Time Elapsed"),"printing-status-label")
|
||||
self.labels['time_left_label'] = KlippyGtk.ImageLabel("speed-step",_("Time Left"),20,"printing-status-label")
|
||||
self.labels['time_left'] = KlippyGtk.Label(_("Time Left"),"printing-status-label")
|
||||
self.labels['file'] = self._gtk.ImageLabel("file","",20,"printing-status-label")
|
||||
self.labels['time_label'] = self._gtk.ImageLabel("speed-step",_("Time Elapsed"),20,"printing-status-label")
|
||||
self.labels['time'] = self._gtk.Label(_("Time Elapsed"),"printing-status-label")
|
||||
self.labels['time_left_label'] = self._gtk.ImageLabel("speed-step",_("Time Left"),20,"printing-status-label")
|
||||
self.labels['time_left'] = self._gtk.Label(_("Time Left"),"printing-status-label")
|
||||
timegrid = Gtk.Grid()
|
||||
timegrid.attach(self.labels['time_label']['b'], 0, 0, 1, 1)
|
||||
timegrid.attach(self.labels['time'], 0, 1, 1, 1)
|
||||
@ -63,17 +58,17 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
grid.attach(pbox, 1, 0, 3, 2)
|
||||
|
||||
self.labels['extruder'] = KlippyGtk.ButtonImage("extruder-1", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['extruder'] = self._gtk.ButtonImage("extruder-1", self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels['extruder'].set_sensitive(False)
|
||||
grid.attach(self.labels['extruder'], 0, 0, 1, 1)
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['heater_bed'] = self._gtk.ButtonImage("bed", self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels['heater_bed'].set_sensitive(False)
|
||||
grid.attach(self.labels['heater_bed'], 0, 1, 1, 1)
|
||||
|
||||
self.labels['resume'] = KlippyGtk.ButtonImage("resume",_("Resume"),"color1")
|
||||
self.labels['resume'] = self._gtk.ButtonImage("resume",_("Resume"),"color1")
|
||||
self.labels['resume'].connect("clicked",self.resume)
|
||||
self.labels['pause'] = KlippyGtk.ButtonImage("pause",_("Pause"),"color1" )
|
||||
self.labels['pause'] = self._gtk.ButtonImage("pause",_("Pause"),"color1" )
|
||||
self.labels['pause'].connect("clicked",self.pause)
|
||||
|
||||
if self._printer.get_stat('pause_resume','is_paused') == True:
|
||||
@ -82,13 +77,13 @@ class JobStatusPanel(ScreenPanel):
|
||||
else:
|
||||
grid.attach(self.labels['pause'], 0, 2, 1, 1)
|
||||
|
||||
self.labels['cancel'] = KlippyGtk.ButtonImage("stop",_("Cancel"),"color2")
|
||||
self.labels['cancel'] = self._gtk.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("emergency",_("Emergency Stop"),"color4")
|
||||
self.labels['estop'] = self._gtk.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'] = self._gtk.ButtonImage("control",_("Control"),"color3")
|
||||
self.labels['control'].connect("clicked", self._screen._go_to_submenu, "")
|
||||
grid.attach(self.labels['control'], 3, 2, 1, 1)
|
||||
|
||||
@ -124,9 +119,8 @@ class JobStatusPanel(ScreenPanel):
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
dialog = KlippyGtk.Dialog(self._screen, buttons, label, self.cancel_confirm)
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, label, self.cancel_confirm)
|
||||
self.disable_button("pause","cancel")
|
||||
|
||||
def cancel_confirm(self, widget, response_id):
|
||||
@ -170,7 +164,7 @@ class JobStatusPanel(ScreenPanel):
|
||||
vsd = self._printer.get_stat("print_stats")
|
||||
if "filename" in vsd and self.filename != vsd['filename']:
|
||||
if vsd['filename'] != "":
|
||||
self.filename = KlippyGtk.formatFileName(vsd['filename'])
|
||||
self.filename = self._gtk.formatFileName(vsd['filename'])
|
||||
self.update_image_text("file", self.filename)
|
||||
else:
|
||||
file = "Unknown"
|
||||
@ -180,8 +174,8 @@ class JobStatusPanel(ScreenPanel):
|
||||
progress = 0 if self._printer.get_stat('virtual_sdcard','progress') == 0 else (vsd['print_duration'] /
|
||||
self._printer.get_stat('virtual_sdcard','progress') - vsd['print_duration'])
|
||||
|
||||
self.update_text("time", str(KlippyGtk.formatTimeString(vsd['print_duration'])))
|
||||
self.update_text("time_left", str(KlippyGtk.formatTimeString(
|
||||
self.update_text("time", str(self._gtk.formatTimeString(vsd['print_duration'])))
|
||||
self.update_text("time_left", str(self._gtk.formatTimeString(
|
||||
progress
|
||||
)))
|
||||
|
||||
@ -213,4 +207,4 @@ class JobStatusPanel(ScreenPanel):
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
|
@ -4,7 +4,6 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from panels.menu import MenuPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MainMenu")
|
||||
@ -19,22 +18,21 @@ class MainPanel(MenuPanel):
|
||||
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
grid.set_size_request(self._screen.width, self._screen.height)
|
||||
|
||||
# Create Extruders and bed icons
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
eq_grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
self.labels[x] = KlippyGtk.ButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels[x] = self._gtk.ButtonImage("extruder-"+str(i+1), self._gtk.formatTemperatureString(0, 0))
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['heater_bed'] = self._gtk.ButtonImage("bed", self._gtk.formatTemperatureString(0, 0))
|
||||
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels['heater_bed'], 0, i/2+1, width, 1)
|
||||
@ -64,7 +62,7 @@ class MainPanel(MenuPanel):
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
|
@ -3,12 +3,10 @@ import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
from jinja2 import Template
|
||||
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MenuPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
@ -59,7 +57,7 @@ class MenuPanel(ScreenPanel):
|
||||
for i in range(len(self.items)):
|
||||
key = list(self.items[i])[0]
|
||||
item = self.items[i][key]
|
||||
b = KlippyGtk.ButtonImage(
|
||||
b = self._gtk.ButtonImage(
|
||||
item['icon'], item['name'], "color"+str((i%4)+1)
|
||||
)
|
||||
if item['panel'] != False:
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -21,24 +20,24 @@ class MovePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
self.labels['x+'] = KlippyGtk.ButtonImage("move-x+", _("X+"), "color1")
|
||||
self.labels['x+'] = self._gtk.ButtonImage("move-x+", _("X+"), "color1")
|
||||
self.labels['x+'].connect("clicked", self.move, "X", "+")
|
||||
self.labels['x-'] = KlippyGtk.ButtonImage("move-x-", _("X-"), "color1")
|
||||
self.labels['x-'] = self._gtk.ButtonImage("move-x-", _("X-"), "color1")
|
||||
self.labels['x-'].connect("clicked", self.move, "X", "-")
|
||||
|
||||
self.labels['y+'] = KlippyGtk.ButtonImage("move-y+", _("Y+"), "color2")
|
||||
self.labels['y+'] = self._gtk.ButtonImage("move-y+", _("Y+"), "color2")
|
||||
self.labels['y+'].connect("clicked", self.move, "Y", "+")
|
||||
self.labels['y-'] = KlippyGtk.ButtonImage("move-y-", _("Y-"), "color2")
|
||||
self.labels['y-'] = self._gtk.ButtonImage("move-y-", _("Y-"), "color2")
|
||||
self.labels['y-'].connect("clicked", self.move, "Y", "-")
|
||||
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", _("Z+"), "color3")
|
||||
self.labels['z+'] = self._gtk.ButtonImage("move-z-", _("Z+"), "color3")
|
||||
self.labels['z+'].connect("clicked", self.move, "Z", "+")
|
||||
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", _("Z-"), "color3")
|
||||
self.labels['z-'] = self._gtk.ButtonImage("move-z+", _("Z-"), "color3")
|
||||
self.labels['z-'].connect("clicked", self.move, "Z", "-")
|
||||
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home", _("Home All"))
|
||||
self.labels['home'] = self._gtk.ButtonImage("home", _("Home All"))
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
|
||||
@ -54,7 +53,7 @@ class MovePanel(ScreenPanel):
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.distances:
|
||||
self.labels[i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
@ -70,25 +69,21 @@ class MovePanel(ScreenPanel):
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
#space_grid = KlippyGtk.HomogeneousGrid()
|
||||
#space_grid = self._gtk.HomogeneousGrid()
|
||||
#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)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
bottomgrid = KlippyGtk.HomogeneousGrid()
|
||||
bottomgrid = self._gtk.HomogeneousGrid()
|
||||
self.labels['pos_x'] = Gtk.Label("X: 0")
|
||||
self.labels['pos_y'] = Gtk.Label("Y: 0")
|
||||
self.labels['pos_z'] = Gtk.Label("Z: 0")
|
||||
self.labels['pos_x'].get_style_context().add_class("text")
|
||||
self.labels['pos_y'].get_style_context().add_class("text")
|
||||
self.labels['pos_z'].get_style_context().add_class("text")
|
||||
bottomgrid.attach(self.labels['pos_x'], 0, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_y'], 1, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_z'], 2, 0, 1, 1)
|
||||
box.pack_start(bottomgrid, True, True, 0)
|
||||
self.labels['move_dist'] = Gtk.Label(_("Move Distance (mm)"))
|
||||
self.labels['move_dist'].get_style_context().add_class("text")
|
||||
box.pack_start(self.labels['move_dist'], True, True, 0)
|
||||
box.pack_start(distgrid, True, True, 0)
|
||||
|
||||
|
@ -5,7 +5,6 @@ import os
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.NetworkPanel")
|
||||
@ -16,7 +15,7 @@ def create_panel(*args):
|
||||
class NetworkPanel(ScreenPanel):
|
||||
def initialize(self, menu):
|
||||
_ = self.lang.gettext
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
grid.set_hexpand(True)
|
||||
|
||||
# Get Hostname
|
||||
|
@ -54,8 +54,8 @@ class PowerPanel(ScreenPanel):
|
||||
switch.set_hexpand(False)
|
||||
switch.set_active(True if self._screen.printer.get_power_device_status(device) == "on" else False)
|
||||
switch.connect("notify::active", self.on_switch, device)
|
||||
switch.set_property("width-request", 150)
|
||||
switch.set_property("height-request", 80)
|
||||
switch.set_property("width-request", round(self._gtk.get_image_width()*2.5))
|
||||
switch.set_property("height-request", round(self._gtk.get_image_height()*1.25))
|
||||
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
|
@ -4,7 +4,6 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.PreheatPanel")
|
||||
@ -20,30 +19,30 @@ class PreheatPanel(ScreenPanel):
|
||||
self.preheat_options = self._screen._config.get_preheat_options()
|
||||
logger.debug("Preheat options: %s" % self.preheat_options)
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
eq_grid = self._gtk.HomogeneousGrid()
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
elif i == 0:
|
||||
primary_tool = x
|
||||
self.labels[x] = KlippyGtk.ToggleButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels[x] = self._gtk.ToggleButtonImage("extruder-"+str(i+1), self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels[x].connect('clicked', self.select_heater, x)
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels["heater_bed"] = KlippyGtk.ToggleButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"] = self._gtk.ToggleButtonImage("bed", self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"].connect('clicked', self.select_heater, "heater_bed")
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels["heater_bed"], 0, i/2+1, width, 1)
|
||||
|
||||
self.labels["control_grid"] = KlippyGtk.HomogeneousGrid()
|
||||
self.labels["control_grid"] = self._gtk.HomogeneousGrid()
|
||||
|
||||
i = 0
|
||||
for option in self.preheat_options:
|
||||
self.labels[option] = KlippyGtk.Button(option, "color%d" % ((i%4)+1))
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i%4)+1))
|
||||
self.labels[option].connect("clicked", self.set_temperature, option)
|
||||
self.labels['control_grid'].attach(
|
||||
self.labels[option],
|
||||
@ -51,7 +50,7 @@ class PreheatPanel(ScreenPanel):
|
||||
i += 1
|
||||
|
||||
|
||||
cooldown = KlippyGtk.ButtonImage('cool-down', _('Cooldown'))
|
||||
cooldown = self._gtk.ButtonImage('cool-down', _('Cooldown'))
|
||||
cooldown.connect("clicked", self.set_temperature, "cooldown")
|
||||
|
||||
row = int(i/2) if i%2 == 0 else int(i/2)+1
|
||||
|
@ -6,7 +6,6 @@ gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
from datetime import datetime
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -27,10 +26,6 @@ class PrintPanel(ScreenPanel):
|
||||
box.set_vexpand(True)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
|
||||
refresh = KlippyGtk.ButtonImage('refresh', None, None, 60, 60)
|
||||
refresh.connect("clicked", self.reload_files)
|
||||
#bar.add(refresh)
|
||||
|
||||
self.labels['filelist'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.labels['filelist'].set_vexpand(True)
|
||||
|
||||
@ -57,6 +52,7 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
frame.get_style_context().add_class("frame-item")
|
||||
|
||||
|
||||
name = Gtk.Label()
|
||||
@ -78,20 +74,16 @@ class PrintPanel(ScreenPanel):
|
||||
labels.set_valign(Gtk.Align.CENTER)
|
||||
labels.set_halign(Gtk.Align.START)
|
||||
|
||||
actions = KlippyGtk.ButtonImage("print",None,"color3")
|
||||
actions = self._gtk.ButtonImage("print",None,"color3")
|
||||
actions.connect("clicked", self.confirm_print, filename)
|
||||
actions.set_hexpand(False)
|
||||
actions.set_halign(Gtk.Align.END)
|
||||
|
||||
file = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
file.set_margin_top(1)
|
||||
file.set_margin_end(15)
|
||||
file.set_margin_start(15)
|
||||
file.set_margin_bottom(1)
|
||||
file.set_hexpand(True)
|
||||
file.set_vexpand(False)
|
||||
|
||||
icon = KlippyGtk.Image("file", False, 100, 100)
|
||||
icon = self._gtk.Image("file", False, 1.6, 1.6)
|
||||
pixbuf = self.get_file_image(filename)
|
||||
if pixbuf != None:
|
||||
icon.set_from_pixbuf(pixbuf)
|
||||
@ -115,14 +107,14 @@ class PrintPanel(ScreenPanel):
|
||||
self.labels['filelist'].attach(self.files[filename], 0, pos, 1, 1)
|
||||
self.labels['filelist'].show_all()
|
||||
|
||||
def get_file_image(self, filename, width=100, height=100):
|
||||
def get_file_image(self, filename, width=1.6, height=1.6):
|
||||
fileinfo = self._screen.files.get_file_info(filename)
|
||||
if fileinfo == None:
|
||||
return None
|
||||
|
||||
if "thumbnails" in fileinfo and len(fileinfo["thumbnails"]) > 0:
|
||||
thumbnail = fileinfo['thumbnails'][0]
|
||||
return KlippyGtk.PixbufFromFile("/tmp/.KS-thumbnails/%s-%s" % (fileinfo['filename'], thumbnail['size']),
|
||||
return self._gtk.PixbufFromFile("/tmp/.KS-thumbnails/%s-%s" % (fileinfo['filename'], thumbnail['size']),
|
||||
None, width, height)
|
||||
return None
|
||||
|
||||
@ -219,16 +211,14 @@ class PrintPanel(ScreenPanel):
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
grid = Gtk.Grid()
|
||||
grid.add(label)
|
||||
grid.set_size_request(self._screen.width - 60, -1)
|
||||
|
||||
pixbuf = self.get_file_image(filename, self._screen.width/2, self._screen.height/3)
|
||||
pixbuf = self.get_file_image(filename, 8, 3.2)
|
||||
if pixbuf != None:
|
||||
image = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
image.set_margin_top(20)
|
||||
grid.attach_next_to(image, label, Gtk.PositionType.BOTTOM, 1, 3)
|
||||
|
||||
#table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
|
||||
@ -236,7 +226,7 @@ class PrintPanel(ScreenPanel):
|
||||
grid.set_halign(Gtk.Align.CENTER)
|
||||
grid.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
dialog = KlippyGtk.Dialog(self._screen, buttons, grid, self.confirm_print_response, filename)
|
||||
dialog = self._gtk.Dialog(self._screen, buttons, grid, self.confirm_print_response, filename)
|
||||
|
||||
def confirm_print_response(self, widget, response_id, filename):
|
||||
widget.destroy()
|
||||
|
@ -5,7 +5,6 @@ import os
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.SplashScreenPanel")
|
||||
@ -24,7 +23,6 @@ class SplashScreenPanel(ScreenPanel):
|
||||
image.set_from_file(os.getcwd() + "/styles/z-bolt/images/klipper.png")
|
||||
|
||||
self.labels['text'] = Gtk.Label(_("Initializing printer..."))
|
||||
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)
|
||||
@ -60,10 +58,10 @@ class SplashScreenPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if "firmware_restart" not in self.labels:
|
||||
self.labels['power'] = KlippyGtk.ButtonImage("reboot",_("Power On Printer"),"color3")
|
||||
self.labels['restart'] = KlippyGtk.ButtonImage("reboot",_("Restart"),"color1")
|
||||
self.labels['power'] = self._gtk.ButtonImage("reboot",_("Power On Printer"),"color3")
|
||||
self.labels['restart'] = self._gtk.ButtonImage("reboot",_("Restart"),"color1")
|
||||
self.labels['restart'].connect("clicked", self.restart)
|
||||
self.labels['firmware_restart'] = KlippyGtk.ButtonImage("restart",_("Firmware Restart"),"color2")
|
||||
self.labels['firmware_restart'] = self._gtk.ButtonImage("restart",_("Firmware Restart"),"color2")
|
||||
self.labels['firmware_restart'].connect("clicked", self.firmware_restart)
|
||||
|
||||
self.clear_action_bar()
|
||||
|
@ -5,7 +5,6 @@ import os
|
||||
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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -18,11 +17,11 @@ class SystemPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
restart = KlippyGtk.ButtonImage('reboot',_('Klipper Restart'),'color1')
|
||||
restart = self._gtk.ButtonImage('reboot',_('Klipper Restart'),'color1')
|
||||
restart.connect("clicked", self.restart_klippy)
|
||||
firmrestart = KlippyGtk.ButtonImage('restart',_('Firmware Restart'),'color2')
|
||||
firmrestart = self._gtk.ButtonImage('restart',_('Firmware Restart'),'color2')
|
||||
firmrestart.connect("clicked", self.restart_klippy, "firmware")
|
||||
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
@ -4,7 +4,6 @@ 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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -21,16 +20,16 @@ class TemperaturePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
eq_grid = self._gtk.HomogeneousGrid()
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
elif i == 0:
|
||||
primary_tool = x
|
||||
self.labels[x] = KlippyGtk.ToggleButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels[x] = self._gtk.ToggleButtonImage("extruder-"+str(i+1), self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels[x].connect('clicked', self.select_heater, x)
|
||||
if i == 0:
|
||||
self.labels[x].set_active(True)
|
||||
@ -40,24 +39,24 @@ class TemperaturePanel(ScreenPanel):
|
||||
print ("Primary tool: " + primary_tool)
|
||||
self.labels[primary_tool].get_style_context().add_class('button_active')
|
||||
|
||||
self.labels["heater_bed"] = KlippyGtk.ToggleButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"] = self._gtk.ToggleButtonImage("bed", self._gtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"].connect('clicked', self.select_heater, "heater_bed")
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels["heater_bed"], 0, i/2+1, width, 1)
|
||||
|
||||
self.labels["control_grid"] = KlippyGtk.HomogeneousGrid()
|
||||
self.labels["control_grid"] = self._gtk.HomogeneousGrid()
|
||||
|
||||
self.labels["increase"] = KlippyGtk.ButtonImage("increase", _("Increase"), "color1")
|
||||
self.labels["increase"] = self._gtk.ButtonImage("increase", _("Increase"), "color1")
|
||||
self.labels["increase"].connect("clicked",self.change_target_temp, "+")
|
||||
self.labels["decrease"] = KlippyGtk.ButtonImage("decrease", _("Decrease"), "color3")
|
||||
self.labels["decrease"] = self._gtk.ButtonImage("decrease", _("Decrease"), "color3")
|
||||
self.labels["decrease"].connect("clicked",self.change_target_temp, "-")
|
||||
self.labels["npad"] = KlippyGtk.ButtonImage("settings", _("Number Pad"), "color2")
|
||||
self.labels["npad"] = self._gtk.ButtonImage("settings", _("Number Pad"), "color2")
|
||||
self.labels["npad"].connect("clicked", self.show_numpad)
|
||||
|
||||
tempgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.tempdeltas:
|
||||
self.labels['deg'+ i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels['deg'+ i] = self._gtk.ToggleButton(i)
|
||||
self.labels['deg'+ i].connect("clicked", self.change_temp_delta, i)
|
||||
ctx = self.labels['deg'+ i].get_style_context()
|
||||
if j == 0:
|
||||
@ -111,7 +110,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
def show_numpad(self, widget):
|
||||
_ = self.lang.gettext
|
||||
|
||||
numpad = KlippyGtk.HomogeneousGrid()
|
||||
numpad = self._gtk.HomogeneousGrid()
|
||||
|
||||
keys = [
|
||||
['1','numpad_tleft'],
|
||||
@ -130,9 +129,9 @@ class TemperaturePanel(ScreenPanel):
|
||||
for i in range(len(keys)):
|
||||
id = 'button_' + str(keys[i][0])
|
||||
if keys[i][0] == "B":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("backspace")
|
||||
self.labels[id] = Gtk.Button("B") #self._gtk.ButtonImage("backspace")
|
||||
elif keys[i][0] == "E":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("complete", None, None, 40, 40)
|
||||
self.labels[id] = Gtk.Button("E") #self._gtk.ButtonImage("complete", None, None, .675, .675)
|
||||
else:
|
||||
self.labels[id] = Gtk.Button(keys[i][0])
|
||||
self.labels[id].connect('clicked', self.update_entry, keys[i][0])
|
||||
@ -140,17 +139,14 @@ class TemperaturePanel(ScreenPanel):
|
||||
ctx.add_class(keys[i][1])
|
||||
numpad.attach(self.labels[id], i%3, i/3, 1, 1)
|
||||
|
||||
self.labels["keypad"] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
|
||||
self.labels["keypad"] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.labels['entry'] = Gtk.Entry()
|
||||
self.labels['entry'].props.xalign = 0.5
|
||||
ctx = self.labels['entry'].get_style_context()
|
||||
ctx.add_class('temperature_entry')
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', _('Close'))
|
||||
b = self._gtk.ButtonImage('back', _('Close'))
|
||||
b.connect("clicked", self.hide_numpad)
|
||||
|
||||
#numpad.attach(b, 0, 5, 3, 1)
|
||||
#numpad.attach(self.labels['entry'], 0, 0, 3, 1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.add(self.labels['entry'])
|
||||
box.add(numpad)
|
||||
@ -159,7 +155,6 @@ class TemperaturePanel(ScreenPanel):
|
||||
self.labels["keypad"] = numpad
|
||||
|
||||
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()
|
||||
|
||||
|
@ -3,7 +3,6 @@ import gi
|
||||
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
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
@ -24,7 +23,7 @@ class ZCalibratePanel(ScreenPanel):
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
label = Gtk.Label(_("Z Offset") + ": \n")
|
||||
self.labels['zposition'] = Gtk.Label(_("Homing"))
|
||||
@ -35,15 +34,15 @@ class ZCalibratePanel(ScreenPanel):
|
||||
box.add(label)
|
||||
box.add(self.labels['zposition'])
|
||||
|
||||
zpos = KlippyGtk.ButtonImage('z-offset-decrease',_("Raise Nozzle"))
|
||||
zpos = self._gtk.ButtonImage('z-offset-decrease',_("Raise Nozzle"))
|
||||
zpos.connect("clicked", self.move, "+")
|
||||
zneg = KlippyGtk.ButtonImage('z-offset-increase',_("Lower Nozzle"))
|
||||
zneg = self._gtk.ButtonImage('z-offset-increase',_("Lower Nozzle"))
|
||||
zneg.connect("clicked", self.move, "-")
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.distances:
|
||||
self.labels[i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels[i] = self._gtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
@ -59,16 +58,16 @@ class ZCalibratePanel(ScreenPanel):
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
space_grid = KlippyGtk.HomogeneousGrid()
|
||||
space_grid = self._gtk.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)
|
||||
|
||||
complete = KlippyGtk.ButtonImage('complete',_('Accept'),'color2')
|
||||
complete = self._gtk.ButtonImage('complete',_('Accept'),'color2')
|
||||
complete.connect("clicked", self.accept)
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', _('Abort'))
|
||||
b = self._gtk.ButtonImage('back', _('Abort'))
|
||||
b.connect("clicked", self.abort)
|
||||
|
||||
|
||||
|
38
screen.py
38
screen.py
@ -63,16 +63,9 @@ class KlipperScreen(Gtk.Window):
|
||||
shutdown = True
|
||||
|
||||
def __init__(self):
|
||||
Gtk.Window.__init__(self)
|
||||
self.width = Gdk.Screen.get_width(Gdk.Screen.get_default())
|
||||
self.height = Gdk.Screen.get_height(Gdk.Screen.get_default())
|
||||
self.set_default_size(self.width, self.height)
|
||||
self.set_resizable(False)
|
||||
self.version = get_software_version()
|
||||
logger.info("KlipperScreen version: %s" % self.version)
|
||||
logger.info("Screen resolution: %sx%s" % (self.width, self.height))
|
||||
self._config = KlipperScreenConfig()
|
||||
self.init_style()
|
||||
self.printer = Printer({
|
||||
"software_version": "Unknown"
|
||||
}, {
|
||||
@ -90,6 +83,15 @@ class KlipperScreen(Gtk.Window):
|
||||
_ = self.lang.gettext
|
||||
|
||||
self.apiclient = KlippyRest("127.0.0.1",7125)
|
||||
Gtk.Window.__init__(self)
|
||||
self.width = self._config.get_main_config().getint("width", Gdk.Screen.get_width(Gdk.Screen.get_default()))
|
||||
self.height = self._config.get_main_config().getint("height", Gdk.Screen.get_height(Gdk.Screen.get_default()))
|
||||
self.set_default_size(self.width, self.height)
|
||||
self.set_resizable(False)
|
||||
logger.info("Screen resolution: %sx%s" % (self.width, self.height))
|
||||
|
||||
self.gtk = KlippyGtk(self.width, self.height)
|
||||
self.init_style()
|
||||
|
||||
#self._load_panels()
|
||||
|
||||
@ -189,7 +191,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
box = Gtk.Box()
|
||||
box.get_style_context().add_class("message_popup")
|
||||
box.set_size_request(self.width, 50)
|
||||
box.set_size_request(self.width, self.gtk.get_header_size())
|
||||
label = Gtk.Label()
|
||||
if "must home axis first" in message.lower():
|
||||
message = "Must home all axis first."
|
||||
@ -200,8 +202,8 @@ class KlipperScreen(Gtk.Window):
|
||||
close.props.relief = Gtk.ReliefStyle.NONE
|
||||
close.connect("clicked", self.close_popup_message)
|
||||
|
||||
box.pack_start(label, True, True, 10)
|
||||
box.pack_end(close, False, False, 10)
|
||||
box.pack_start(label, True, True, 0)
|
||||
box.pack_end(close, False, False, 0)
|
||||
box.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
cur_panel = self.panels[self._cur_panels[-1]]
|
||||
@ -244,9 +246,8 @@ class KlipperScreen(Gtk.Window):
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
dialog = KlippyGtk.Dialog(self, buttons, label, self.error_modal_response)
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self.error_modal_response)
|
||||
|
||||
def error_modal_response(self, widget, response_id):
|
||||
widget.destroy()
|
||||
@ -254,7 +255,15 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
def init_style(self):
|
||||
style_provider = Gtk.CssProvider()
|
||||
style_provider.load_from_path(klipperscreendir + "/style.css")
|
||||
#style_provider.load_from_path(klipperscreendir + "/style.css")
|
||||
|
||||
css = open(klipperscreendir + "/styles/style.css")
|
||||
css_data = css.read()
|
||||
css.close()
|
||||
css_data = css_data.replace("KS_FONT_SIZE",str(self.gtk.get_font_size()))
|
||||
|
||||
style_provider = Gtk.CssProvider()
|
||||
style_provider.load_from_data(css_data.encode())
|
||||
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(),
|
||||
@ -388,9 +397,8 @@ class KlipperScreen(Gtk.Window):
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
dialog = KlippyGtk.Dialog(self, buttons, label, self._confirm_send_action_response, method, params)
|
||||
dialog = self.gtk.Dialog(self, buttons, label, self._confirm_send_action_response, method, params)
|
||||
|
||||
def _confirm_send_action_response(self, widget, response_id, method, params):
|
||||
if response_id == Gtk.ResponseType.OK:
|
||||
|
314
style.css
314
style.css
@ -1,314 +0,0 @@
|
||||
/* * {
|
||||
|
||||
} */
|
||||
|
||||
window {
|
||||
background-color: #13181C;
|
||||
-gtk-icon-shadow: none;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
scrollbar, scrollbar button, scrollbar trough {
|
||||
border: none;
|
||||
background-color: #13181C;
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
min-width: 60px;
|
||||
border-radius: 15px;
|
||||
background-color: #404E57;
|
||||
}
|
||||
|
||||
label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
frame {
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #444;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
progress, trough {
|
||||
min-height: 40px;
|
||||
/*font-size: 50px;*/
|
||||
background-color: #404E57;
|
||||
color: #fff;
|
||||
border: #000 1px solid;
|
||||
}
|
||||
|
||||
progress {
|
||||
background-color: #d47b00;
|
||||
font-size: 50px;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
.message_popup {
|
||||
background-color: #367554;
|
||||
border-bottom: 2px solid #fff;
|
||||
}
|
||||
|
||||
.message_popup button {
|
||||
background-color: #367554;
|
||||
}
|
||||
|
||||
.printing-progress-bar {
|
||||
font-size: 25px;
|
||||
color: #00C9B4;
|
||||
}
|
||||
|
||||
.printing-progress-text {
|
||||
font-size: 25px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.printing-state {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
button {
|
||||
background-image: none;
|
||||
background-color: #13181C;
|
||||
margin: 5px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 0;
|
||||
border: 0px solid #000;
|
||||
color: #fff;
|
||||
-gtk-icon-shadow: none;
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #304C62;
|
||||
}
|
||||
|
||||
.button_active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
button.color1 {
|
||||
border-bottom: 8px solid #ED6500;
|
||||
}
|
||||
|
||||
button.color2 {
|
||||
border-bottom: 8px solid #B10080;
|
||||
}
|
||||
|
||||
button.color3 {
|
||||
border-bottom: 8px solid #009384;
|
||||
}
|
||||
|
||||
button.color4 {
|
||||
border-bottom: 8px solid #A7E100;
|
||||
}
|
||||
|
||||
button.active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
button.file-list {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.distbutton_top {
|
||||
border: 3px solid #fff;
|
||||
border-right: 0px;
|
||||
border-top-left-radius: 15px;
|
||||
border-bottom-left-radius: 15px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
.distbutton {
|
||||
border: 3px solid #fff;
|
||||
border-left: 3px solid #ccc;
|
||||
border-right: 0px;
|
||||
margin-left: 0;
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
.distbutton_bottom {
|
||||
border: 3px solid #fff;
|
||||
border-left: 3px solid #ccc;
|
||||
border-top-right-radius: 15px;
|
||||
border-bottom-right-radius: 15px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.tempbutton_top {
|
||||
border: 3px solid #fff;
|
||||
border-bottom: 0px;
|
||||
border-top-left-radius: 15px;
|
||||
border-top-right-radius: 15px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.tempbutton {
|
||||
border: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
border-bottom: 0px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.tempbutton_bottom {
|
||||
border: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
border-bottom-left-radius: 15px;
|
||||
border-bottom-right-radius: 15px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.distbutton_active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
entry {
|
||||
font-size: 30px;
|
||||
background-color: #20292F;
|
||||
border-radius: 0;
|
||||
padding-left: 1em;
|
||||
margin-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
button.keyboard {
|
||||
font-size: 30px;
|
||||
margin: 0px;
|
||||
/* margin-bottom:10px; */
|
||||
}
|
||||
|
||||
.dialog {
|
||||
border: 2px solid black;
|
||||
font-size: 20px;
|
||||
padding: 50px;
|
||||
background-color: #000;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.dialog button {
|
||||
padding: 30px 50px 30px 50px;
|
||||
border-bottom: 8px solid #009384;
|
||||
}
|
||||
|
||||
.message {
|
||||
border: 2px solid #981E1F;
|
||||
font-size: 20px;
|
||||
padding: 50px;
|
||||
color: #FFF;
|
||||
background-color: #981E1F;
|
||||
}
|
||||
|
||||
.message button {
|
||||
background-color: #FFF;
|
||||
color: #000;
|
||||
padding: 40px 50px 40px 50px;
|
||||
}
|
||||
|
||||
.notification {
|
||||
background-clip: padding-box;
|
||||
padding: 5px;
|
||||
border-radius: 0 0 5px 5px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background-color: rgba(30, 204, 39, 0.7);
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: rgba(204, 30, 30, 0.7);
|
||||
}
|
||||
|
||||
.printing-status-label {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 3px;
|
||||
color: #ccc;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
|
||||
.temperature_entry {
|
||||
border: 0px;
|
||||
color: #fff;
|
||||
margin: 10px 5px 5px 5px;
|
||||
}
|
||||
|
||||
.numpad_tleft {
|
||||
border-left: 3px solid #fff;
|
||||
border-top: 3px solid #fff;
|
||||
border-top-left-radius: 15px;
|
||||
margin: 3px 0 0 3px;
|
||||
}
|
||||
|
||||
.numpad_top {
|
||||
border-left: 3px solid #ccc;
|
||||
border-top: 3px solid #fff;
|
||||
margin: 3px 0 0 0;
|
||||
}
|
||||
|
||||
.numpad_tright {
|
||||
border-left: 3px solid #fff;
|
||||
border-right: 3px solid #fff;
|
||||
border-top: 3px solid #fff;
|
||||
border-top-right-radius: 15px;
|
||||
margin: 3px 3px 0 0;
|
||||
}
|
||||
|
||||
.numpad_left {
|
||||
border-left: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
margin: 0 0 0 3px;
|
||||
}
|
||||
|
||||
.numpad_button {
|
||||
border-left: 3px solid #ccc;
|
||||
border-top: 3px solid #ccc;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.numpad_right {
|
||||
border-right: 3px solid #fff;
|
||||
border-left: 3px solid #ccc;
|
||||
border-top: 3px solid #ccc;
|
||||
margin: 0 3px 0 0;
|
||||
}
|
||||
|
||||
.numpad_bleft {
|
||||
border-left: 3px solid #fff;
|
||||
border-bottom: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
border-bottom-left-radius: 15px;
|
||||
margin: 0 0 3px 3px;
|
||||
}
|
||||
|
||||
.numpad_bottom {
|
||||
border-left: 3px solid #ccc;
|
||||
border-bottom: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
margin: 0 0 3px 0;
|
||||
}
|
||||
|
||||
.numpad_bright {
|
||||
border-left: 3px solid #ccc;
|
||||
border-bottom: 3px solid #fff;
|
||||
border-top: 3px solid #ccc;
|
||||
border-right: 3px solid #ccc;
|
||||
border-bottom-right-radius: 15px;
|
||||
margin: 0 3px 3px 0;
|
||||
}
|
||||
|
||||
.fan_slider {
|
||||
margin: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
scale mark {
|
||||
margin-top: 20px;
|
||||
color: #fff;
|
||||
}
|
290
styles/style.css
Normal file
290
styles/style.css
Normal file
@ -0,0 +1,290 @@
|
||||
* {
|
||||
color: #fff;
|
||||
font-size: KS_FONT_SIZEpx;
|
||||
}
|
||||
|
||||
window {
|
||||
background-color: #13181C;
|
||||
-gtk-icon-shadow: none;
|
||||
}
|
||||
|
||||
button {
|
||||
background-image: none;
|
||||
background-color: #13181C;
|
||||
margin: .25em;
|
||||
margin-bottom: .5em;
|
||||
border-radius: 0;
|
||||
border: 0 solid #000;
|
||||
-gtk-icon-shadow: none;
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #304C62;
|
||||
}
|
||||
|
||||
.button_active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
button.color1 {
|
||||
border-bottom: .4em solid #ED6500;
|
||||
}
|
||||
|
||||
button.color2 {
|
||||
border-bottom: .4em solid #B10080;
|
||||
}
|
||||
|
||||
button.color3 {
|
||||
border-bottom: .4em solid #009384;
|
||||
}
|
||||
|
||||
button.color4 {
|
||||
border-bottom: .4em solid #A7E100;
|
||||
}
|
||||
|
||||
button.active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
button.file-list {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
entry {
|
||||
font-size: 1em;
|
||||
background-color: #20292F;
|
||||
border: 0;
|
||||
padding: .25em;
|
||||
}
|
||||
|
||||
frame {
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #444;
|
||||
}
|
||||
|
||||
label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
progress {
|
||||
background-color: #d47b00;
|
||||
}
|
||||
|
||||
progress, trough {
|
||||
min-height: 2em;
|
||||
background-color: #404E57;
|
||||
color: #fff;
|
||||
border: #000 1px solid;
|
||||
}
|
||||
|
||||
scale mark {
|
||||
margin-top: 1em;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
scrollbar, scrollbar button, scrollbar trough {
|
||||
border: none;
|
||||
background-color: #13181C;
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
min-width: 3em;
|
||||
border-radius: .7em;
|
||||
background-color: #404E57;
|
||||
}
|
||||
|
||||
trough {
|
||||
margin: .5em 1em;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
border: .1em solid black;
|
||||
padding: 2.5em;
|
||||
background-color: #000;
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.dialog button {
|
||||
padding: 1.5em 2.5em 1.5em 2.5em;
|
||||
border-bottom: .4em solid #009384;
|
||||
}
|
||||
|
||||
.distbutton_active {
|
||||
background-color: #20303D;
|
||||
}
|
||||
|
||||
.distbutton_top {
|
||||
border: .15em solid #fff;
|
||||
border-right: 0;
|
||||
border-top-left-radius: .75em;
|
||||
border-bottom-left-radius: .75em;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.distbutton {
|
||||
border: .15em solid #fff;
|
||||
border-left: .15em solid #ccc;
|
||||
border-right: 0;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.distbutton_bottom {
|
||||
border: .15em solid #fff;
|
||||
border-left: .15em solid #ccc;
|
||||
border-top-right-radius: .7em;
|
||||
border-bottom-right-radius: .7em;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.fan_slider {
|
||||
margin: 1em;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.frame-item {
|
||||
padding: .1em .75em;
|
||||
}
|
||||
|
||||
.message_popup {
|
||||
background-color: #367554;
|
||||
border-bottom: .1em solid #fff;
|
||||
}
|
||||
|
||||
.message_popup button {
|
||||
background-color: #367554;
|
||||
}
|
||||
|
||||
.numpad_tleft {
|
||||
border-left: .15em solid #fff;
|
||||
border-top: .15em solid #fff;
|
||||
border-top-left-radius: .7em;
|
||||
margin: .15em 0 0 .15em;
|
||||
}
|
||||
|
||||
.numpad_top {
|
||||
border-left: .15em solid #ccc;
|
||||
border-top: .15em solid #fff;
|
||||
margin: .15em 0 0 0;
|
||||
}
|
||||
|
||||
.numpad_tright {
|
||||
border-left: .15em solid #fff;
|
||||
border-right: .15em solid #fff;
|
||||
border-top: .15em solid #fff;
|
||||
border-top-right-radius: .7em;
|
||||
margin: .15em .15em 0 0;
|
||||
}
|
||||
|
||||
.numpad_left {
|
||||
border-left: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
margin: 0 0 0 .15em;
|
||||
}
|
||||
|
||||
.numpad_button {
|
||||
border-left: .15em solid #ccc;
|
||||
border-top: .15em solid #ccc;
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.numpad_right {
|
||||
border-right: .15em solid #fff;
|
||||
border-left: .15em solid #ccc;
|
||||
border-top: .15em solid #ccc;
|
||||
margin: 0 .15em 0 0;
|
||||
}
|
||||
|
||||
.numpad_bleft {
|
||||
border-left: .15em solid #fff;
|
||||
border-bottom: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
border-bottom-left-radius: .7em;
|
||||
margin: 0 0 .15em .15em;
|
||||
}
|
||||
|
||||
.numpad_bottom {
|
||||
border-left: .15em solid #ccc;
|
||||
border-bottom: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
margin: 0 0 .15em 0;
|
||||
}
|
||||
|
||||
.numpad_bright {
|
||||
border-left: .15em solid #ccc;
|
||||
border-bottom: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
border-right: .15em solid #ccc;
|
||||
border-bottom-right-radius: .7em;
|
||||
margin: 0 .15em .15em 0;
|
||||
}
|
||||
|
||||
.printing-progress-bar {
|
||||
color: #00C9B4;
|
||||
}
|
||||
|
||||
.printing-progress-text {
|
||||
font-size: 1.25em;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.printing-status-label {
|
||||
padding-top: .25em;
|
||||
padding-bottom: .15em;
|
||||
color: #ccc;
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
.tempbutton_top {
|
||||
border: .15em solid #fff;
|
||||
border-bottom: 0;
|
||||
border-top-left-radius: .75em;
|
||||
border-top-right-radius: .75em;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.tempbutton {
|
||||
border: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
border-bottom: 0;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.tempbutton_bottom {
|
||||
border: .15em solid #fff;
|
||||
border-top: .15em solid #ccc;
|
||||
border-bottom-left-radius: .7em;
|
||||
border-bottom-right-radius: .7em;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.message {
|
||||
border: .1em solid #981E1F;
|
||||
font-size: 1em;
|
||||
padding: 2.5em;
|
||||
color: #FFF;
|
||||
background-color: #981E1F;
|
||||
}
|
||||
|
||||
.message button {
|
||||
background-color: #FFF;
|
||||
color: #000;
|
||||
padding: 2em 2.5em 2em 2.5em;
|
||||
}
|
||||
|
||||
.notification {
|
||||
background-clip: padding-box;
|
||||
padding: .25em;
|
||||
border-radius: 0 0 .25em .25em;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background-color: rgba(30, 204, 39, 0.7);
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: rgba(204, 30, 30, 0.7);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user