diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py index 9911b55f2..6434a8fda 100644 --- a/gui/qt/history_widget.py +++ b/gui/qt/history_widget.py @@ -28,13 +28,18 @@ from electrum.plugins import run_hook class HistoryWidget(MyTreeWidget): def __init__(self, parent=None): - headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')] - run_hook('history_tab_headers', headers) - MyTreeWidget.__init__(self, parent, self.create_menu, headers, 3) + MyTreeWidget.__init__(self, parent, self.create_menu, [], 3) + self.refresh_headers() self.setColumnHidden(1, True) self.config = self.parent.config self.setSortingEnabled(False) + def refresh_headers(self): + headers = ['', '', _('Date'), _('Description') , _('Amount'), + _('Balance')] + run_hook('history_tab_headers', headers) + self.update_headers(headers) + def get_icon(self, conf, timestamp): time_str = _("unknown") if conf > 0: diff --git a/gui/qt/util.py b/gui/qt/util.py index 0504d9192..24207b5b7 100644 --- a/gui/qt/util.py +++ b/gui/qt/util.py @@ -303,9 +303,7 @@ class MyTreeWidget(QTreeWidget): editable_columns=None): QTreeWidget.__init__(self, parent) self.parent = parent - self.setColumnCount(len(headers)) - self.setHeaderLabels(headers) - self.header().setStretchLastSection(False) + self.stretch_column = stretch_column self.setContextMenuPolicy(Qt.CustomContextMenu) self.itemActivated.connect(self.on_activated) self.customContextMenuRequested.connect(create_menu) @@ -322,12 +320,19 @@ class MyTreeWidget(QTreeWidget): QAbstractItemView.EditKeyPressed) self.setItemDelegate(EditableItemDelegate(self)) self.itemChanged.connect(self.item_changed) - - # stretch - for i in range(len(headers)): - self.header().setResizeMode(i, QHeaderView.Stretch if i == stretch_column else QHeaderView.ResizeToContents) + self.update_headers(headers) self.setSortingEnabled(True) + def update_headers(self, headers): + self.setColumnCount(len(headers)) + self.setHeaderLabels(headers) + self.header().setStretchLastSection(False) + for col in range(len(headers)): + if col == self.stretch_column: + self.header().setResizeMode(col, QHeaderView.Stretch) + else: + self.header().setResizeMode(col, QHeaderView.ResizeToContents) + def on_activated(self, item): if not item: return diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index 43acf353c..32970a7d6 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -268,6 +268,7 @@ class Plugin(BasePlugin, ThreadJob): 'last_edited': {}} self.connect_fields(window, window.amount_e, send_e, window.fee_e) self.connect_fields(window, window.receive_amount_e, receive_e, None) + window.history_list.refresh_headers() window.update_status() def connect_fields(self, window, btc_e, fiat_e, fee_e): @@ -313,6 +314,7 @@ class Plugin(BasePlugin, ThreadJob): for window, data in self.windows.items(): for edit in data['edits']: edit.hide() + window.history_list.refresh_headers() window.update_status() def on_fx_history(self):