Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a digit-only input for spool ID #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion ks_includes/widgets/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ def __init__(self, screen, close_cb, entry=None):
language = self.detect_language(screen._config.get_main_config().get("language", None))
logging.info(f"Keyboard {language}")

if language == "de":
if self.entry_is_digital():
self.keys = [
[
[ "7", "8", "9" ],
[ "4", "5", "6" ],
[ "1", "2", "3" ],
[ "↓", "0", "⌫" ]
]
]
elif language == "de":
self.keys = [
[
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü"],
Expand Down Expand Up @@ -145,6 +154,17 @@ def set_pallet(self, p):
self.keyboard.remove_row(0)
self.pallet_nr = p
columns = 0

if self.entry_is_digital():
for r, row in enumerate(self.keys[p]):
for k, key in enumerate(row):
x = k * 2
self.keyboard.attach(self.buttons[p][r][k], x, r, 2, 1)
if x > columns:
columns = x
self.show_all()
return

for r, row in enumerate(self.keys[p][:-1]):
for k, key in enumerate(row):
x = k * 2 + 1 if r == 1 else k * 2
Expand Down Expand Up @@ -233,3 +253,6 @@ def toggle_shift(self):
widget.get_style_context().add_class("active")
else:
widget.get_style_context().remove_class("active")

def entry_is_digital(self):
return self.entry.get_input_purpose() == Gtk.InputPurpose.DIGITS
1 change: 1 addition & 0 deletions panels/mmu_filaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def __init__(self, screen, title):
self.labels['id_entry'].connect("changed", self.select_spool_id)
self.labels['id_entry'].grab_focus_without_selecting()
self.labels['id_entry'].set_max_length(4)
self.labels['id_entry'].set_input_purpose(Gtk.InputPurpose.DIGITS)

self.labels['filament'].set_vexpand(False)
self.labels['filament'].get_style_context().add_class("mmu_recover")
Expand Down