mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Merge pull request #200 from glutanimate/editor-button-labels
Reintroduce button labels for the Editor
This commit is contained in:
commit
ec27ca52b2
1 changed files with 18 additions and 6 deletions
|
@ -125,11 +125,19 @@ class Editor:
|
||||||
data64 = b''.join(base64.encodestring(data).splitlines())
|
data64 = b''.join(base64.encodestring(data).splitlines())
|
||||||
return 'data:%s;base64,%s' % (mime, data64.decode('ascii'))
|
return 'data:%s;base64,%s' % (mime, data64.decode('ascii'))
|
||||||
|
|
||||||
def _addButton(self, icon, cmd, tip="", id=None, toggleable=False):
|
def _addButton(self, icon, cmd, tip="", label="", id=None, toggleable=False):
|
||||||
|
if icon:
|
||||||
if os.path.isabs(icon):
|
if os.path.isabs(icon):
|
||||||
iconstr = self.resourceToData(icon)
|
iconstr = self.resourceToData(icon)
|
||||||
else:
|
else:
|
||||||
iconstr = "/_anki/imgs/{}.png".format(icon)
|
iconstr = "/_anki/imgs/{}.png".format(icon)
|
||||||
|
imgelm = '''<img class=topbut src="{}">'''.format(iconstr)
|
||||||
|
else:
|
||||||
|
imgelm = ""
|
||||||
|
if label or not imgelm:
|
||||||
|
labelelm = '''<span class=blabel>{}</span>'''.format(label or cmd)
|
||||||
|
else:
|
||||||
|
labelelm = ""
|
||||||
if id:
|
if id:
|
||||||
idstr = 'id={}'.format(id)
|
idstr = 'id={}'.format(id)
|
||||||
else:
|
else:
|
||||||
|
@ -139,8 +147,12 @@ class Editor:
|
||||||
else:
|
else:
|
||||||
toggleScript = ''
|
toggleScript = ''
|
||||||
tip = shortcut(tip)
|
tip = shortcut(tip)
|
||||||
return '''<button tabindex=-1 {id} class=linkb type="button" title="{tip}" onclick="pycmd('{cmd}');{togglesc}return false;">
|
return ('''<button tabindex=-1 {id} class=linkb type="button" title="{tip}"'''
|
||||||
<img class=topbut src="{icon}"></button>'''.format(icon=iconstr, cmd=cmd, tip=tip, id=idstr, togglesc=toggleScript)
|
''' onclick="pycmd('{cmd}');{togglesc}return false;">'''
|
||||||
|
'''{imgelm}{labelelm}</button>'''.format(
|
||||||
|
imgelm=imgelm, cmd=cmd, tip=tip, labelelm=labelelm, id=idstr,
|
||||||
|
togglesc=toggleScript)
|
||||||
|
)
|
||||||
|
|
||||||
def setupShortcuts(self):
|
def setupShortcuts(self):
|
||||||
cuts = [
|
cuts = [
|
||||||
|
|
Loading…
Reference in a new issue