wizard: (trivial) add show_error to base class, document API
This commit is contained in:
@@ -685,3 +685,6 @@ class BaseWizard(Logger):
|
|||||||
self.line_dialog(run_next=f, title=title, message=message, default='', test=lambda x: x==passphrase)
|
self.line_dialog(run_next=f, title=title, message=message, default='', test=lambda x: x==passphrase)
|
||||||
else:
|
else:
|
||||||
f('')
|
f('')
|
||||||
|
|
||||||
|
def show_error(self, msg: Union[str, BaseException]) -> None:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|||||||
@@ -975,8 +975,8 @@ class ElectrumWindow(App):
|
|||||||
self.qr_dialog(label.name, label.data, True)
|
self.qr_dialog(label.name, label.data, True)
|
||||||
|
|
||||||
def show_error(self, error, width='200dp', pos=None, arrow_pos=None,
|
def show_error(self, error, width='200dp', pos=None, arrow_pos=None,
|
||||||
exit=False, icon='atlas://electrum/gui/kivy/theming/light/error', duration=0,
|
exit=False, icon='atlas://electrum/gui/kivy/theming/light/error', duration=0,
|
||||||
modal=False):
|
modal=False):
|
||||||
''' Show an error Message Bubble.
|
''' Show an error Message Bubble.
|
||||||
'''
|
'''
|
||||||
self.show_info_bubble( text=error, icon=icon, width=width,
|
self.show_info_bubble( text=error, icon=icon, width=width,
|
||||||
@@ -984,7 +984,7 @@ class ElectrumWindow(App):
|
|||||||
duration=duration, modal=modal)
|
duration=duration, modal=modal)
|
||||||
|
|
||||||
def show_info(self, error, width='200dp', pos=None, arrow_pos=None,
|
def show_info(self, error, width='200dp', pos=None, arrow_pos=None,
|
||||||
exit=False, duration=0, modal=False):
|
exit=False, duration=0, modal=False):
|
||||||
''' Show an Info Message Bubble.
|
''' Show an Info Message Bubble.
|
||||||
'''
|
'''
|
||||||
self.show_error(error, icon='atlas://electrum/gui/kivy/theming/light/important',
|
self.show_error(error, icon='atlas://electrum/gui/kivy/theming/light/important',
|
||||||
@@ -992,7 +992,7 @@ class ElectrumWindow(App):
|
|||||||
arrow_pos=arrow_pos)
|
arrow_pos=arrow_pos)
|
||||||
|
|
||||||
def show_info_bubble(self, text=_('Hello World'), pos=None, duration=0,
|
def show_info_bubble(self, text=_('Hello World'), pos=None, duration=0,
|
||||||
arrow_pos='bottom_mid', width=None, icon='', modal=False, exit=False):
|
arrow_pos='bottom_mid', width=None, icon='', modal=False, exit=False):
|
||||||
'''Method to show an Information Bubble
|
'''Method to show an Information Bubble
|
||||||
|
|
||||||
.. parameters::
|
.. parameters::
|
||||||
@@ -1002,6 +1002,7 @@ class ElectrumWindow(App):
|
|||||||
width: width of the Bubble
|
width: width of the Bubble
|
||||||
arrow_pos: arrow position for the bubble
|
arrow_pos: arrow position for the bubble
|
||||||
'''
|
'''
|
||||||
|
text = str(text) # so that we also handle e.g. Exception
|
||||||
info_bubble = self.info_bubble
|
info_bubble = self.info_bubble
|
||||||
if not info_bubble:
|
if not info_bubble:
|
||||||
info_bubble = self.info_bubble = Factory.InfoBubble()
|
info_bubble = self.info_bubble = Factory.InfoBubble()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
@@ -24,6 +25,10 @@ from . import EventsDialog
|
|||||||
from ...i18n import _
|
from ...i18n import _
|
||||||
from .password_dialog import PasswordDialog
|
from .password_dialog import PasswordDialog
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.gui.kivy.main_window import ElectrumWindow
|
||||||
|
|
||||||
|
|
||||||
# global Variables
|
# global Variables
|
||||||
is_test = (platform == "linux")
|
is_test = (platform == "linux")
|
||||||
test_seed = "grape impose jazz bind spatial mind jelly tourist tank today holiday stomach"
|
test_seed = "grape impose jazz bind spatial mind jelly tourist tank today holiday stomach"
|
||||||
@@ -1153,7 +1158,7 @@ class InstallWizard(BaseWizard, Widget):
|
|||||||
def show_message(self, msg): self.show_error(msg)
|
def show_message(self, msg): self.show_error(msg)
|
||||||
|
|
||||||
def show_error(self, msg):
|
def show_error(self, msg):
|
||||||
app = App.get_running_app()
|
app = App.get_running_app() # type: ElectrumWindow
|
||||||
Clock.schedule_once(lambda dt: app.show_error(msg))
|
Clock.schedule_once(lambda dt: app.show_error(msg))
|
||||||
|
|
||||||
def request_password(self, run_next, force_disable_encrypt_cb=False):
|
def request_password(self, run_next, force_disable_encrypt_cb=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user