simpleledger / Electron-Cash-SLP

Electron Cash for SLP Tokens
https://simpleledger.cash/project/electron-cash-slp-edition/
MIT License
67 stars 53 forks source link

some qt arguments want int, not float after python 3.8 -> 3.10 upgrade #243

Open molecular opened 2 years ago

molecular commented 2 years ago

I upgraded my python virtualenv for electron-cash-slp and ran into errors like this:

Traceback (most recent call last):
  File "/home/nick/bitcoin/electron-cash-slp/./electron-cash", line 594, in <module>
    main()
  File "/home/nick/bitcoin/electron-cash-slp/./electron-cash", line 582, in main
    result = run_gui(config, config_options)
  File "/home/nick/bitcoin/electron-cash-slp/./electron-cash", line 359, in run_gui
    daemon_thread.init_gui()
  File "/home/nick/bitcoin/electron-cash-slp/electroncash/daemon.py", line 363, in init_gui
    self.gui = gui.ElectrumGui(config, self, plugins)
  File "/home/nick/bitcoin/electron-cash-slp/electroncash_gui/qt/__init__.py", line 167, in __init__
    self._start_auto_update_timer(first_run = True)
  File "/home/nick/bitcoin/electron-cash-slp/electroncash_gui/qt/__init__.py", line 776, in _start_auto_update_timer
    self.update_checker_timer.start(interval)
TypeError: arguments did not match any overloaded call:
  start(self, int): argument 1 has unexpected type 'float'

upstream fix:

#a55dadc51075a8385e3d3c2c065fd0b92be107bc

what I did for now:

diff --git a/electroncash_gui/qt/__init__.py b/electroncash_gui/qt/__init__.py
index 9af943777..ec5be5bc6 100644
--- a/electroncash_gui/qt/__init__.py
+++ b/electroncash_gui/qt/__init__.py
@@ -773,7 +773,7 @@ class ElectrumGui(QObject, PrintError):
             interval = 10.0*1e3 # do it very soon (in 10 seconds)
         else:
             interval = 4.0*3600.0*1e3 # once every 4 hours (in ms)
-        self.update_checker_timer.start(interval)
+        self.update_checker_timer.start(int(interval))
         self.print_error("Auto update check: interval set to {} seconds".format(interval//1e3))

     def _stop_auto_update_timer(self):
diff --git a/electroncash_gui/qt/paytoedit.py b/electroncash_gui/qt/paytoedit.py
index 7fd380fd6..edcd31d81 100644
--- a/electroncash_gui/qt/paytoedit.py
+++ b/electroncash_gui/qt/paytoedit.py
@@ -231,7 +231,7 @@ class PayToEdit(PrintError, ScanQRTextEdit):
         docHeight = docLineCount * self.fontSpacing

         h = docHeight + self.verticalMargins
-        h = min(max(h, self.heightMin), self.heightMax)
+        h = int(min(max(h, self.heightMin), self.heightMax))

         self.setMinimumHeight(h)
         self.setMaximumHeight(h)
diff --git a/electroncash_gui/qt/util.py b/electroncash_gui/qt/util.py
index 358846d2c..5875c7e25 100644
--- a/electroncash_gui/qt/util.py
+++ b/electroncash_gui/qt/util.py
@@ -880,7 +880,7 @@ class OverlayControlMixin:
         if hasattr(self, 'verticalScrollBar') and self.verticalScrollBar().isVisible():
             scrollbar_width = self.style().pixelMetric(QStyle.PM_ScrollBarExtent)
             x -= scrollbar_width
-        self.overlay_widget.move(x, y)
+        self.overlay_widget.move(int(x), int(y))

     def addWidget(self, widget: QWidget, index: int = 0):
         if index is not None:
@@ -1167,7 +1167,7 @@ class RateLimiter(PrintError):
                 self.timer.timeout.connect(self._doIt)
                 #self.timer.destroyed.connect(lambda x=None,qn=self.qn: print(qn,"Timer deallocated"))
                 self.timer.setSingleShot(True)
-                self.timer.start(diff*1e3)
+                self.timer.start(int(diff*1e3))
                 #self.print_error("deferring")
         else:
             # We had a timer active, which means as future call will occur. So return early and let that call happenin the future.