commit aa3d817ef20f630333d06678c434564baf20b7a3
parent b8e4ce9ba1d3e8c600bd4f1ebe8055fb42d1152d
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 18 Nov 2019 20:56:49 +0100
qt: clean-up imports
Diffstat:
13 files changed, 42 insertions(+), 78 deletions(-)
diff --git a/electrum/gui/qt/amountedit.py b/electrum/gui/qt/amountedit.py
@@ -3,7 +3,7 @@
from decimal import Decimal
from PyQt5.QtCore import pyqtSignal, Qt
-from PyQt5.QtGui import QPalette, QPainter, QFontMetrics
+from PyQt5.QtGui import QPalette, QPainter
from PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame)
from .util import char_width_in_lineedit
diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py
@@ -1,19 +1,18 @@
# -*- coding: utf-8 -*-
import traceback
-import asyncio
from enum import IntEnum
-from PyQt5 import QtCore, QtWidgets, QtGui
+from PyQt5 import QtCore, QtGui
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit, QPushButton
+from PyQt5.QtWidgets import QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit
-from electrum.util import inv_dict, bh2u, bfh
+from electrum.util import bh2u
from electrum.i18n import _
from electrum.lnchannel import Channel
from electrum.wallet import Abstract_Wallet
-from electrum.lnutil import LOCAL, REMOTE, ConnStringFormatError, format_short_channel_id, LN_MAX_FUNDING_SAT
+from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDING_SAT
-from .util import MyTreeView, WindowModalDialog, Buttons, OkButton, CancelButton, EnterButton, WWLabel, WaitingDialog, HelpLabel
+from .util import MyTreeView, WindowModalDialog, Buttons, OkButton, CancelButton, EnterButton, WaitingDialog
from .amountedit import BTCAmountEdit
from .channel_details import ChannelDetailsDialog
diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py
@@ -24,25 +24,19 @@
# SOFTWARE.
from typing import TYPE_CHECKING, Optional
-import copy
-from PyQt5.QtCore import Qt, QSize
-from PyQt5.QtGui import QTextCharFormat, QBrush, QFont
-from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QGridLayout, QPushButton, QWidget, QTextEdit, QLineEdit, QCheckBox
+from PyQt5.QtWidgets import QVBoxLayout, QLabel, QGridLayout, QPushButton, QLineEdit
from electrum.i18n import _
-from electrum.util import quantize_feerate, NotEnoughFunds, NoDynamicFeeEstimates
+from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates
from electrum.plugin import run_hook
-from electrum.transaction import TxOutput, Transaction
-from electrum.simple_config import SimpleConfig, FEERATE_WARNING_HIGH_FEE
+from electrum.transaction import Transaction
+from electrum.simple_config import FEERATE_WARNING_HIGH_FEE
from electrum.wallet import InternalAddressCorruption
-from .util import WindowModalDialog, ButtonsLineEdit, ColorScheme, Buttons, CloseButton, FromList, HelpLabel, read_QIcon, char_width_in_lineedit, Buttons, CancelButton, OkButton
-from .util import MONOSPACE_FONT
+from .util import WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton
from .fee_slider import FeeSlider
-from .history_list import HistoryList, HistoryModel
-from .qrtextedit import ShowQRTextEdit
if TYPE_CHECKING:
from .main_window import ElectrumWindow
diff --git a/electrum/gui/qt/exception_window.py b/electrum/gui/qt/exception_window.py
@@ -21,9 +21,7 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-import platform
import sys
-import traceback
from PyQt5.QtCore import QObject
import PyQt5.QtCore as QtCore
diff --git a/electrum/gui/qt/invoice_list.py b/electrum/gui/qt/invoice_list.py
@@ -26,19 +26,17 @@
from enum import IntEnum
from PyQt5.QtCore import Qt, QItemSelectionModel
-from PyQt5.QtGui import QStandardItemModel, QStandardItem, QFont
+from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtWidgets import QAbstractItemView
-from PyQt5.QtWidgets import QHeaderView, QMenu, QVBoxLayout, QGridLayout, QLabel, QTreeWidget, QTreeWidgetItem
+from PyQt5.QtWidgets import QMenu, QVBoxLayout, QTreeWidget, QTreeWidgetItem
from electrum.i18n import _
from electrum.util import format_time, PR_UNPAID, PR_PAID, PR_INFLIGHT
from electrum.util import get_request_status
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
from electrum.lnutil import format_short_channel_id
-from electrum.bitcoin import COIN
-from electrum import constants
-from .util import (MyTreeView, read_QIcon, MONOSPACE_FONT,
+from .util import (MyTreeView, read_QIcon,
import_meta_gui, export_meta_gui, pr_icons)
from .util import CloseButton, Buttons
from .util import WindowModalDialog
diff --git a/electrum/gui/qt/lightning_dialog.py b/electrum/gui/qt/lightning_dialog.py
@@ -23,20 +23,21 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-from PyQt5.QtGui import QStandardItemModel, QStandardItem
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import (QDialog, QWidget, QLabel, QVBoxLayout, QCheckBox,
- QGridLayout, QPushButton, QLineEdit, QTabWidget)
+from typing import TYPE_CHECKING
+
+from PyQt5.QtWidgets import (QDialog, QLabel, QVBoxLayout, QPushButton)
from electrum.i18n import _
-from .util import HelpLabel, MyTreeView, Buttons
+from .util import Buttons
+if TYPE_CHECKING:
+ from . import ElectrumGui
class LightningDialog(QDialog):
- def __init__(self, gui_object):
+ def __init__(self, gui_object: 'ElectrumGui'):
QDialog.__init__(self)
self.gui_object = gui_object
self.config = gui_object.config
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -38,32 +38,30 @@ import queue
import asyncio
from typing import Optional, TYPE_CHECKING, Sequence, List, Union
-from PyQt5.QtGui import QPixmap, QKeySequence, QIcon, QCursor, QFont
+from PyQt5.QtGui import QPixmap, QKeySequence, QIcon, QCursor
from PyQt5.QtCore import Qt, QRect, QStringListModel, QSize, pyqtSignal
from PyQt5.QtWidgets import (QMessageBox, QComboBox, QSystemTrayIcon, QTabWidget,
- QSpinBox, QMenuBar, QFileDialog, QCheckBox, QLabel,
- QVBoxLayout, QGridLayout, QLineEdit, QTreeWidgetItem,
+ QMenuBar, QFileDialog, QCheckBox, QLabel,
+ QVBoxLayout, QGridLayout, QLineEdit,
QHBoxLayout, QPushButton, QScrollArea, QTextEdit,
QShortcut, QMainWindow, QCompleter, QInputDialog,
- QWidget, QMenu, QSizePolicy, QStatusBar)
+ QWidget, QSizePolicy, QStatusBar)
import electrum
-from electrum import (keystore, simple_config, ecc, constants, util, bitcoin, commands,
- coinchooser, paymentrequest)
+from electrum import (keystore, ecc, constants, util, bitcoin, commands,
+ paymentrequest)
from electrum.bitcoin import COIN, is_address
from electrum.plugin import run_hook
from electrum.i18n import _
from electrum.util import (format_time, format_satoshis, format_fee_satoshis,
- format_satoshis_plain, NotEnoughFunds,
- UserCancelled, NoDynamicFeeEstimates, profiler,
+ format_satoshis_plain,
+ UserCancelled, profiler,
export_meta, import_meta, bh2u, bfh, InvalidPassword,
- base_units, base_units_list, base_unit_name_to_decimal_point,
- decimal_point_to_base_unit_name, quantize_feerate,
+ decimal_point_to_base_unit_name,
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException,
get_new_wallet_name, send_exception_to_crash_reporter,
- InvalidBitcoinURI, InvoiceError)
+ InvalidBitcoinURI)
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
-from electrum.lnutil import PaymentFailure, SENT, RECEIVED
from electrum.transaction import (Transaction, PartialTxInput,
PartialTransaction, PartialTxOutput)
from electrum.address_synchronizer import AddTransactionException
@@ -74,7 +72,7 @@ from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed
from electrum.exchange_rate import FxThread
from electrum.simple_config import SimpleConfig
from electrum.logging import Logger
-from electrum.util import PR_PAID, PR_UNPAID, PR_INFLIGHT, PR_FAILED
+from electrum.util import PR_PAID, PR_FAILED
from electrum.util import pr_expiration_values
from electrum.lnutil import ln_dummy_address
@@ -85,12 +83,12 @@ from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .transaction_dialog import show_transaction
from .fee_slider import FeeSlider
from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialog,
- WindowModalDialog, ChoicesLayout, HelpLabel, FromList, Buttons,
+ WindowModalDialog, ChoicesLayout, HelpLabel, Buttons,
OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
CloseButton, HelpButton, MessageBoxMixin, EnterButton,
- ButtonsLineEdit, CopyCloseButton, import_meta_gui, export_meta_gui,
+ import_meta_gui, export_meta_gui,
filename_field, address_field, char_width_in_lineedit, webopen,
- MONOSPACE_FONT, TRANSACTION_FILE_EXTENSION_FILTER)
+ TRANSACTION_FILE_EXTENSION_FILTER)
from .util import ButtonsTextEdit
from .installwizard import WIF_HELP_TEXT
from .history_list import HistoryList, HistoryModel
diff --git a/electrum/gui/qt/qrtextedit.py b/electrum/gui/qt/qrtextedit.py
@@ -2,7 +2,6 @@ from PyQt5.QtWidgets import QFileDialog
from electrum.i18n import _
from electrum.plugin import run_hook
-from electrum.simple_config import SimpleConfig
from .util import ButtonsTextEdit, MessageBoxMixin, ColorScheme, get_parent_main_window
diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py
@@ -26,19 +26,14 @@
from enum import IntEnum
from PyQt5.QtGui import QStandardItemModel, QStandardItem
-from PyQt5.QtWidgets import QMenu, QHeaderView
+from PyQt5.QtWidgets import QMenu
from PyQt5.QtCore import Qt, QItemSelectionModel
from electrum.i18n import _
-from electrum.util import format_time, age, get_request_status
+from electrum.util import format_time, get_request_status
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
-from electrum.util import PR_UNPAID, PR_EXPIRED, PR_PAID, PR_UNKNOWN, PR_INFLIGHT, pr_tooltips
-from electrum.lnutil import SENT, RECEIVED
+from electrum.util import PR_PAID
from electrum.plugin import run_hook
-from electrum.wallet import InternalAddressCorruption
-from electrum.bitcoin import COIN
-from electrum.lnaddr import lndecode
-import electrum.constants as constants
from .util import MyTreeView, pr_icons, read_QIcon, webopen
diff --git a/electrum/gui/qt/seed_dialog.py b/electrum/gui/qt/seed_dialog.py
@@ -24,7 +24,7 @@
# SOFTWARE.
from PyQt5.QtCore import Qt
-from PyQt5.QtGui import QPixmap, QPalette
+from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import (QVBoxLayout, QCheckBox, QHBoxLayout, QLineEdit,
QLabel, QCompleter, QDialog, QStyledItemDelegate)
diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py
@@ -45,11 +45,10 @@ from electrum.bitcoin import base_encode
from electrum.i18n import _
from electrum.plugin import run_hook
from electrum import simple_config
-from electrum.util import bfh
from electrum.transaction import SerializationError, Transaction, PartialTransaction, PartialTxInput
from electrum.logging import get_logger
-from .util import (MessageBoxMixin, read_QIcon, Buttons, CopyButton, icon_path,
+from .util import (MessageBoxMixin, read_QIcon, Buttons, icon_path,
MONOSPACE_FONT, ColorScheme, ButtonsLineEdit, text_dialog,
char_width_in_lineedit, TRANSACTION_FILE_EXTENSION_FILTER)
diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py
@@ -872,22 +872,6 @@ def get_default_language():
name = QLocale.system().name()
return name if name in languages else 'en_UK'
-class FromList(QTreeWidget):
- def __init__(self, parent, create_menu):
- super().__init__(parent)
- self.setHeaderHidden(True)
- self.setMaximumHeight(300)
- self.setContextMenuPolicy(Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(create_menu)
- self.setUniformRowHeights(True)
- # remove left margin
- self.setRootIsDecorated(False)
- self.setColumnCount(2)
- self.header().setStretchLastSection(False)
- sm = QHeaderView.ResizeToContents
- self.header().setSectionResizeMode(0, sm)
- self.header().setSectionResizeMode(1, sm)
-
def char_width_in_lineedit() -> int:
char_width = QFontMetrics(QLineEdit().font()).averageCharWidth()
diff --git a/electrum/gui/qt/watchtower_dialog.py b/electrum/gui/qt/watchtower_dialog.py
@@ -25,11 +25,10 @@
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import (QDialog, QWidget, QLabel, QVBoxLayout, QCheckBox,
- QGridLayout, QPushButton, QLineEdit, QTabWidget)
+from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QPushButton)
from electrum.i18n import _
-from .util import HelpLabel, MyTreeView, Buttons
+from .util import MyTreeView, Buttons
class WatcherList(MyTreeView):