コード例 #1
0
ファイル: screens.py プロジェクト: xavierfiechter/specter-diy
    def __init__(self, wallet, network, idx=None, branch_index=0):
        self.wallet = wallet
        self.network = network
        self.idx = wallet.unused_recv
        addr, gap = wallet.get_address(self.idx,
                                       network=network,
                                       branch_index=branch_index)
        super().__init__(
            "    " + wallet.name + "  #708092 " + lv.SYMBOL.EDIT,
            format_addr(addr, words=4),
            "bitcoin:" + addr,
            qr_width=350,
        )
        self.title.set_recolor(True)
        self.title.set_click(True)
        self.title.set_event_cb(on_release(self.rename))
        self.policy = add_label(wallet.policy, y=55, style="hint", scr=self)

        style = lv.style_t()
        lv.style_copy(style, self.message.get_style(0))
        style.text.font = lv.font_roboto_mono_22
        self.message.set_style(0, style)

        # index
        self.branch_index = branch_index
        self.note = add_label("%s address #%d" % (self.prefix, self.idx),
                              y=80,
                              style="hint",
                              scr=self)
        self.qr.align(self.note, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)
        self.message.align(self.qr, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)

        # warning label for address gap limit
        self.warning = add_label("", scr=self)
        self.warning.align(self.message, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)
        style = lv.style_t()
        lv.style_copy(style, self.note.get_style(0))
        style.text.color = lv.color_hex(0xFF9A00)
        self.warning.set_style(0, style)

        # delbtn = add_button("Delete wallet", on_release(cb_del), y=610)
        self.prv = add_button(lv.SYMBOL.LEFT, on_release(self.prev), scr=self)
        self.nxt = add_button(lv.SYMBOL.RIGHT, on_release(self.next), scr=self)
        if self.idx <= 0:
            self.prv.set_state(lv.btn.STATE.INA)
        self.prv.set_width(70)
        self.prv.align(self.qr, lv.ALIGN.OUT_LEFT_MID, -20, 0)
        self.prv.set_x(0)
        self.nxt.set_width(70)
        self.nxt.align(self.qr, lv.ALIGN.OUT_RIGHT_MID, 20, 0)
        self.nxt.set_x(HOR_RES - 70)

        self.menubtn = add_button(lv.SYMBOL.SETTINGS + " Settings",
                                  on_release(self.show_menu),
                                  scr=self)
        self.menubtn.align(self.close_button, lv.ALIGN.OUT_TOP_MID, 0, -20)

        if idx is not None:
            self.idx = idx
            self.update_address()
コード例 #2
0
    def __init__(self, title, message, note=None):
        super().__init__()
        self.title = add_label(title, scr=self, style="title")
        obj = self.title
        if note is not None:
            self.note = add_label(note, scr=self, style="hint")
            self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
            obj = self.note
        self.page = lv.page(self)
        self.page.set_size(480, 600)
        self.message = add_label(message, scr=self.page)
        self.page.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)

        (self.close_button, self.again_button) = add_button_pair(
            lv.SYMBOL.LEFT + " Back",
            on_release(cb_with_args(self.set_value, False)),
            "Roll again",
            on_release(cb_with_args(self.set_value, True)),
            scr=self,
        )
コード例 #3
0
 def __init__(self, name, policy, keys):
     super().__init__('Add wallet "%s"?' % name, "")
     self.policy = add_label("Policy: " + policy, y=75, scr=self)
     self.page.align(self.policy, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
     self.message.set_recolor(True)
     self.page.set_height(550)
     msg = ""
     for k in keys:
         if k["mine"]:
             msg += "#7ED321 My key: # %s\n\n" % k["key"]
         else:
             msg += "#F5A623 External key: # %s\n\n" % k["key"]
     self.message.set_text(msg)
コード例 #4
0
    def __init__(self, name, policy, keys):
        super().__init__('Add wallet "%s"?' % name, "")
        self.policy = add_label("Policy: " + policy, y=75, scr=self)

        lbl = lv.label(self)
        lbl.set_text(
            "Canonical xpub                     SLIP-132             ")
        lbl.align(self.policy, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
        self.slip_switch = lv.sw(self)
        self.slip_switch.align(lbl, lv.ALIGN.CENTER, 0, 0)
        self.slip_switch.set_event_cb(on_release(self.fill_message))

        self.page.align(self.policy, lv.ALIGN.OUT_BOTTOM_MID, 0, 70)
        self.message.set_recolor(True)
        self.page.set_height(500)
        self.keys = keys
        self.fill_message()
コード例 #5
0
    def __init__(self, title, message, note=None):
        super().__init__()
        self.title = add_label(title, scr=self, style="title")
        obj = self.title
        if note is not None:
            self.note = add_label(note, scr=self, style="hint")
            self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
            obj = self.note
        self.page = lv.page(self)
        self.page.set_size(480, 600)
        self.message = add_label(message, scr=self.page)
        self.page.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, -10)

        self.pips_1 = add_button("1",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_1)),
                                 scr=self)
        self.pips_1.set_width(130)
        self.pips_1.align(self.page, lv.ALIGN.OUT_LEFT_MID, 20, 20)
        self.pips_1.set_x(100)

        self.pips_2 = add_button("2",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_2)),
                                 scr=self)
        self.pips_2.set_width(130)
        self.pips_2.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 20)
        self.pips_2.set_x(HOR_RES - 230)

        self.pips_3 = add_button("3",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_3)),
                                 scr=self)
        self.pips_3.set_width(130)
        self.pips_3.align(self.page, lv.ALIGN.OUT_LEFT_MID, -20, 110)
        self.pips_3.set_x(100)

        self.pips_4 = add_button(u"4",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_4)),
                                 scr=self)
        self.pips_4.set_width(130)
        self.pips_4.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 110)
        self.pips_4.set_x(HOR_RES - 230)

        self.pips_5 = add_button("5",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_5)),
                                 scr=self)
        self.pips_5.set_width(130)
        self.pips_5.align(self.page, lv.ALIGN.OUT_LEFT_MID, -20, 200)
        self.pips_5.set_x(100)

        self.pips_6 = add_button("6",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_6)),
                                 scr=self)
        self.pips_6.set_width(130)
        self.pips_6.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 200)
        self.pips_6.set_x(HOR_RES - 230)

        (self.close_button, self.again_button) = add_button_pair(
            lv.SYMBOL.LEFT + " Back",
            on_release(cb_with_args(self.set_value, BACK)),
            "TODO: Use this seed",
            on_release(cb_with_args(self.set_value, USE_SEED)),
            scr=self,
        )