def __init__(self, app, page):
        self.app = app
        self.page = page

        # slider
        self.slider = lv.slider(page)
        self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 20)
        self.slider_label = lv.label(page)
        self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0)
        self.slider.set_event_cb(self.on_slider_changed)
        self.on_slider_changed(None)

        # style selector
        self.styles = [('Plain', lv.style_plain),
                       ('Plain color', lv.style_plain_color),
                       ('Pretty', lv.style_pretty),
                       ('Pretty color', lv.style_pretty_color)]

        self.style_selector = lv.ddlist(page)
        self.style_selector.align(self.slider, lv.ALIGN.IN_BOTTOM_LEFT, 0, 40)
        self.style_selector.set_options('\n'.join(x[0] for x in self.styles))
        self.style_selector.set_event_cb(self.on_style_selector_changed)

        self.counter_btn = lv.btn(page)
        self.counter_btn.set_size(140, 100)
        self.counter_btn.align(self.page, lv.ALIGN.IN_TOP_RIGHT, -20, 20)
        self.counter_label = lv.label(self.counter_btn)
        self.counter_label.set_text('Count')
        self.counter_btn.set_event_cb(self.on_counter_btn)
        self.counter = 0
Beispiel #2
0
    def __init__(self, app, page):
        self.app = app
        self.page = page

        # slider
        self.slider = lv.slider(page)
        self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 20)
        self.slider_label = lv.label(page)
        self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0)
        self.slider.set_event_cb(self.on_slider_changed)
        self.on_slider_changed(None)

        # style selector
        self.styles = [
            ("Plain", lv.style_plain),
            ("Plain color", lv.style_plain_color),
            ("Pretty", lv.style_pretty),
            ("Pretty color", lv.style_pretty_color),
        ]

        self.style_selector = lv.ddlist(page)
        self.style_selector.align(self.slider, lv.ALIGN.IN_BOTTOM_LEFT, 0, 40)
        self.style_selector.set_options("\n".join(x[0] for x in self.styles))
        self.style_selector.set_event_cb(self.on_style_selector_changed)

        # counter button
        self.counter_btn = lv.btn(page)
        self.counter_btn.set_size(80, 80)
        self.counter_btn.align(self.style_selector, lv.ALIGN.OUT_RIGHT_TOP, 40, 0)
        self.counter_label = lv.label(self.counter_btn)
        self.counter_label.set_text("Count")
        self.counter_btn.set_event_cb(self.on_counter_btn)
        self.counter = 0
    def profile_selector_init(self):
        """
        Initialize alloy reflow profile drop-down selector on the screen
        """
        # Alloy Label
        alloy_label = lv.label(self.main_scr)
        alloy_label.set_text('Solder Paste:')
        alloy_label.align(self.profile_title_label, lv.ALIGN.OUT_RIGHT_MID, 38,
                          0)

        this = self

        # paste alloy selection drop-down
        def alloy_select_handler(obj, event):
            if event == lv.EVENT.VALUE_CHANGED:
                profile_alloy_name = this.alloy_list[
                    alloy_select.get_selected()]
                this.profiles.load_profile_details(profile_alloy_name)
                this.profile_detail_init()

        # style_selector = lv.style_t()
        # lv.style_copy(style_selector, lv.style_pretty_color)
        alloy_select = lv.ddlist(self.main_scr)
        alloy_select.set_options('\n'.join(self.alloy_list))
        alloy_select.set_selected(self.profiles.get_default_alloy_index())
        alloy_select.set_event_cb(alloy_select_handler)
        alloy_select.set_fix_width(140)
        alloy_select.set_draw_arrow(True)
        alloy_select.align(alloy_label, lv.ALIGN.OUT_BOTTOM_LEFT, 2, 2)
        alloy_select.set_style(lv.ddlist.STYLE.BG, lv.style_pretty_color)
        alloy_select.set_style(lv.ddlist.STYLE.SEL, lv.style_pretty_color)
        return alloy_select
Beispiel #4
0
 def __init__(self, app, page):
     self.app = app
     self.page = page
     
     # slider 
     self.slider = lv.slider(page)
     self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 0)
     self.slider_label = lv.label(page)
     self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0)
     self.slider.set_action(self.on_slider_changed)
     self.on_slider_changed(0)
     
     # style selector
     self.styles = [('Plain', lv.style_plain), ('Plain color', lv.style_plain_color), ('Pretty', lv.style_pretty), ('Pretty color', lv.style_pretty_color)]
 
     self.style_selector = lv.ddlist(page)
     self.style_selector.align(self.slider, lv.ALIGN.IN_BOTTOM_LEFT, 0, 40)
     self.style_selector.set_options('\n'.join(x[0] for x in self.styles))
     self.style_selector.set_action(self.on_style_selector_changed)
Beispiel #5
0
    )

    TOUCH_READY = 1 #表示已经配置好触摸参数

#############################################
###############   Dropdown List #############
#############################################
def event_handler(obj, event):
    if event == lv.EVENT.VALUE_CHANGED:
        option = " "*10 # should be large enough to store the option
        obj.get_selected_str(option, len(option))
        # .strip() removes trailing spaces
        print("Option: \"%s\"" % option.strip())

if TOUCH_READY:

    # Create a drop down list
    ddlist = lv.ddlist(lv.scr_act())
    ddlist.set_options("\n".join([
                        "Apple",
                        "Banana",
                        "Orange",
                        "Melon",
                        "Grape",
                        "Raspberry"]))

    ddlist.set_fix_width(150)
    ddlist.set_draw_arrow(True)
    ddlist.align(None, lv.ALIGN.IN_TOP_MID, 0, 20)
    ddlist.set_event_cb(event_handler)
Beispiel #6
0
# Create a label on the button
label = lv.label(btn2)
label.set_text("Button 2")

"""
ADD A SLIDER
"""
slider = lv.slider(scr) # Create a slider
slider.set_size(round(scr.get_width() / 3), slider.get_height()) # Set the size
slider.align(btn1, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 20) # Align below the first button
slider.set_value(30, False) # Set the current value

"""
ADD A DROP DOWN LIST
"""
ddlist = lv.ddlist(scr) # Create a drop down list
ddlist.align(slider, lv.ALIGN.OUT_RIGHT_TOP, 50, 0) # Align next to the slider
ddlist.set_top(True) # Enable to be on the top when clicked
ddlist.set_options("None\nLittle\nHalf\nA lot\nAll")# Set the options
ddlist.set_event_cb(ddlist_event_cb) # Set function to call on new option is chosen

"""
CREATE A CHART
"""
chart = lv.chart(scr) # Create the chart
chart.set_size(round(scr.get_width() / 2), round(scr.get_width() / 4)) # Set the size
chart.align(slider, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 20) # Align below the slider
chart.set_series_width(3) # Set the line width

# Add a RED data series and set some points
dl1 = chart.add_series(lv.color_hex(0xFF0000))