feat(gui): Add accel keys to RowEditor
This commit is contained in:
@@ -114,7 +114,8 @@ class MainWindow(ThemedTk):
|
|||||||
self.bind_all(
|
self.bind_all(
|
||||||
"<Control-Shift-R>", lambda event: self.editor.toggle_extended_matching()
|
"<Control-Shift-R>", lambda event: self.editor.toggle_extended_matching()
|
||||||
)
|
)
|
||||||
self.bind_all("<Alt-s>", lambda event: self.editor.do_save_txn())
|
|
||||||
|
# self.bind_all("<Alt-s>", lambda event: self.editor.do_save_txn())
|
||||||
self.bind_all("<Alt-Return>", lambda event: self.editor.do_apply())
|
self.bind_all("<Alt-Return>", lambda event: self.editor.do_apply())
|
||||||
|
|
||||||
def setup_window(self):
|
def setup_window(self):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from tkinter import BooleanVar, StringVar, ttk
|
from tkinter import BooleanVar, StringVar, ttk
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
|
||||||
from ..base.converter import Converter
|
from ..base.converter import Converter
|
||||||
@@ -122,14 +123,19 @@ class RowEditor(ttk.Frame):
|
|||||||
if to_select is not None:
|
if to_select is not None:
|
||||||
to_select.focus_set()
|
to_select.focus_set()
|
||||||
|
|
||||||
def focus_txn_frame(self):
|
def focus_txn_frame(self, name=None):
|
||||||
if self.showing_txn:
|
if self.showing_txn:
|
||||||
|
if name is None:
|
||||||
to_select = self.last_txnfield
|
to_select = self.last_txnfield
|
||||||
if to_select is None:
|
if to_select is None:
|
||||||
to_select = next(
|
to_select = next(
|
||||||
(entry for _, _, entry in self.txn_rows.values() if entry)
|
(entry for _, _, entry in self.txn_rows.values() if entry)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
_, _, to_select = self.txn_rows[name]
|
||||||
to_select.focus_set()
|
to_select.focus_set()
|
||||||
|
to_select.select_range(0, "end")
|
||||||
|
to_select.icursor("end")
|
||||||
|
|
||||||
def toggle_matching(self):
|
def toggle_matching(self):
|
||||||
self.match_var.set(not self.match_var.get())
|
self.match_var.set(not self.match_var.get())
|
||||||
@@ -461,6 +467,12 @@ class RowEditor(ttk.Frame):
|
|||||||
# TODO!: If we have a list of accounts, we could use a ComboBox here instead? For autocompletion.
|
# TODO!: If we have a list of accounts, we could use a ComboBox here instead? For autocompletion.
|
||||||
# TODO!: Key shortcuts for prev/next record, and hints on the buttons
|
# TODO!: Key shortcuts for prev/next record, and hints on the buttons
|
||||||
# TODO!: Radio Buttons on the flag
|
# TODO!: Radio Buttons on the flag
|
||||||
|
# Pretty hacky accelerators
|
||||||
|
char = name[0].lower()
|
||||||
|
self.bind_all(
|
||||||
|
f"<Alt-{char}>",
|
||||||
|
lambda event, fname=name: self.focus_txn_frame(fname),
|
||||||
|
)
|
||||||
|
|
||||||
txnrows[name] = (matchbox, keylabel, entrybox)
|
txnrows[name] = (matchbox, keylabel, entrybox)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user