Browse Source

qt: clean-up imports

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
aa3d817ef2
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/qt/amountedit.py
  2. 11
      electrum/gui/qt/channels_list.py
  3. 16
      electrum/gui/qt/confirm_tx_dialog.py
  4. 2
      electrum/gui/qt/exception_window.py
  5. 8
      electrum/gui/qt/invoice_list.py
  6. 13
      electrum/gui/qt/lightning_dialog.py
  7. 30
      electrum/gui/qt/main_window.py
  8. 1
      electrum/gui/qt/qrtextedit.py
  9. 11
      electrum/gui/qt/request_list.py
  10. 2
      electrum/gui/qt/seed_dialog.py
  11. 3
      electrum/gui/qt/transaction_dialog.py
  12. 16
      electrum/gui/qt/util.py
  13. 5
      electrum/gui/qt/watchtower_dialog.py

2
electrum/gui/qt/amountedit.py

@ -3,7 +3,7 @@
from decimal import Decimal from decimal import Decimal
from PyQt5.QtCore import pyqtSignal, Qt 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 PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame)
from .util import char_width_in_lineedit from .util import char_width_in_lineedit

11
electrum/gui/qt/channels_list.py

@ -1,19 +1,18 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import traceback import traceback
import asyncio
from enum import IntEnum from enum import IntEnum
from PyQt5 import QtCore, QtWidgets, QtGui from PyQt5 import QtCore, QtGui
from PyQt5.QtCore import Qt 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.i18n import _
from electrum.lnchannel import Channel from electrum.lnchannel import Channel
from electrum.wallet import Abstract_Wallet 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 .amountedit import BTCAmountEdit
from .channel_details import ChannelDetailsDialog from .channel_details import ChannelDetailsDialog

16
electrum/gui/qt/confirm_tx_dialog.py

@ -24,25 +24,19 @@
# SOFTWARE. # SOFTWARE.
from typing import TYPE_CHECKING, Optional from typing import TYPE_CHECKING, Optional
import copy
from PyQt5.QtCore import Qt, QSize from PyQt5.QtWidgets import QVBoxLayout, QLabel, QGridLayout, QPushButton, QLineEdit
from PyQt5.QtGui import QTextCharFormat, QBrush, QFont
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QGridLayout, QPushButton, QWidget, QTextEdit, QLineEdit, QCheckBox
from electrum.i18n import _ 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.plugin import run_hook
from electrum.transaction import TxOutput, Transaction from electrum.transaction import Transaction
from electrum.simple_config import SimpleConfig, FEERATE_WARNING_HIGH_FEE from electrum.simple_config import FEERATE_WARNING_HIGH_FEE
from electrum.wallet import InternalAddressCorruption 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 WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton
from .util import MONOSPACE_FONT
from .fee_slider import FeeSlider from .fee_slider import FeeSlider
from .history_list import HistoryList, HistoryModel
from .qrtextedit import ShowQRTextEdit
if TYPE_CHECKING: if TYPE_CHECKING:
from .main_window import ElectrumWindow from .main_window import ElectrumWindow

2
electrum/gui/qt/exception_window.py

@ -21,9 +21,7 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
import platform
import sys import sys
import traceback
from PyQt5.QtCore import QObject from PyQt5.QtCore import QObject
import PyQt5.QtCore as QtCore import PyQt5.QtCore as QtCore

8
electrum/gui/qt/invoice_list.py

@ -26,19 +26,17 @@
from enum import IntEnum from enum import IntEnum
from PyQt5.QtCore import Qt, QItemSelectionModel 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 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.i18n import _
from electrum.util import format_time, PR_UNPAID, PR_PAID, PR_INFLIGHT from electrum.util import format_time, PR_UNPAID, PR_PAID, PR_INFLIGHT
from electrum.util import get_request_status from electrum.util import get_request_status
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
from electrum.lnutil import format_short_channel_id 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) import_meta_gui, export_meta_gui, pr_icons)
from .util import CloseButton, Buttons from .util import CloseButton, Buttons
from .util import WindowModalDialog from .util import WindowModalDialog

13
electrum/gui/qt/lightning_dialog.py

@ -23,20 +23,21 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
from PyQt5.QtGui import QStandardItemModel, QStandardItem from typing import TYPE_CHECKING
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QDialog, QWidget, QLabel, QVBoxLayout, QCheckBox, from PyQt5.QtWidgets import (QDialog, QLabel, QVBoxLayout, QPushButton)
QGridLayout, QPushButton, QLineEdit, QTabWidget)
from electrum.i18n import _ from electrum.i18n import _
from .util import HelpLabel, MyTreeView, Buttons
from .util import Buttons
if TYPE_CHECKING:
from . import ElectrumGui
class LightningDialog(QDialog): class LightningDialog(QDialog):
def __init__(self, gui_object): def __init__(self, gui_object: 'ElectrumGui'):
QDialog.__init__(self) QDialog.__init__(self)
self.gui_object = gui_object self.gui_object = gui_object
self.config = gui_object.config self.config = gui_object.config

30
electrum/gui/qt/main_window.py

@ -38,32 +38,30 @@ import queue
import asyncio import asyncio
from typing import Optional, TYPE_CHECKING, Sequence, List, Union 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.QtCore import Qt, QRect, QStringListModel, QSize, pyqtSignal
from PyQt5.QtWidgets import (QMessageBox, QComboBox, QSystemTrayIcon, QTabWidget, from PyQt5.QtWidgets import (QMessageBox, QComboBox, QSystemTrayIcon, QTabWidget,
QSpinBox, QMenuBar, QFileDialog, QCheckBox, QLabel, QMenuBar, QFileDialog, QCheckBox, QLabel,
QVBoxLayout, QGridLayout, QLineEdit, QTreeWidgetItem, QVBoxLayout, QGridLayout, QLineEdit,
QHBoxLayout, QPushButton, QScrollArea, QTextEdit, QHBoxLayout, QPushButton, QScrollArea, QTextEdit,
QShortcut, QMainWindow, QCompleter, QInputDialog, QShortcut, QMainWindow, QCompleter, QInputDialog,
QWidget, QMenu, QSizePolicy, QStatusBar) QWidget, QSizePolicy, QStatusBar)
import electrum import electrum
from electrum import (keystore, simple_config, ecc, constants, util, bitcoin, commands, from electrum import (keystore, ecc, constants, util, bitcoin, commands,
coinchooser, paymentrequest) paymentrequest)
from electrum.bitcoin import COIN, is_address from electrum.bitcoin import COIN, is_address
from electrum.plugin import run_hook from electrum.plugin import run_hook
from electrum.i18n import _ from electrum.i18n import _
from electrum.util import (format_time, format_satoshis, format_fee_satoshis, from electrum.util import (format_time, format_satoshis, format_fee_satoshis,
format_satoshis_plain, NotEnoughFunds, format_satoshis_plain,
UserCancelled, NoDynamicFeeEstimates, profiler, UserCancelled, profiler,
export_meta, import_meta, bh2u, bfh, InvalidPassword, export_meta, import_meta, bh2u, bfh, InvalidPassword,
base_units, base_units_list, base_unit_name_to_decimal_point, decimal_point_to_base_unit_name,
decimal_point_to_base_unit_name, quantize_feerate,
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException, UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException,
get_new_wallet_name, send_exception_to_crash_reporter, get_new_wallet_name, send_exception_to_crash_reporter,
InvalidBitcoinURI, InvoiceError) InvalidBitcoinURI)
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
from electrum.lnutil import PaymentFailure, SENT, RECEIVED
from electrum.transaction import (Transaction, PartialTxInput, from electrum.transaction import (Transaction, PartialTxInput,
PartialTransaction, PartialTxOutput) PartialTransaction, PartialTxOutput)
from electrum.address_synchronizer import AddTransactionException 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.exchange_rate import FxThread
from electrum.simple_config import SimpleConfig from electrum.simple_config import SimpleConfig
from electrum.logging import Logger 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.util import pr_expiration_values
from electrum.lnutil import ln_dummy_address from electrum.lnutil import ln_dummy_address
@ -85,12 +83,12 @@ from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .transaction_dialog import show_transaction from .transaction_dialog import show_transaction
from .fee_slider import FeeSlider from .fee_slider import FeeSlider
from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialog, 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, OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
CloseButton, HelpButton, MessageBoxMixin, EnterButton, 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, filename_field, address_field, char_width_in_lineedit, webopen,
MONOSPACE_FONT, TRANSACTION_FILE_EXTENSION_FILTER) TRANSACTION_FILE_EXTENSION_FILTER)
from .util import ButtonsTextEdit from .util import ButtonsTextEdit
from .installwizard import WIF_HELP_TEXT from .installwizard import WIF_HELP_TEXT
from .history_list import HistoryList, HistoryModel from .history_list import HistoryList, HistoryModel

1
electrum/gui/qt/qrtextedit.py

@ -2,7 +2,6 @@ from PyQt5.QtWidgets import QFileDialog
from electrum.i18n import _ from electrum.i18n import _
from electrum.plugin import run_hook from electrum.plugin import run_hook
from electrum.simple_config import SimpleConfig
from .util import ButtonsTextEdit, MessageBoxMixin, ColorScheme, get_parent_main_window from .util import ButtonsTextEdit, MessageBoxMixin, ColorScheme, get_parent_main_window

11
electrum/gui/qt/request_list.py

@ -26,19 +26,14 @@
from enum import IntEnum from enum import IntEnum
from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtWidgets import QMenu, QHeaderView from PyQt5.QtWidgets import QMenu
from PyQt5.QtCore import Qt, QItemSelectionModel from PyQt5.QtCore import Qt, QItemSelectionModel
from electrum.i18n import _ 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_TYPE_ONCHAIN, PR_TYPE_LN
from electrum.util import PR_UNPAID, PR_EXPIRED, PR_PAID, PR_UNKNOWN, PR_INFLIGHT, pr_tooltips from electrum.util import PR_PAID
from electrum.lnutil import SENT, RECEIVED
from electrum.plugin import run_hook 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 from .util import MyTreeView, pr_icons, read_QIcon, webopen

2
electrum/gui/qt/seed_dialog.py

@ -24,7 +24,7 @@
# SOFTWARE. # SOFTWARE.
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPalette from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import (QVBoxLayout, QCheckBox, QHBoxLayout, QLineEdit, from PyQt5.QtWidgets import (QVBoxLayout, QCheckBox, QHBoxLayout, QLineEdit,
QLabel, QCompleter, QDialog, QStyledItemDelegate) QLabel, QCompleter, QDialog, QStyledItemDelegate)

3
electrum/gui/qt/transaction_dialog.py

@ -45,11 +45,10 @@ from electrum.bitcoin import base_encode
from electrum.i18n import _ from electrum.i18n import _
from electrum.plugin import run_hook from electrum.plugin import run_hook
from electrum import simple_config from electrum import simple_config
from electrum.util import bfh
from electrum.transaction import SerializationError, Transaction, PartialTransaction, PartialTxInput from electrum.transaction import SerializationError, Transaction, PartialTransaction, PartialTxInput
from electrum.logging import get_logger 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, MONOSPACE_FONT, ColorScheme, ButtonsLineEdit, text_dialog,
char_width_in_lineedit, TRANSACTION_FILE_EXTENSION_FILTER) char_width_in_lineedit, TRANSACTION_FILE_EXTENSION_FILTER)

16
electrum/gui/qt/util.py

@ -872,22 +872,6 @@ def get_default_language():
name = QLocale.system().name() name = QLocale.system().name()
return name if name in languages else 'en_UK' 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: def char_width_in_lineedit() -> int:
char_width = QFontMetrics(QLineEdit().font()).averageCharWidth() char_width = QFontMetrics(QLineEdit().font()).averageCharWidth()

5
electrum/gui/qt/watchtower_dialog.py

@ -25,11 +25,10 @@
from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QDialog, QWidget, QLabel, QVBoxLayout, QCheckBox, from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QPushButton)
QGridLayout, QPushButton, QLineEdit, QTabWidget)
from electrum.i18n import _ from electrum.i18n import _
from .util import HelpLabel, MyTreeView, Buttons from .util import MyTreeView, Buttons
class WatcherList(MyTreeView): class WatcherList(MyTreeView):

Loading…
Cancel
Save