diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index fd133c5d4..b87f9c62a 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -9,6 +9,7 @@ import html
import itertools
import json
import mimetypes
+import os
import re
import urllib.error
import urllib.parse
@@ -295,6 +296,8 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
disables: bool = True,
rightside: bool = True,
) -> str:
+ title_attribute = tip
+
if icon:
if icon.startswith("qrc:/"):
iconstr = icon
@@ -302,38 +305,34 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
iconstr = self.resourceToData(icon)
else:
iconstr = f"/_anki/imgs/{icon}.png"
- imgelm = f"""
"""
+ image_element = f'
'
else:
- imgelm = ""
- if label or not imgelm:
- labelelm = label or cmd
+ image_element = ""
+
+ if not label and icon:
+ label_element = ""
+ elif label:
+ label_element = label
else:
- labelelm = ""
- if id:
- idstr = f"id={id}"
- else:
- idstr = ""
- if toggleable:
- toggleScript = "toggleEditorButton(this);"
- else:
- toggleScript = ""
- tip = shortcut(tip)
- if rightside:
- class_ = "linkb"
- else:
- class_ = "rounded"
+ label_element = cmd
+
+ title_attribute = shortcut(title_attribute)
+ cmd_to_toggle_button = "toggleEditorButton(this);" if toggleable else ""
+ id_attribute_assignment = f"id={id}" if id else ""
+ class_attribute = "linkb" if rightside else "rounded"
if not disables:
- class_ += " perm"
+ class_attribute += " perm"
+
return f""""""
def setupShortcuts(self) -> None: