diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index 531bb7a34..28392fa23 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -1237,6 +1237,10 @@ def icon_path(icon_basename: str): def read_QIcon(icon_basename: str) -> QIcon: return QIcon(icon_path(icon_basename)) +def read_QIcon_from_bytes(b: bytes) -> QIcon: + qp = QPixmap() + qp.loadFromData(b) + return QIcon(qp) class IconLabel(QWidget): HorizontalSpacing = 2 diff --git a/electrum/plugin.py b/electrum/plugin.py index ed1717844..ac84ad231 100644 --- a/electrum/plugin.py +++ b/electrum/plugin.py @@ -422,6 +422,14 @@ class BasePlugin(Logger): def settings_dialog(self, window): raise NotImplementedError() + def read_file(self, filename: str) -> bytes: + """ note: only for external plugins """ + import zipfile + plugin_file_path = os.path.join(self.parent.get_external_plugin_dir(), self.name + '.zip') + with zipfile.ZipFile(plugin_file_path) as myzip: + with myzip.open(os.path.join(self.name, filename)) as myfile: + s = myfile.read() + return s class DeviceUnpairableError(UserFacingException): pass class HardwarePluginLibraryUnavailable(Exception): pass