コード例 #1
0
    def __init__(self,
                 title="Alert!", 
                 message="Something happened", 
                 close_callback=None):

        super().__init__(close_callback)
        self.title = add_label(title, scr=self, style="title")
        self.page = lv.page(lv.scr_act())
        self.page.set_size(480, 550)
        self.message = add_label(message, scr=self.page)
        self.page.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 50)
コード例 #2
0
    def __init__(self,
                 buttons=[],
                 title="What do you want to do?",
                 note=None,
                 y0=60,
                 last=None):
        super().__init__()
        y = y0
        self.title = add_label(title, style="title", scr=self)
        if note is not None:
            self.note = add_label(note, style="hint", scr=self)
            self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
            y += self.note.get_height()
        self.page = lv.page(self)
        h = 800 - y - 20
        self.page.set_size(480, h)
        self.page.set_y(y)
        y = 0
        self.buttons = []
        # value, text, enable, color
        for value, text, *args in buttons:
            if text is not None:
                if value is not None:
                    enable = len(args) == 0 or args[0]
                    if enable:
                        cb = on_release(cb_with_args(self.set_value, value))
                    else:
                        cb = None
                    btn = add_button(text, cb, y=y, scr=self.page)
                    if not enable:
                        btn.set_state(lv.btn.STATE.INA)
                    # color
                    if len(args) > 1:
                        color = args[1]
                        style = lv.style_t()
                        lv.style_copy(style, btn.get_style(lv.btn.STYLE.REL))
                        style.body.main_color = lv.color_hex(color)
                        style.body.grad_color = lv.color_hex(color)
                        btn.set_style(lv.btn.STYLE.REL, style)

                    self.buttons.append(btn)
                    y += 85
                else:
                    add_label(text.upper(),
                              y=y + 10,
                              style="hint",
                              scr=self.page)
                    y += 50
            else:
                y += 40
        if last is not None:
            self.add_back_button(*last)
            self.page.set_height(h - 100)
コード例 #3
0
ファイル: prompt.py プロジェクト: The-Peso-G/specter-diy
    def __init__(self, title="Are you sure?", message="Make a choice"):
        super().__init__()
        self.title = add_label(title, scr=self, style="title")
        self.page = lv.page(self)
        self.page.set_size(480, 600)
        self.message = add_label(message, scr=self.page)
        self.page.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)

        (self.cancel_button, self.confirm_button) = add_button_pair(
            "Cancel",
            on_release(cb_with_args(self.set_value, False)),
            "Confirm",
            on_release(cb_with_args(self.set_value, True)),
            scr=self)
コード例 #4
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,
        )
コード例 #5
0
ファイル: alert.py プロジェクト: The-Peso-G/specter-diy
    def __init__(self,
                 title,
                 message,
                 button_text=(lv.SYMBOL.LEFT + " Back"),
                 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 = add_button(scr=self,
                                       callback=on_release(self.release))

        self.close_label = lv.label(self.close_button)
        self.close_label.set_text(button_text)
コード例 #6
0
    def __init__(self, manifest: DandelionAppManifest):
        super().__init__(manifest)

        self.container = super().get_container()
        self.container.set_style_local_bg_color(lv.cont.PART.MAIN,
                                                lv.STATE.DEFAULT,
                                                lv.color_hex(0x000000))

        self.manifests = Dandelion.discoverApplicationManifests()

        # Count apps
        self.numberOfApps = 0
        for m in self.manifests:
            if m.visibleInLauncher:
                self.numberOfApps += 1

        self.numberOfColumns = self.container.get_width() // 100

        # Scrollview
        self.scrollview = lv.page(self.container)
        self.scrollview.set_size(self.container.get_width(),
                                 self.container.get_height())
        self.scrollview.align(self.container, lv.ALIGN.IN_TOP_LEFT, 0, 0)
        self.scrollview.set_style_local_bg_opa(lv.page.PART.BG,
                                               lv.STATE.DEFAULT, lv.OPA._0)

        # Group
        self.scrollgroup = lv.group_create()

        # Populate pages
        index = 0
        for m in filter(lambda x: (x.visibleInLauncher), self.manifests):

            i = SpringboardIcon(self.scrollview, m)
            self.scrollgroup.add_obj(i)
            index += 1

        super().start()
コード例 #7
0
ファイル: menu.py プロジェクト: swipswaps/specter-diy
 def __init__(self,
              buttons=[],
              title="What do you want to do?",
              note=None,
              y0=80,
              last=None):
     super().__init__()
     y = y0
     self.title = add_label(title, style="title", scr=self)
     if note is not None:
         self.note = add_label(note, style="hint", scr=self)
         self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
         y += self.note.get_height()
     self.page = lv.page(self)
     h = 800 - y - 20
     self.page.set_size(480, h)
     self.page.set_y(y)
     y = 0
     for value, text in buttons:
         if text is not None:
             if value is not None:
                 add_button(text,
                            on_release(cb_with_args(self.set_value, value)),
                            y=y,
                            scr=self.page)
                 y += 85
             else:
                 add_label(text.upper(),
                           y=y + 10,
                           style="hint",
                           scr=self.page)
                 y += 50
         else:
             y += 40
     if last is not None:
         self.add_back_button(*last)
         self.page.set_height(h - 100)
コード例 #8
0
 def __init__(self, config):
     self.config = config
     self.sensor = MAX31855(hwspi=self.config['max31855_pins']['hwspi'],
                            cs=self.config['max31855_pins']['cs'],
                            miso=self.config['max31855_pins']['miso'],
                            sck=self.config['max31855_pins']['sck'],
                            offset=self.config['temp_offset'])
     self.oven = machine.Pin(self.config['oven_pin'], machine.Pin.OUT, value=0)
     self.temp_cali_scr = lv.obj()
     self.page = lv.page(self.temp_cali_scr)
     self.page.set_size(self.temp_cali_scr.get_width(), self.temp_cali_scr.get_height())
     self.page.align(None, lv.ALIGN.CENTER, 0, 0)
     self.label = lv.label(self.page)
     self.label.set_long_mode(lv.label.LONG.BREAK)
     self.label.set_width(self.page.get_fit_width())
     self.page_text = ''
     self.tim = machine.Timer(-1)
     self.start_time = None
     self.start_temp = None
     self.last_temp = None
     self.lag_temp = None
     self.lag_time = None
     self.cooling_counter = 0
     self.check_temp = 100
コード例 #9
0
    # Create a scroll bar style
    style_sb = lv.style_t()
    lv.style_copy(style_sb, lv.style_plain)
    style_sb.body.main_color = lv.color_make(0, 0, 0)
    style_sb.body.grad_color = lv.color_make(0, 0, 0)
    style_sb.body.border.color = lv.color_make(0xff, 0xff, 0xff)
    style_sb.body.border.width = 1
    style_sb.body.border.opa = lv.OPA._70
    style_sb.body.radius = 800  # large enough to make a circle
    style_sb.body.opa = lv.OPA._60
    style_sb.body.padding.right = 3
    style_sb.body.padding.bottom = 3
    style_sb.body.padding.inner = 8  # Scrollbar width

    # Create a page
    page = lv.page(lv.scr_act())
    page.set_size(240, 300)
    page.align(None, lv.ALIGN.CENTER, 0, 0)
    page.set_style(lv.page.STYLE.SB, style_sb)  # Set the scrollbar style

    # Create a label on the page
    label = lv.label(page)
    label.set_long_mode(lv.label.LONG.BREAK)  # Automatically break long lines
    label.set_width(page.get_fit_width(
    ))  # Set the label width to max value to not show hor. scroll bars
    label.set_text("""Lorem ipsum dolor sit amet, consectetur adipiscing elit,
    sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    Ut enim ad minim veniam, quis nostrud exercitation ullamco
    laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    dolor in reprehenderit in voluptate velit esse cillum dolore
    eu fugiat nulla pariatur.
コード例 #10
0
    def __init__(self, title, meta):
        send_amount = sum(
            [out["value"] for out in meta["outputs"] if not out["change"]])
        super().__init__(title, "")

        obj = self.message  # for alignments

        enable_inputs = len(
            [k for k in meta["inputs"] if k["sighash"] != "ALL"]) > 0

        lbl = add_label("Show detailed information                      ",
                        scr=self)
        lbl.align(obj, lv.ALIGN.CENTER, 0, 0)
        self.details_sw = lv.sw(self)
        self.details_sw.align(obj, lv.ALIGN.CENTER, 130, 0)
        self.details_sw.set_event_cb(on_release(self.toggle_details))
        if enable_inputs:
            self.details_sw.on(lv.ANIM.OFF)

        # change page a bit
        self.page.set_pos(0, lbl.get_y() + 20)
        self.page.set_size(480, 800 - 130 - lbl.get_y())

        self.page2 = lv.page(self)
        self.page2.set_pos(self.page.get_x(), self.page.get_y())
        self.page2.set_size(self.page.get_width(), self.page.get_height())

        # define styles
        style = lv.style_t()
        lv.style_copy(style, self.message.get_style(0))
        style.text.font = lv.font_roboto_mono_28

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

        style_secondary = lv.style_t()
        lv.style_copy(style_secondary, self.message.get_style(0))
        style_secondary.text.color = lv.color_hex(0x999999)
        style_secondary.text.font = lv.font_roboto_mono_22

        style_warning = lv.style_t()
        lv.style_copy(style_warning, self.message.get_style(0))
        style_warning.text.color = lv.color_hex(0xFF9A00)

        self.style = style
        self.style_secondary = style_secondary
        self.style_warning = style_warning

        num_change_outputs = 0
        for out in meta["outputs"]:
            # first only show destination addresses
            if out["change"]:
                num_change_outputs += 1
                continue
            obj = self.show_output(out, obj)

        if send_amount > 0:
            fee_percent = meta["fee"] * 100 / send_amount
            fee_txt = "%d satoshi (%.2f%%)" % (meta["fee"], fee_percent)
        # back to wallet
        else:
            fee_txt = "%d satoshi" % (meta["fee"])
        fee = add_label("Fee: " + fee_txt, scr=self.page)
        fee.set_style(0, style)
        fee.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)

        obj = fee

        # warning label for address gap limit
        if "warnings" in meta and len(meta["warnings"]) > 0:
            text = "WARNING!\n" + "\n".join(meta["warnings"])
            self.warning = add_label(text, scr=self.page)
            self.warning.set_style(0, style_warning)
            self.warning.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)

        lbl = add_label("%d INPUTS" % len(meta["inputs"]), scr=self.page2)
        lbl.align(self.page2, lv.ALIGN.IN_TOP_MID, 0, 30)
        obj = lbl
        for i, inp in enumerate(meta["inputs"]):
            idxlbl = lv.label(self.page2)
            idxlbl.set_text("%d:" % i)
            idxlbl.align(lbl, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
            idxlbl.set_x(30)
            lbl = lv.label(self.page2)
            lbl.set_long_mode(lv.label.LONG.BREAK)
            lbl.set_width(380)
            lbl.set_text("%.8f BTC from %s" %
                         (inp["value"] / 1e8, inp["label"]))
            lbl.align(idxlbl, lv.ALIGN.IN_TOP_LEFT, 0, 0)
            lbl.set_x(60)

            if inp["sighash"] != "ALL":
                shlbl = lv.label(self.page2)
                shlbl.set_long_mode(lv.label.LONG.BREAK)
                shlbl.set_width(380)
                shlbl.set_text(inp["sighash"])
                shlbl.align(lbl, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 5)
                shlbl.set_x(60)
                shlbl.set_style(0, style_warning)
                lbl = shlbl
            obj = lbl

        lbl = add_label("%d OUTPUTS" % len(meta["outputs"]), scr=self.page2)
        lbl.align(self.page2, lv.ALIGN.IN_TOP_MID, 0, 0)
        lbl.set_y(obj.get_y() + obj.get_height() + 30)
        for i, out in enumerate(meta["outputs"]):
            idxlbl = lv.label(self.page2)
            idxlbl.set_text("%d:" % i)
            idxlbl.align(lbl, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
            idxlbl.set_x(30)
            lbl = lv.label(self.page2)
            lbl.set_long_mode(lv.label.LONG.BREAK)
            lbl.set_width(380)
            lbl.set_text("%.8f BTC to %s" %
                         (out["value"] / 1e8, out.get("label", "")))
            lbl.align(idxlbl, lv.ALIGN.IN_TOP_LEFT, 0, 0)
            lbl.set_x(60)

            addrlbl = lv.label(self.page2)
            addrlbl.set_long_mode(lv.label.LONG.BREAK)
            addrlbl.set_width(380)
            addrlbl.set_text(format_addr(out["address"], words=4))
            addrlbl.align(lbl, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 5)
            addrlbl.set_x(60)
            if "label" in out:
                addrlbl.set_style(0, style_secondary)
            else:
                addrlbl.set_style(0, style_primary)
            lbl = addrlbl

        idxlbl = lv.label(self.page2)
        idxlbl.set_text("Fee:  " + fee_txt)
        idxlbl.align(lbl, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
        idxlbl.set_x(30)

        self.toggle_details()
コード例 #11
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,
        )
コード例 #12
0
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver

# create a page
page = lv.page(lv.scr_act(), None)
page.set_size(200, 200)
page.align(None, lv.ALIGN.CENTER, 0, 0)
# page.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)

# Create a label on the page
label = lv.label(page, None)
#label.set_long_mode(lv.label.LONG.BREAK);            # Automatically break long lines
label.set_width(lv.page.get_width_fit(page))
# Set the label width to max value to not show hor. scroll bars*/
label.set_text(
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n"
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"
    "Ut enim ad minim veniam, quis nostrud exercitation ullamco\n"
    "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure\n"
    "dolor in reprehenderit in voluptate velit esse cillum dolore\n"
    "eu fugiat nulla pariatur.\n"
    "Excepteur sint occaecat cupidatat non proident, sunt in culpa\n"
    "qui officia deserunt mollit anim id est laborum.")