示例#1
0
def main():
    """
    Write "Hello!"
    """
    bot = TurtlePlotBot()
    bot.setscale(2)
    bot.write("Hello!", "fonts/scripts.fnt")
    bot.done()
示例#2
0
def main(ui):
    """
    Write "Hello!"
    """
    message = "Hello!"
    ui.cls()
    width = ui.size(message, scale=2, font="fonts/scripts.fnt")
    column = ui.width // 2 - width // 2
    line = ui.height // 2 - 16
    ui.draw(message, column, line, scale=2, font="fonts/scripts.fnt")

    bot = TurtlePlotBot()
    bot.setscale(2)
    bot.write(message, "fonts/scripts.fnt")
    bot.done()
示例#3
0
def main():
    """
    Write text using user provided values
    """
    uio = oledui.UI() # pylint: disable-msg=invalid-name
    fonts = uos.listdir("/fonts")
    message = "Hello!"
    scale = 1

    form = [
        [uio.HEAD, 0, "Write A Message"],
        [uio.TEXT, 2, 0, "Message:"],
        [uio.STR, 3, 0, 16, message],
        [uio.TEXT, 5, 0, "Scale:"],
        [uio.INT, 5, 8, 2, scale],
    ]

    again = True
    while again:
        result = uio.form(form)
        if result:
            message = form[2][uio.VAL]
            scale = form[4][uio.VAL]
            font = 0
            response = 0
            font = uio.menu("Choose A Font", fonts, font)
            if font is not None:
                uio.cls(fonts[font], 0)
                uio.draw(message, 0, 32, "/fonts/" + fonts[font])
                response = uio.select(7, 0, ("Draw", "Back", "Cancel"), 0)
                if response[1] == 0:
                    uio.cls(0)
                    bot = TurtlePlotBot()
                    bot.setscale(scale)
                    bot.write(message, "/fonts/" + fonts[font])
                    bot.done()

                again = response[1] == 1
            else:
                again = False
        else:
            again = False
示例#4
0
'''
Write a message.
'''

from turtleplotbot import TurtlePlotBot
bot = TurtlePlotBot()

# make the text 2 times larger then default
bot.setscale(2)
bot.write("Hello!", "fonts/scripts.fnt")
bot.done()

__import__("menu")  # optional return to turtleplotbot menu
示例#5
0
def main(ui):
    """
    Write text using user provided values
    """
    fonts = [f for f in uos.listdir("/fonts") if f.endswith(".fnt")]
    fonts_len = len(fonts)
    message = "Hello!"
    scale = 0
    ok = 0

    form = [
        [ui.HEAD, 0, "Write A Message"],
        [ui.STR, 0, 2, "Message:", 0, 3, 16, message],
        [ui.SEL, 0, 5, "Scale:", 6, 5, ("1", "2", "3"), scale],
        [ui.OK, 0, 7, ("Next", "Cancel"), ok],
    ]

    again = True
    while again:
        btn, ok = ui.form(form)
        if btn == button.CENTER and ok == 0:
            message = form[1][ui.VAL]
            scale = form[2][ui.VAL] + 1
            font = 0
            font = ui.menu("Choose A Font", fonts, font)
            if font is not None:

                while again:
                    ui.cls(fonts[font], 0)
                    font_file = "/fonts/" + fonts[font]
                    width = ui.size(message, font=font_file, scale=scale)

                    ui.draw(message,
                            ui.width // 2 - width // 2,
                            ui.height // 2,
                            ui.fg,
                            font=font_file,
                            scale=scale)

                    response = 0
                    btn, response = ui.select(0, 7, ("Draw", "Back", "Quit"),
                                              response)
                    if btn == button.CENTER:
                        if response == 0:
                            ui.cls(0)
                            bot = TurtlePlotBot()
                            bot.setscale(scale)
                            bot.write(message, "/fonts/" + fonts[font])
                            bot.done()
                            again = False
                        elif response == 2:
                            again = False

                    if btn == button.UP:
                        font -= 1
                        font %= fonts_len

                    elif btn == button.DOWN:
                        font += 1
                        font %= fonts_len

        else:
            again = False