diff --git a/aqt/editor.py b/aqt/editor.py index ab0436784..298d1866e 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -125,6 +125,19 @@ class Editor: data64 = b''.join(base64.encodestring(data).splitlines()) return 'data:%s;base64,%s' % (mime, data64.decode('ascii')) + + def addButton(self, icon, cmd, func, tip="", label="", + id=None, toggleable=False, keys=None): + """Assign func to bridge cmd, register shortcut, return button""" + if cmd not in self._links: + self._links[cmd] = func + if keys: + QShortcut(QKeySequence(keys), self.widget, + activated = lambda s=self: func(s)) + btn = self._addButton(icon, cmd, tip=tip, label=label, + id=id, toggleable=toggleable) + return btn + def _addButton(self, icon, cmd, tip="", label="", id=None, toggleable=False): if icon: if os.path.isabs(icon):