electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

question.py (1585B)


      1 from kivy.app import App
      2 from kivy.factory import Factory
      3 from kivy.properties import ObjectProperty
      4 from kivy.lang import Builder
      5 from kivy.uix.checkbox import CheckBox
      6 from kivy.uix.label import Label
      7 from kivy.uix.widget import Widget
      8 
      9 from electrum.gui.kivy.i18n import _
     10 
     11 Builder.load_string('''
     12 <Question@Popup>
     13     id: popup
     14     title: ''
     15     message: ''
     16     yes_str: ''
     17     no_str: ''
     18     size_hint: 0.8, 0.5
     19     pos_hint: {'top':0.9}
     20     BoxLayout:
     21         orientation: 'vertical'
     22         Label:
     23             id: label
     24             text: root.message
     25             text_size: self.width, None
     26         Widget:
     27             size_hint: 1, 0.1
     28         BoxLayout:
     29             orientation: 'horizontal'
     30             size_hint: 1, 0.2
     31             Button:
     32                 text: root.no_str
     33                 size_hint: 0.5, None
     34                 height: '48dp'
     35                 on_release:
     36                     root.callback(False)
     37                     popup.dismiss()
     38             Button:
     39                 text: root.yes_str
     40                 size_hint: 0.5, None
     41                 height: '48dp'
     42                 on_release:
     43                     root.callback(True)
     44                     popup.dismiss()
     45 ''')
     46 
     47 
     48 
     49 class Question(Factory.Popup):
     50 
     51     def __init__(self, msg, callback, *,
     52                  yes_str: str = None, no_str: str = None,
     53                  title: str = None):
     54         Factory.Popup.__init__(self)
     55         self.yes_str = yes_str or _('Yes')
     56         self.no_str = no_str or _('No')
     57         self.title = title or _('Question')
     58         self.message = msg
     59         self.callback = callback