diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index 84a0f1c0..dbe311b2 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -12,6 +12,7 @@ class KlippyGtk: labels = {} width_ratio = 16 height_ratio = 9.375 + keyboard_ratio = .5 def __init__(self, screen, width, height, theme, cursor, fontsize_type): self.screen = screen @@ -21,10 +22,8 @@ class KlippyGtk: if self.screen.vertical_mode: self.font_ratio = [33, 49] - self.keyboard_ratio = .25 else: self.font_ratio = [43, 29] - self.keyboard_ratio = .33 self.font_size = int(min( self.width / self.font_ratio[0], self.height / self.font_ratio[1] diff --git a/ks_includes/locales/keyboard.xml b/ks_includes/locales/keyboard.xml index 4615fb20..8fba568d 100644 --- a/ks_includes/locales/keyboard.xml +++ b/ks_includes/locales/keyboard.xml @@ -69,12 +69,6 @@ - - - - - - @@ -129,10 +123,16 @@ + + + + + + - + @@ -162,7 +162,7 @@ - + @@ -177,31 +177,27 @@ - + - - + + - + - + - + - + - - - - diff --git a/ks_includes/widgets/keypad.py b/ks_includes/widgets/keypad.py index 267c6813..934d1be7 100644 --- a/ks_includes/widgets/keypad.py +++ b/ks_includes/widgets/keypad.py @@ -16,6 +16,7 @@ class Keypad(Gtk.Box): numpad = self._gtk.HomogeneousGrid() numpad.set_direction(Gtk.TextDirection.LTR) + numpad.get_style_context().add_class('numpad') keys = [ ['1', 'numpad_tleft'], @@ -48,7 +49,7 @@ class Keypad(Gtk.Box): self.labels['entry'].props.xalign = 0.5 self.labels['entry'].connect("activate", self.update_entry, "E") - b = self._gtk.ButtonImage('cancel', _('Close'), None, 1) + b = self._gtk.ButtonImage('cancel', _('Close'), None, .66, Gtk.PositionType.LEFT, False) b.connect("clicked", close_function) self.add(self.labels['entry']) diff --git a/panels/bed_mesh.py b/panels/bed_mesh.py index 1124823f..abb3886a 100644 --- a/panels/bed_mesh.py +++ b/panels/bed_mesh.py @@ -266,19 +266,19 @@ class BedMeshPanel(ScreenPanel): if "create_profile" not in self.labels: pl = self._gtk.Label(_("Profile Name:")) pl.set_hexpand(False) - entry = Gtk.Entry() - entry.set_text('') - entry.set_hexpand(True) - entry.connect("activate", self.create_profile) - entry.connect("focus-in-event", self._show_keyboard) - entry.connect("focus-out-event", self._remove_keyboard) + self.labels['profile_name'] = Gtk.Entry() + self.labels['profile_name'].set_text('') + self.labels['profile_name'].set_hexpand(True) + self.labels['profile_name'].connect("activate", self.create_profile) + self.labels['profile_name'].connect("focus-in-event", self._screen.show_keyboard) + self.labels['profile_name'].grab_focus_without_selecting() save = self._gtk.ButtonImage("sd", _("Save"), "color3") save.set_hexpand(False) save.connect("clicked", self.create_profile) box = Gtk.HBox() - box.pack_start(entry, True, True, 5) + box.pack_start(self.labels['profile_name'], True, True, 5) box.pack_start(save, False, False, 5) self.labels['create_profile'] = Gtk.VBox(spacing=5) @@ -290,8 +290,6 @@ class BedMeshPanel(ScreenPanel): self.content.add(self.labels['create_profile']) self._screen.show_keyboard() - self.labels['profile_name'] = entry - self.labels['profile_name'].grab_focus_without_selecting() self.show_create = True def show_mesh(self, widget, profile): diff --git a/panels/console.py b/panels/console.py index d45c657b..773eff23 100644 --- a/panels/console.py +++ b/panels/console.py @@ -69,6 +69,7 @@ class ConsolePanel(ScreenPanel): tv.set_editable(False) tv.set_cursor_visible(False) tv.connect("size-allocate", self._autoscroll) + tv.connect("focus-in-event", self._screen.remove_keyboard) sw.add(tv) @@ -79,9 +80,10 @@ class ConsolePanel(ScreenPanel): entry = Gtk.Entry() entry.set_hexpand(True) entry.set_vexpand(False) - entry.connect("focus-in-event", self._show_keyboard) - entry.connect("focus-out-event", self._remove_keyboard) + entry.connect("button-press-event", self._screen.show_keyboard) + entry.connect("focus-in-event", self._screen.show_keyboard) entry.connect("activate", self._send_command) + entry.grab_focus_without_selecting() enter = self._gtk.ButtonImage("resume", " " + _('Send') + " ", None, .66, Gtk.PositionType.RIGHT, False) enter.set_hexpand(False) @@ -98,9 +100,9 @@ class ConsolePanel(ScreenPanel): }) content_box = Gtk.VBox() - content_box.pack_start(options, False, 0, 5) + content_box.pack_start(options, False, False, 5) content_box.add(sw) - content_box.pack_end(ebox, False, 0, 0) + content_box.pack_end(ebox, False, False, 0) self.content.add(content_box) def clear(self, widget): @@ -155,15 +157,10 @@ class ConsolePanel(ScreenPanel): adj = self.labels['sw'].get_vadjustment() adj.set_value(adj.get_upper() - adj.get_page_size()) - def _show_keyboard(self, *args): - self._screen.show_keyboard() - - def _remove_keyboard(self, *args): - self._screen.remove_keyboard() - def _send_command(self, *args): cmd = self.labels['entry'].get_text() self.labels['entry'].set_text('') + self._screen.remove_keyboard() self.add_gcode("command", time.time(), cmd) self._screen._ws.klippy.gcode_script(cmd) diff --git a/panels/network.py b/panels/network.py index d6e3ce7d..faca16c9 100644 --- a/panels/network.py +++ b/panels/network.py @@ -351,19 +351,19 @@ class NetworkPanel(ScreenPanel): label = self._gtk.Label("%s %s:" % (_("PSK for"), ssid)) label.set_hexpand(False) - entry = Gtk.Entry() - entry.set_text('') - entry.set_hexpand(True) - entry.connect("activate", self.add_new_network, ssid, True) - entry.connect("focus-in-event", self._show_keyboard) - entry.connect("focus-out-event", self._remove_keyboard) + self.labels['network_psk'] = Gtk.Entry() + self.labels['network_psk'].set_text('') + self.labels['network_psk'].set_hexpand(True) + self.labels['network_psk'].connect("activate", self.add_new_network, ssid, True) + self.labels['network_psk'].connect("focus-in-event", self._screen.show_keyboard) + self.labels['network_psk'].grab_focus_without_selecting() save = self._gtk.ButtonImage("sd", _("Save"), "color3") save.set_hexpand(False) save.connect("clicked", self.add_new_network, ssid, True) box = Gtk.HBox() - box.pack_start(entry, True, True, 5) + box.pack_start(self.labels['network_psk'], True, True, 5) box.pack_start(save, False, False, 5) self.labels['add_network'] = Gtk.VBox(spacing=5) @@ -375,8 +375,6 @@ class NetworkPanel(ScreenPanel): self.content.add(self.labels['add_network']) self._screen.show_keyboard() - self.labels['network_psk'] = entry - self.labels['network_psk'].grab_focus_without_selecting() self.content.show_all() self.show_add = True diff --git a/screen.py b/screen.py index 3f8643e9..857aa087 100644 --- a/screen.py +++ b/screen.py @@ -1016,7 +1016,7 @@ class KlipperScreen(Gtk.Window): self.show_panel('job_status', "job_status", "Print Status", 2) self.base_panel.show_heaters(True) - def show_keyboard(self, widget=None): + def show_keyboard(self, widget=None, event=None): if self.keyboard is not None: return @@ -1038,9 +1038,10 @@ class KlipperScreen(Gtk.Window): box = Gtk.VBox() box.set_vexpand(False) box.set_size_request(self.gtk.get_content_width(), self.gtk.get_keyboard_height()) + box.get_style_context().add_class("keyboard_box") box.add(keyboard) - self.base_panel.get_content().pack_end(box, False, 0, 0) + self.base_panel.get_content().pack_end(box, True, True, 0) self.show_all() keyboard.add_id(xid) @@ -1052,7 +1053,7 @@ class KlipperScreen(Gtk.Window): "socket": keyboard } - def remove_keyboard(self, widget=None): + def remove_keyboard(self, widget=None, event=None): if self.keyboard is None: return diff --git a/styles/base.css b/styles/base.css index 1dfb3fcd..ea3a2207 100644 --- a/styles/base.css +++ b/styles/base.css @@ -101,7 +101,7 @@ switch slider { entry { font-size: 1em; background-color: #20292F; - border: 1em solid #13181C; + border: .2em solid #13181C; padding: .25em; } @@ -278,6 +278,10 @@ trough { min-height: 2em; } +.keyboard_box { + margin-top: 42px; +} + .message_popup { border-bottom: .1em solid white; } @@ -294,6 +298,10 @@ trough { background-color: #9e2f3a; } +.numpad{ + margin-top: 30px; +} + .numpad_tleft { border: .15em solid white; border-bottom: 0;