コード例 #1
0
ファイル: draw_name.py プロジェクト: Kimbsy/EMF_20016
def draw(x, y, window):
    global obj
    global sty
    if len(obj) == 0:

        sty = ugfx.Style()
        sty.set_enabled([ugfx.RED, ugfx.BLACK, ugfx.GREY, ugfx.GREY])

        #ugfx.Imagebox(0,0,window.width(),window.height(),"apps/home/back.bmp",0, win2)
        ugfx.set_default_font(ugfx.FONT_NAME)
        l = ugfx.Label(5,
                       20,
                       310,
                       window.height() - 20,
                       database_get("display-name", "<not actually set yet>"),
                       parent=window)
        obj.append(l)
        ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
        obj.append(
            ugfx.Label(5,
                       0,
                       310,
                       20,
                       "My name is...",
                       parent=window,
                       style=sty))
        #ugfx.text(40,80,database_get("display-name", "<not set yet>"),ugfx.BLUE)
        #ugfx.circle(140,150,40,ugfx.GREEN)
        #ugfx.circle(160,150,40,ugfx.GREEN)
        #ugfx.circle(180,150,40,ugfx.GREEN)
        window.show()
    else:
        window.hide()
        window.show()
コード例 #2
0
    def __init__(self, text="Please Wait...", title="SHA2017Badge"):
        self.window = ugfx.Container(30, 30,
                                     ugfx.width() - 60,
                                     ugfx.height() - 60)
        self.window.show()
        self.window.text(5, 10, title, ugfx.BLACK)
        self.window.line(0, 30, ugfx.width() - 60, 30, ugfx.BLACK)
        self.label = ugfx.Label(5,
                                40,
                                self.window.width() - 10,
                                ugfx.height() - 40,
                                text=text,
                                parent=self.window)

        # Indicator to show something is going on
        self.indicator = ugfx.Label(ugfx.width() - 100,
                                    0,
                                    20,
                                    20,
                                    text="...",
                                    parent=self.window)
        self.timer = pyb.Timer(3)
        self.timer.init(freq=3)
        self.timer.callback(
            lambda t: self.indicator.visible(not self.indicator.visible()))
コード例 #3
0
def draw_badge():
	style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
	style.set_background(ugfx.html_color(0x800080))
	ugfx.clear(ugfx.html_color(0x800080))
	ugfx.set_default_style(style)
	# Logo stuff
	ugfx.display_image(
		int((ugfx.width() - logo_width) / 2),
		int((ugfx.height() - logo_height) / 2),
		logo_path
	)

	# Draw for people to see
	ugfx.orientation(90)
	# Draw introduction
	ugfx.set_default_font(ugfx.FONT_TITLE)
	ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER)
	# Process name
	name_setting = name("Set your name in the settings app")
	if len(name_setting) <= max_name:
		ugfx.set_default_font(ugfx.FONT_NAME)
	else:
		ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	# Draw name
	ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, name_setting, justification=ugfx.Label.CENTER)

	# Draw for wearer to see
	ugfx.orientation(270)
	ugfx.set_default_font(ugfx.FONT_SMALL)
	status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT)
コード例 #4
0
ファイル: main.py プロジェクト: jimc13/Mk4-Apps-1
def draw_name():
    intro_text = "Hi! I'm"
    intro_height = 30
    name_height = 60
    max_name = 8

    ugfx.orientation(90)
    ugfx.set_default_font(ugfx.FONT_TITLE)
    # Process name
    name_setting = name("Set your name in the settings app")
    if len(name_setting) <= max_name:
        ugfx.set_default_font(ugfx.FONT_NAME)
    else:
        ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)

    ugfx.Label(0,
               ugfx.height() - name_height - intro_height,
               ugfx.width(),
               intro_height,
               intro_text,
               justification=ugfx.Label.CENTER)
    ugfx.Label(0,
               ugfx.height() - name_height,
               ugfx.width(),
               name_height,
               name_setting,
               justification=ugfx.Label.CENTER)

    ugfx.orientation(270)
コード例 #5
0
ファイル: launcher.py プロジェクト: barmi/ibmkr_badge2018
    def Status(self, data=None):
        self.destroy()
        self.create_window()
        w = self.window
        y = 10
        gap = 5
        height = 35
        ugfx.Label(10, y, w.width() - 20, height, 'Platform: {}'.format(util.get_version()), parent=w)
        y += gap + height
        ugfx.Label(10, y, w.width() - 20, height, 'Release: {}'.format(uos.uname()[2]), parent=w)
        y += gap + height
        ugfx.Label(10, y, w.width() - 20, height, 'firmware:', parent=w)
        ugfx.set_default_font('IBMPlexMono_Bold18')
        y += height
        ugfx.Label(10, y, w.width() - 20, height + 10, '{}'.format(uos.uname()[3]), parent=w)
        ugfx.set_default_font(self.default_font)
        ugfx.set_default_font('IBMPlexSans_Regular18')
        self.create_status_box()
        ugfx.set_default_font(self.default_font)

        try:
            ota_data = ota.check_version()
        except ota.OtaException as e:
            self.set_status('Error: {}'.format(e))
        else:
            if ota_data:
                self.status_box.destroy()
                ugfx.Label(10, 180, 200, 40, text='New: {}'.format(ota_data['version']),
                    parent=w)
                self.btngroup = ButtonGroup(self.window, 190, 180, 110, 40, 10)
                self.btngroup.add('Upgrade', self.install_ota, ota_data)
                self.btngroup.end()
            else:
                self.set_status('Up to date')
コード例 #6
0
def display_person(person):
    top_left_logo()

    # try:
    #     resp = http.get("https://twitter.com/"+person['contact'].lstrip("@")+"/profile_image?size=mini").raise_for_status()
    #     url2 = ure.search('href=\"([^\"]+)',resp.content).group(1).decode('ascii')
    #     print(url2)
    #     img = http.get(url2).raise_for_status().content
    #     print(img)
    #     ugfx.display_image(180, 5, bytearray(img))
    # except Exception as ex:
    #     print(ex)

    ugfx.set_default_font(ugfx.FONT_TITLE)
    ugfx.Label(5, 90, 230, 40, person["username"], justification=ugfx.Label.LEFTTOP)
    ugfx.set_default_font(ugfx.FONT_SMALL)
    ugfx.text(200, 92, person["age"], ugfx.WHITE)

    ugfx.Label(5, 120, 230, 60, person["tag_line"])

    ugfx.Label(5, 200, 230, 40, person["looking_for"])
    ugfx.text(5, 190, "Looking for...", ugfx.RED)

    ugfx.text(5, 245, person["contact"], ugfx.BLUE)

    # ugfx.Button(0, 280, 100, 40, "< Edit profile", parent=None, shape=ugfx.Button.RECT, style=None)
    ugfx.Button(160, 280, 100, 40, "Swipe >", parent=None, shape=ugfx.Button.RECT, style=None)
コード例 #7
0
    def __init__(self, text="Please Wait...", title=version.dialog_title):
        self.window = ugfx.Container(30, 30,
                                     ugfx.width() - 60,
                                     ugfx.height() - 60)
        self.window.show()
        self.window.text(5, 10, title, ugfx.BLACK)
        self.window.line(0, 30, ugfx.width() - 60, 30, ugfx.BLACK)
        self.label = ugfx.Label(5,
                                40,
                                self.window.width() - 10,
                                ugfx.height() - 40,
                                text=text,
                                parent=self.window)

        # Indicator to show something is going on
        self.indicator = ugfx.Label(ugfx.width() - 100,
                                    0,
                                    20,
                                    20,
                                    text="...",
                                    parent=self.window)
        self.timer = machine.Timer(-1)
        self.timer.init(period=2000,
                        mode=self.timer.PERIODIC,
                        callback=lambda t: self.indicator.visible(
                            not self.indicator.visible()))
コード例 #8
0
def no_more(my_profile):
    top_left_logo()

    ugfx.set_default_font(ugfx.FONT_TITLE)
    ugfx.Label(5, 90, 230, 50, "You've swiped everybody!", justification=ugfx.Label.CENTERTOP)
    ugfx.set_default_font(ugfx.FONT_SMALL)
    ugfx.Label(5, 160, 230, 20, "Soz "+my_profile["username"], justification=ugfx.Label.CENTERTOP)
    ugfx.Label(5, 180, 230, 20, "Come back later ;)", justification=ugfx.Label.CENTERTOP)

    # ugfx.Button(0, 280, 100, 40, "< Edit profile", parent=None, shape=ugfx.Button.RECT, style=None)
    ugfx.Button(160, 280, 100, 40, "Try again >", parent=None, shape=ugfx.Button.RECT, style=None)
コード例 #9
0
ファイル: nomore.py プロジェクト: mjms3/emf2018
def screen(state):
    window = ugfx.Container(0, 0, 240, 320)
    window.show()

    top_left_logo()

    ugfx.set_default_font(ugfx.FONT_TITLE)
    l1 = ugfx.Label(5,
                    90,
                    230,
                    50,
                    "You've swiped everybody!",
                    parent=window,
                    justification=ugfx.Label.CENTERTOP)
    ugfx.set_default_font(ugfx.FONT_SMALL)
    l2 = ugfx.Label(5,
                    160,
                    230,
                    20,
                    "Soz " + state["profile"]["username"],
                    parent=window,
                    justification=ugfx.Label.CENTERTOP)
    l3 = ugfx.Label(5,
                    180,
                    230,
                    20,
                    "Come back later ;)",
                    parent=window,
                    justification=ugfx.Label.CENTERTOP)

    b2 = ugfx.Button(0,
                     280,
                     120,
                     40,
                     "< Edit profile",
                     parent=window,
                     shape=ugfx.Button.RECT,
                     style=None)
    b1 = ugfx.Button(120,
                     280,
                     120,
                     40,
                     "Try again >",
                     parent=window,
                     shape=ugfx.Button.RECT,
                     style=None)

    state['ui'].append(window)
    state['ui'].append(l1)
    state['ui'].append(l2)
    state['ui'].append(l3)
    state['ui'].append(b1)
    state['ui'].append(b2)
コード例 #10
0
    def __init__(self, parent):
        super().__init__()
        self.parent = parent
        self.views = {}
        self.current_view = None
        self.previous_view = None

        # Initialize Input
        ugfx.input_init()

        # A/B Button Handler
        ugfx.input_attach(ugfx.BTN_A, self.select_a_cb)
        ugfx.input_attach(ugfx.BTN_B, self.select_b_cb)

        # Title
        self.set_title('RPS Game')

        # Message Box
        self.message_box = ugfx.Label(0,
                                      self.container.height() - 88,
                                      self.container.width(),
                                      88,
                                      '',
                                      parent=self.container,
                                      style=styles.wb,
                                      justification=ugfx.Label.LEFT)

        # Status box
        self.create_status_box()

        # Message Popup
        self.message_popup_view = MessagePopupView(manager=self)
コード例 #11
0
 def title(self):
     ugfx.Label(5,
                5,
                310,
                40,
                text='IBM Developer Day 2018',
                parent=self.window)
コード例 #12
0
def showPage():
    global current_page
    # avoid out of bounds errors
    current_page = max(1, min(current_page, total_pages))
    
    start = (current_page - 1) * APPS_PER_PAGE
    end = start + APPS_PER_PAGE
    apps_on_current_page = all_apps[start:end]

    # Refresh page
    ugfx.clear(ugfx.html_color(EMF_PURPLE))

    # Write current page number and arrows
    ugfx.Label(0, 20, ugfx.width(), 20, "Page {} of {}".format(current_page, total_pages), justification=ugfx.Label.CENTER)

    if current_page > 1:
        ugfx.fill_polygon(10, 16, [[0, 10], [15, 20], [15, 0]], ugfx.WHITE)
        
    if current_page < total_pages:
        ugfx.fill_polygon(ugfx.width() - 30, 16, [[0, 0], [15, 10], [0, 20]], ugfx.WHITE)
    
    # Write app numbers and names
    i = 0
    yOffset = 45
    xOffset = 0
    for a in apps_on_current_page:
        # xOffset = (i % 3) * 8  # offset lines to match the physical layout of the keypad
        ugfx.area(20 + xOffset, yOffset + 2, 20, 20, ugfx.WHITE)
        ugfx.text(23 + xOffset, yOffset + 3, keypadLabels[i] + " ", EMF_PURPLE)

        ugfx.Label(46 + xOffset, yOffset + 3, ugfx.width(), 20, a['title'], justification=ugfx.Label.LEFT)
        yOffset = yOffset + 22
        i = i + 1

    while True:
        for key in keypad:
            keyIndex = keypad.index(key)
            if buttons.is_pressed(key) and (keyIndex < len(apps_on_current_page)):
                apps_on_current_page[keyIndex]['app'].boot()
                break

        if buttons.is_triggered(Buttons.JOY_Right) and (current_page is not total_pages):
            current_page = current_page + 1
            return
        if buttons.is_triggered(Buttons.JOY_Left) and (current_page is not 1):
            current_page = current_page - 1
            return
コード例 #13
0
def main():
    #h = DHT11(machine.Pin(33)) # J8
    h = DHT11(machine.Pin(26))  # J7

    ugfx.set_default_font('IBMPlexMono_Bold24')
    ugfx.clear()
    ugfx.Label(40, 0, 240, 60, text='DHT11/22 Demo')

    ugfx.set_default_font('IBMPlexMono_Regular24')
    l = ugfx.Label(40, 60, 240, 120, text='')

    while True:
        h.measure()
        h.temperature()
        l.text('temperature:{},humidity:{}'.format(h.temperature(),
                                                   h.humidity()))
        time.sleep(1)
コード例 #14
0
ファイル: launcher.py プロジェクト: barmi/ibmkr_badge2018
 def install_ota(self, data):
     self.destroy()
     print('On the air update..')
     self.create_window()
     ugfx.Label(80, 60, 160, 120, text='Upgrading..\nto {}'.format(data['version']),
         parent=self.window)
     print(data)
     ota.install_url(data['ota_url'], '/')
コード例 #15
0
ファイル: main.py プロジェクト: trandi/Mk4-Apps
    def setup_screen(self):
        """ Set up the screen and the labels that display
            values on it. 
        """
        ugfx.init()
        width=ugfx.width()
        height=ugfx.height()
        ugfx.clear(ugfx.html_color(0x800080))
        style = ugfx.Style()
        style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
        style.set_background(ugfx.html_color(0x800080))
        ugfx.set_default_style(style)
        ugfx.orientation(90)
        ugfx.set_default_font(ugfx.FONT_TITLE)
        ugfx.Label(0, 0, width, 60,"Air Quality", justification=ugfx.Label.CENTER)
        label_height=45
        self.ppm10_label = ugfx.Label(0, label_height, width, label_height,"PPM 10: starting", justification=ugfx.Label.CENTER)
        self.ppm25_label = ugfx.Label(0, label_height*2, width, label_height,"PPM 2.5: starting", justification=ugfx.Label.CENTER)

        self.temp_label = ugfx.Label(0, label_height*3, width, label_height,"Temp: starting", justification=ugfx.Label.CENTER)
        self.humid_label = ugfx.Label(0, label_height*4, width, label_height,"Humid: starting", justification=ugfx.Label.CENTER)
        self.error_label = ugfx.Label(0, label_height*5, width, label_height,"", justification=ugfx.Label.CENTER)
        self.message_label = ugfx.Label(0, label_height*6, width, label_height,"", justification=ugfx.Label.CENTER)
        self.error_count = 0
        self.error_message = ""
        self.neopix = Neopix()
        self.p10_decode = ((100,0x00ff00),(250,0xffff00),(350,0xff8000),(430,0xff0000),(-1,0xcc6600))
        self.p25_decode = ((60, 0x00ff00),(91, 0xffff00), (121,0xff8000),(251,0xff0000),(-1,0xcc6600))
コード例 #16
0
def prompt_text(description, init_text="", true_text="OK", false_text="Back", font=FONT_MEDIUM_BOLD, style=default_style_badge):
    """Shows a dialog and keyboard that allows the user to input/change a string

    Returns None if user aborts with button B
    """

    window = ugfx.Container(0, 0, ugfx.width(), ugfx.height())

    if false_text:
        true_text = "A: " + true_text
        false_text = "B: " + false_text

    ugfx.set_default_font(FONT_MEDIUM_BOLD)
    kb = ugfx.Keyboard(0, ugfx.height()//2, ugfx.width(), ugfx.height()//2, parent=window)
    edit = ugfx.Textbox(2, ugfx.height()//2-60, ugfx.width()-7, 25, text = init_text, parent=window)
    ugfx.set_default_font(FONT_SMALL)
    button_yes = ugfx.Button(2, ugfx.height()//2-30, ugfx.width()//2-6, 25 , true_text, parent=window)
    button_no = ugfx.Button(ugfx.width()//2+2, ugfx.height()//2-30, ugfx.width()//2-6, 25 , false_text, parent=window) if false_text else None
    ugfx.set_default_font(font)
    label = ugfx.Label(ugfx.width()//10, ugfx.height()//10, ugfx.width()*4//5, ugfx.height()*2//5-90, description, parent=window)

    try:
        window.show()
        # edit.set_focus() todo: do we need this?
        while True:
            sleep.wfi()
            ugfx.poll()
            if buttons.is_triggered(buttons.Buttons.BTN_A): return edit.text()
            if buttons.is_triggered(buttons.Buttons.BTN_B): return None
            if buttons.is_triggered(buttons.Buttons.BTN_Menu): return edit.text()
            if buttons.is_triggered(buttons.Buttons.BTN_0): edit.text(edit.text() + "0")
            if buttons.is_triggered(buttons.Buttons.BTN_1): edit.text(edit.text() + "1")
            if buttons.is_triggered(buttons.Buttons.BTN_2): edit.text(edit.text() + "2")
            if buttons.is_triggered(buttons.Buttons.BTN_3): edit.text(edit.text() + "3")
            if buttons.is_triggered(buttons.Buttons.BTN_4): edit.text(edit.text() + "4")
            if buttons.is_triggered(buttons.Buttons.BTN_5): edit.text(edit.text() + "5")
            if buttons.is_triggered(buttons.Buttons.BTN_6): edit.text(edit.text() + "6")
            if buttons.is_triggered(buttons.Buttons.BTN_7): edit.text(edit.text() + "7")
            if buttons.is_triggered(buttons.Buttons.BTN_8): edit.text(edit.text() + "8")
            if buttons.is_triggered(buttons.Buttons.BTN_9): edit.text(edit.text() + "9")
            if buttons.is_triggered(buttons.Buttons.BTN_Hash): edit.text(edit.text() + "#")
            if buttons.is_triggered(buttons.Buttons.BTN_Star): edit.text(edit.text() + "*")

    finally:
        window.hide()
        window.destroy()
        button_yes.destroy()
        if button_no: button_no.destroy()
        label.destroy()
        kb.destroy()
        edit.destroy();
    return
コード例 #17
0
 def __init__(self, text="Please Wait...", title="TiLDA"):
     self.window = ugfx.Container(30, 30,
                                  ugfx.width() - 60,
                                  ugfx.height() - 60)
     self.window.show()
     self.window.text(5, 10, title, TILDA_COLOR)
     self.window.line(0, 30, ugfx.width() - 60, 30, ugfx.BLACK)
     self.label = ugfx.Label(5,
                             40,
                             self.window.width() - 10,
                             ugfx.height() - 40,
                             text=text,
                             parent=self.window)
コード例 #18
0
def draw_trans():
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)])
	style.set_background(ugfx.html_color(0x55cdfc))
	ugfx.set_default_style(style)
	ugfx.display_image(0, 0, "home_trans/trans.png")

	# Logo stuff
	ugfx.display_image(
	    int((ugfx.width() - logo_width) / 2),
	    int((ugfx.height() - logo_height) / 2)+9,
	    trans_logo_path
	)

	# Draw for people to see
	ugfx.orientation(90)
	# Draw introduction
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be)])
	style.set_background(ugfx.html_color(0xf8b0be))
	ugfx.set_default_style(style)
	ugfx.set_default_font(ugfx.FONT_TITLE)
	ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER)
	# Prepare to draw name
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)])
	style.set_background(ugfx.html_color(0x55cdfc))
	ugfx.set_default_style(style)
	# Process name
	name_setting = name("Set your name in the settings app")
	if len(name_setting) <= max_name:
		ugfx.set_default_font(ugfx.FONT_NAME)
	else:
		ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
	# Draw name
	ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, name_setting, justification=ugfx.Label.CENTER)

	# Draw for wearer to see
	ugfx.orientation(270)
	ugfx.set_default_font(ugfx.FONT_SMALL)
	status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT)
コード例 #19
0
def main():
    ugfx.init()

    h = htu21d.HTU21D(25, 26)

    ugfx.set_default_font('IBMPlexMono_Bold48')
    l = ugfx.Label(40, 60, 240, 120, text='')

    while True:
        try:
            l.text('{:.1f} C\n{:.1f} %'.format(h.temperature, h.humidity))
        except OSError:
            l.text('OSError')
        time.sleep(0.5)
コード例 #20
0
def write_name():
    name_setting = name("Set your name in the settings app")
    if len(name_setting) <= max_name:
        ugfx.set_default_font(ugfx.FONT_NAME)
    else:
        ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
    # Draw name
    ugfx.orientation(90)
    ugfx.Label(0,
               ugfx.height() - name_height,
               ugfx.width(),
               name_height,
               name_setting,
               justification=ugfx.Label.CENTER,
               style=style)
コード例 #21
0
def prompt_text(description, init_text = "", true_text="OK", false_text="Back", width = 300, height = 200, font=ugfx.FONT_MEDIUM_BOLD, style=default_style_badge):
    """Shows a dialog and keyboard that allows the user to input/change a string

    Returns None if user aborts with button B
    """

    window = ugfx.Container(int((ugfx.width()-width)/2), int((ugfx.height()-height)/2), width, height, style=style)

    if false_text:
        true_text = "M: " + true_text
        false_text = "B: " + false_text

    if buttons.has_interrupt("BTN_MENU"):
        buttons.disable_interrupt("BTN_MENU")

    ugfx.set_default_font(ugfx.FONT_MEDIUM)
    kb = ugfx.Keyboard(0, int(height/2), width, int(height/2), parent=window)
    edit = ugfx.Textbox(5, int(height/2)-30, int(width*4/5)-10, 25, text = init_text, parent=window)
    ugfx.set_default_font(ugfx.FONT_SMALL)
    button_yes = ugfx.Button(int(width*4/5), int(height/2)-30, int(width*1/5)-3, 25 , true_text, parent=window)
    button_no = ugfx.Button(int(width*4/5), int(height/2)-30-30, int(width/5)-3, 25 , false_text, parent=window) if false_text else None
    ugfx.set_default_font(font)
    label = ugfx.Label(int(width/10), int(height/10), int(width*4/5), int(height*2/5)-60, description, parent=window)

    try:
        buttons.init()

        button_yes.attach_input(ugfx.BTN_MENU,0)
        if button_no: button_no.attach_input(ugfx.BTN_B,0)

        window.show()
        edit.set_focus()
        while True:
            pyb.wfi()
            ugfx.poll()
            #if buttons.is_triggered("BTN_A"): return edit.text()
            if buttons.is_triggered("BTN_B"): return None
            if buttons.is_triggered("BTN_MENU"): return edit.text()

    finally:
        window.hide()
        window.destroy()
        button_yes.destroy()
        if button_no: button_no.destroy()
        label.destroy()
        kb.destroy()
        edit.destroy();
    return
コード例 #22
0
ファイル: main.py プロジェクト: jimc13/Mk4-Apps-1
def init_label():

    ugfx.set_default_font(ugfx.FONT_MEDIUM)

    margin_v = 29
    margin_h = 18

    screen_w = 240
    screen_h = 320

    return ugfx.Label(
        margin_h,
        margin_v,  #x, y
        screen_w - (margin_h * 2),
        screen_h - (margin_v * 2),  # width, height
        _LOADING_TEXT)
コード例 #23
0
ファイル: manager.py プロジェクト: barmi/ibmkr_badge2018
    def main(self):
        self.create_window()
        self.title()
        self.btngroup = ButtonGroup(self.window, 80, 110, 140, 40, 10)
        self.widgets.append(self.btngroup)
        sta_if = network.WLAN(network.STA_IF)
        ugfx.Label(40,
                   60,
                   240,
                   30,
                   text=sta_if.ifconfig()[0],
                   parent=self.window)

        for menu in self.menus:
            self.btngroup.add(menu, getattr(self, menu))
        self.btngroup.end()
コード例 #24
0
def prompt_boolean(text, title="TiLDA", true_text="Yes", false_text="No", font=FONT_SMALL, style=None):
    """A simple one and two-options dialog

    if 'false_text' is set to None only one button is displayed.
    If both 'true_text' and 'false_text' are given a boolean is returned
    """
    global default_style_dialog
    if style == None:
        style = default_style_dialog
    ugfx.set_default_font(FONT_MEDIUM_BOLD)

    width = ugfx.width() - 10
    height = ugfx.height() - 10

    window = ugfx.Container(5, 5,  width, height)
    window.show()
    ugfx.set_default_font(font)
    window.text(5, 10, title, TILDA_COLOR)
    window.line(0, 30, width, 30, ugfx.BLACK)

    if false_text:
        true_text = "A: " + true_text
        false_text = "B: " + false_text

    ugfx.set_default_font(font)
    label = ugfx.Label(5, 30, width - 10, height - 80, text = text, parent=window)
    ugfx.set_default_font(FONT_MEDIUM_BOLD)
    button_yes = ugfx.Button(5, height - 40, width // 2 - 15 if false_text else width - 15, 30 , true_text, parent=window)
    button_no = ugfx.Button(width // 2 + 5, height - 40, width // 2 - 15, 30 , false_text, parent=window) if false_text else None

    try:
        #button_yes.attach_input(ugfx.BTN_A,0) # todo: re-enable once working
        #if button_no: button_no.attach_input(ugfx.BTN_B,0)

        window.show()

        while True:
            sleep.wfi()
            if buttons.is_triggered(buttons.Buttons.BTN_A): return True
            if buttons.is_triggered(buttons.Buttons.BTN_B): return False

    finally:
        window.hide()
        window.destroy()
        button_yes.destroy()
        if button_no: button_no.destroy()
        label.destroy()
コード例 #25
0
    def __init__(self, width=ugfx.width(), height=ugfx.height()):
        # Default font
        ugfx.set_default_font(self.default_font)

        # Container
        self.container = ugfx.Container(0,
                                        0,
                                        width,
                                        height,
                                        style=styles.ibm_st)

        # Title Label
        self.title_label = ugfx.Label(5,
                                      5,
                                      310,
                                      40,
                                      text='',
                                      parent=self.container)
コード例 #26
0
    def main(self):
        self.create_window()
        w = self.window
        self.title()
        self.list_apps()

        self.desc = ugfx.Textbox(160, 105, 155, w.height() - 115, parent=w)
        self.widgets.append(self.desc)
        self.version = ugfx.Label(160, 50, 155, 25, text='', parent=w)
        self.widgets.append(self.version)
        self.btngroup = ButtonGroup(self.window, 160, 75, 75, 25, 5, False)
        self.btngroup.add('Install', self.install_app)
        self.btngroup.add('Delete', self.delete_app)
        self.btngroup.end()
        self.widgets.append(self.btngroup)
        self.update_desc()

        self.input_attach()
コード例 #27
0
def draw_name():
    # Orientation for other people to see
    ugfx.orientation(90)

    ugfx.set_default_font(ugfx.FONT_NAME)

    # Process name
    given_name = homescreen.name("Set your name in the settings app")
    if len(given_name) <= max_name:
        ugfx.set_default_font(ugfx.FONT_NAME)
    else:
        ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
    # Draw name
    ugfx.Label(0,
               ugfx.height() - name_height,
               ugfx.width(),
               name_height,
               given_name,
               justification=ugfx.Label.CENTER)
コード例 #28
0
ファイル: main.py プロジェクト: tswsl1989/Mk4-Apps
def show_screen(type=None):
    if type == "horse":
        img = "praise_horse_worship_melon/horse.gif"
        color = ugfx.RED
        text = "HORSE!"
    elif type == "melon":
        img = "praise_horse_worship_melon/melon.gif"
        color = ugfx.BLUE
        text = "MELON!"
    else:
        return

    ugfx.area(0,0,ugfx.width(),ugfx.height(), color)
    ugfx.display_image(0, 0,img)
    ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
    for y_offset in range(8):
        ugfx.Label(0, 42 * y_offset, ugfx.width(), 20, text, parent=None, style=None, justification=ugfx.Label.CENTER)
        utime.sleep_ms(100)

    utime.sleep_ms(1000)
    loading_screen()
コード例 #29
0
    def _init_container(self, x, y, title, path_to_icon):
        self.container = ugfx.Container(
            x - _half_icon_size - _padding, y - _half_icon_size - _padding,
            _padded_size, _padded_size + _text_height,
            style=_icon_container_style
        )

        #This doesn't work reliably at the moment
        #ugfx.Imagebox(
        #    _padding - 2, _padding - 2,
        #    _icon_size, _icon_size,
        #    parent=self.container, text=path_to_icon
        #)

        self.label = ugfx.Label(
            0, _padded_size,
            _padded_size, _text_height,
            title, parent=self.container, justification=ugfx.Label.CENTERTOP
        )

        self.container.enabled(self._selected)
コード例 #30
0
def run_app(path):
	import buttons
	import ugfx
	import sys

	buttons.init()
	ugfx.init()
	ugfx.clear()

	if not buttons.has_interrupt("BTN_MENU"):
		buttons.enable_menu_reset()

	try:
		# Make libraries shipped by the app importable
		app_path = '/flash/' + '/'.join(path.split('/')[:-1])
		sys.path.append(app_path)

		mod = __import__(path)
		if "main" in dir(mod):
			mod.main()
	except Exception as e:
		import sys
		import uio
		import ugfx
		s = uio.StringIO()
		sys.print_exception(e, s)
		ugfx.clear()
		ugfx.set_default_font(ugfx.FONT_SMALL)
		w=ugfx.Container(0,0,ugfx.width(),ugfx.height())
		ugfx.Label(0,0,ugfx.width(),ugfx.height(),s.getvalue(),parent=w)
		w.show()
		raise(e)
	import stm
	stm.mem8[0x40002850] = 0x9C
	import pyb
	pyb.hard_reset()