some fix to thread qdialog

This commit is contained in:
2026-05-19 12:41:41 -04:00
parent 5726ad2943
commit 242d1b137f
2 changed files with 25 additions and 27 deletions

50
qt.py
View File

@@ -49,7 +49,7 @@ from PyQt6.QtWidgets import (QAbstractItemView, QCheckBox, QComboBox,
QLineEdit, QTextEdit, QMenu, QMenuBar, QPushButton,
QScrollArea, QSizePolicy, QSpinBox,
QStackedWidget, QStyle, QStyleOptionFrame,
QVBoxLayout, QWidget)
QVBoxLayout, QWidget,QDialog)
from .bal import BalPlugin,BalTimestamp
from .heirs import HEIR_DUST_AMOUNT, HEIR_REAL_AMOUNT, Heirs
@@ -741,7 +741,7 @@ class BalWindow:
self.init_heirs_to_locktime(self.bal_plugin.ENABLE_MULTIVERSE.get())
except Exception as e:
log_error(e, self)
log_error(e )
_logger.error(f"init_class_variables: {e}")
raise e
@@ -1124,18 +1124,20 @@ class BalWindow:
def check_transactions_task(self, will):
start = time.time()
for wid, w in will.items():
self.waiting_dialog.update(
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
)
if w.we:
self.waiting_dialog.update(
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
)
w.set_check_willexecutor(Willexecutors.check_transaction(wid, w.we["url"]))
w.set_check_willexecutor(Willexecutors.check_transaction(wid, w.we["url"]))
if time.time() - start < 3:
time.sleep(3 - (time.time() - start))
def check_transactions(self, will):
def on_success(result):
del self.waiting_dialog
if hasattr(self,"waiting_dialog"):
del self.waiting_dialog
self.update_all()
pass
@@ -1172,7 +1174,7 @@ class BalWindow:
fn_on_failure = log_error
welist_server = self.bal_plugin.WELIST_SERVER.get()
task = partial(Willexecutors.download_list, willexecutors, welist_server)
msg = _(f"Downloadinf willexecutors list from {welist_server}")
msg = _(f"Downloading willexecutors list from {welist_server}")
self.waiting_dialog = BalWaitingDialog(
self, msg, task, on_success, on_failure, exe=False
)
@@ -1730,12 +1732,10 @@ class WillSettingsWidget(QWidget):
days_difference = (locktime - threshold).days
heirs_details = "\r\n".join(f" {heir} - {self.bal_window.heirs[heir][0]}, {self.bal_window.heirs[heir][1]}" for heir in self.bal_window.heirs)
print("heirs",heirs_details)
event_description = BalCalendar.ical_escape(
f"{self.bal_window.bal_plugin.EVENT_DESCRIPTION.get()}".replace("$wallet_name",str(self.bal_window.wallet)).replace("$heirs_complete",heirs_details)
)
#event_description =f"{event_description}{heirs_details}"
print("event description",event_description)
uid = f"bal-{str(self.bal_window.wallet)}"
summary = BalCalendar.ical_escape(
f"{self.bal_window.bal_plugin.EVENT_SUMMARY.get()}".replace("$wallet_name",str(self.bal_window.wallet))
@@ -1759,7 +1759,6 @@ class WillSettingsWidget(QWidget):
])
ics_content = "\r\n".join(lines) + "\r\n"
print(ics_content)
self.temp_path = BalCalendar.write_temp_ics(ics_content)
opened = BalCalendar.open_with_default_app(
self.bal_window.bal_plugin.CALENDAR_APP.get(), self.temp_path
@@ -1874,24 +1873,25 @@ class PercAmountEdit(BTCAmountEdit):
)
class BalDialog(WindowModalDialog):
class BalDialog(QDialog,MessageBoxMixin):
def __init__(self, parent, bal_plugin, title=None, icon="icons/bal16x16.png"):
self.parent = parent
self.thread = None
WindowModalDialog.__init__(self, parent, title)
super().__init__(parent)
if title:
self.setWindowTitle(title)
# WindowModalDialog.__init__(self,parent)
#print(bal_plugin.read_file(icon))
#self.setWindowIcon(read_QIcon_from_bytes(bal_plugin.read_file(icon)))
self.setWindowIcon(read_QIcon_from_bytes(bal_plugin.read_file(icon)))
def closeEvent(self, event):
self._stopping = True
if self.thread:
self.thread.stop()
#if self.thread:
# self.thread.stop()
def hideEvent(self, event):
self._stopping = True
if self.thread:
self.thread.stop()
#if self.thread:
# self.thread.stop()
class BalWizardDialog(BalDialog):
@@ -2714,6 +2714,7 @@ class BalBuildWillDialog(BalDialog):
button.clicked.connect(self.close)
self.vbox.addWidget(button)
self.resize(self.vbox.sizeHint()+button.sizeHint()*2)
self.repaint()
def on_error_phase2(self, error):
self.bal_window.upade_all()
a, b, c = error
@@ -3996,7 +3997,8 @@ class CheckAliveError(Exception):
def log_error(exec_info, window=None):
_logger.error(exec_info)
tb = traceback.format_exc()
#tb = traceback.format_exc()
tb=exec_info[1]
_logger.error(tb)
if window is not None:
window.show_error(exec_info)
@@ -4058,28 +4060,22 @@ class BalCalendar:
.replace(b";", b"\\;")
.replace(b",", b"\\,")
)
print("escaped",text)
out =""
temp=text.split(b"\r\n")
print("temp",temp)
for s in temp:
encoded= s
print("encoded",encoded)
cut =0
while len(encoded) >75:
cut+=5
encoded=f"{s[:len(s)-cut]}"
print("encoded -1",encoded[-1])
if encoded[-1]==b"\\" and encoded[-2]!=b"\\\\":
cut += 1
encoded=f"{s[:len(s)-cut]}"
encoded=f"{encoded}...\r\n".encode("utf-8")
print("cut",encoded,cut)
if cut>0:
out+=str(f"{s[:len(s)-cut].decode()}...\r\n")
else:
out+=str(f"{s.decode()}\r\n")
print("out",out)
return out[:-2]

View File

@@ -131,6 +131,8 @@ class Willexecutors:
def send_request(
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
):
import time
time.sleep(10)
network = Network.get_instance()
if not network:
raise Exception("You are offline.")