Example #1
0
def todolist():
    tasks = []

    put_html(r"""<h1 align="center"><strong>📝 To-Do List</strong></h1>""")
    with use_scope('tasks'):
        while True:
            task = input(
                type=TEXT,
                required=True,
                label='🏃 What are you going to do today?',
                placeholder='Add a task...',
                help_text='Try: "Write an article"',
            )
            tasks.append(task)

            clear('tasks')
            put_table(
                tdata=[[
                    task,
                    put_buttons(['Complete'],
                                onclick=partial(complete_task,
                                                task=task,
                                                tasks=tasks))
                ] for task in tasks],
                header=[
                    '🤩 Your Awesome Tasks',
                    '✅ Have you completed your task?',
                ],
            )
Example #2
0
 def update_table():
     with use_scope("updater_info", clear=True):
         local_commit = updater.get_commit(short_sha1=True)
         upstream_commit = updater.get_commit(
             f"origin/{updater.Branch}", short_sha1=True
         )
         put_table(
             [
                 [t("Gui.Update.Local"), *local_commit],
                 [t("Gui.Update.Upstream"), *upstream_commit],
             ],
             header=[
                 "",
                 "SHA1",
                 t("Gui.Update.Author"),
                 t("Gui.Update.Time"),
                 t("Gui.Update.Message"),
             ],
         )
     with use_scope("updater_detail", clear=True):
         put_text(t("Gui.Update.DetailedHistory"))
         history = updater.get_commit(
             f"origin/{updater.Branch}", n=20, short_sha1=True
         )
         put_table(
             [commit for commit in history],
             header=[
                 "SHA1",
                 t("Gui.Update.Author"),
                 t("Gui.Update.Time"),
                 t("Gui.Update.Message"),
             ],
         )
Example #3
0
 def update_table():
     with use_scope('updater_info', clear=True):
         local_commit = updater.get_commit(short_sha1=True)
         upstream_commit = updater.get_commit(
             f'origin/{updater.branch}', short_sha1=True)
         put_table([[t('Gui.Update.Local'), *local_commit],
                    [t('Gui.Update.Upstream'), *upstream_commit]],
                   header=[
                       '', 'SHA1',
                       t('Gui.Update.Author'),
                       t('Gui.Update.Time'),
                       t('Gui.Update.Message')
                   ])
Example #4
0
def hike():
    current_salary = input("Enter your current salary ($):", type=FLOAT)
    new_salary = input("Enter your new salary ($):", type=FLOAT)
    total_hike = (new_salary - current_salary)
    hike_per = (((new_salary - current_salary) / current_salary) * 100)
    put_markdown('# **Results**')
    put_html('<br><br>')
    put_markdown('Your Hike: %.1f. Hike percentage: %s' %
                 (total_hike, hike_per))
    put_html('<hr>')
    put_table([
        ['Hike($)', 'Hike (%)'],
        [total_hike, hike_per],
    ])
Example #5
0
 def update_table():
     with use_scope("updater_info", clear=True):
         local_commit = updater.get_commit(short_sha1=True)
         upstream_commit = updater.get_commit(
             f"origin/{updater.branch}", short_sha1=True)
         put_table(
             [
                 [t("Gui.Update.Local"), *local_commit],
                 [t("Gui.Update.Upstream"), *upstream_commit],
             ],
             header=[
                 "",
                 "SHA1",
                 t("Gui.Update.Author"),
                 t("Gui.Update.Time"),
                 t("Gui.Update.Message"),
             ],
         )
Example #6
0
def complete_task(choice: str, task: str, tasks):
    if choice == 'Complete':
        tasks.remove(task)

    clear('tasks')
    if tasks:
        put_table(
            tdata=[[
                put_text(task),
                put_buttons(['Complete'],
                            onclick=partial(complete_task,
                                            task=task,
                                            tasks=tasks))
            ] for task in tasks],
            header=[
                '🤩 Your Awesome Tasks',
                '✅ Have you completed your task?',
            ],
            scope='tasks',
        )
Example #7
0
def bmi():
    height = input("Input your height(cm):", type=FLOAT)
    weight = input("Input your weight(kg):", type=FLOAT)

    BMI = weight / (height / 100) ** 2

    top_status = [(16, 'Severely underweight'), (18.5, 'Underweight'),
                  (25, 'Normal'), (30, 'Overweight'),
                  (35, 'Moderately obese'), (float('inf'), 'Severely obese')]

    for top, status in top_status:
        if BMI <= top:
            put_markdown('# **Results**')
            put_html('<br><br>')
            put_markdown('Your BMI: `%.1f`. Category: `%s`' % (BMI, status))
            put_html('<hr>')
            put_table([
                ['Your BMI', 'Category'],
                [BMI, status],
            ])

            break
Example #8
0
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

import pywebio.output as out

out.put_table([
    ['Language', 'Ratings'],
    ['C', '15.95'],
    ['Java', '13.48'],
    ['Python', '10.47'],
    ['C++', '7.11'],
    ['C#', '4.58'],
    ['Visual Basic', '4.12'],
    ['JavaScript', '2.54'],
    ['PHP', '2.49'],
    ['R', '2.37'],
    ['SQL', '1.76'],
    ['Go', '1.46'],
    ['Swift', '1.38'],
    ['Perl', '1.30'],
    ['Assembly language', '1.30'],
    ['Ruby', '1.24'],
    ['MATLAB', '1.10'],
    ['Groovy', '0.99'],
    ['Rust', '0.92'],
    ['Objective-C', '0.85'],
    ['Dart', '0.77'],
])
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

import pywebio.output as out

values = [(x, "{:5.3f}".format(1.0 / x)) for x in range(1, 20)]

out.put_table(values)
# pout.put_code("""pin.slider("How old are you?", min_value=0, max_value=120)""")
# pin.slider("How old are you?", min_value=0, max_value=120)
#
# pout.put_code("""pin.checkbox("What toppings for pizza?", options=["pepperoni", "sausage", "chicken"])""")
# pin.checkbox("What toppings for pizza?", options=["pepperoni", "sausage", "chicken"])
#
# pout.put_code("""pin.select("Who's GOAT in NBA?", options=["Bryant", "Jordan", "James"])""")
# pin.select("Who's GOAT in NBA?", options=["Bryant", "Jordan", "James"])
#
# pout.put_code("""pin.radio("Are you ready to try pyWebIO?", options=["Yes", "No"])""")
# pin.radio("Are you ready to try pyWebIO?", options=["Yes", "No"])

pout.put_text("This is an awesome library.")

pout.put_table([("Col 1 Title", "Col 2 Title"),
                ("Row 1, Col 1", "Row 1, Col 2"),
                ("Row 2, Col 1", "Row 2, Col2")])

pout.put_markdown("# This is the Title")
pout.put_markdown("## This is the Subtitle")
pout.put_markdown("_Bold Text_")
pout.put_markdown("__Italic Text__")
pout.put_markdown("*__Bold & Italic__*")
pout.put_markdown("[google.com](google.com)")

pout.put_image(open("airplane.jpg", "rb").read())
pout.toast("Please Pay Attention!", duration=10)


def show_text():
    pout.toast("Button is clicked!", duration=10)
Example #11
0
from pywebio import input, output
from time import *

output.put_markdown("## Hi </fooders>")
output.put_markdown("<p>I am Jayant</p>")

output.put_table([["Name", "code"], ['Food', 11], ['Water', 12],
                  ['Sunlight', 13]])

with output.popup("Subscribe to the page"):
    output.put_text("Join Other Customer!")

food = input.select("Choose Your Favorite Food", ['Maggi', 'Noodles'])
output.put_text("You Choose", food, "from given list")

output.put_processbar('bar')

for i in range(1, 11):
    output.set_processbar('bar', i / 10)
    sleep(0.1)

output.put_markdown("Your Order is ready")

if food == "Maggi":
    with open("maggi.jpg", "rb+") as f:
        image = f.read()
else:
    with open("noodles.jpg", "rb+") as f:
        image = f.read()

output.put_image(image, height="100", width="100")