Can I put input in a scope just like output? #122
liaoshian
started this conversation in
Feature request
Replies: 2 comments 5 replies
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
-
The BMI demo for grid input layout is here: from pywebio.input import *
from pywebio.output import *
from pywebio.pin import *
from pywebio.session import hold
def calculate(weight, height):
BMI = weight / (height / 100) ** 2
top_status = [(14.9, 'Severely underweight'), (18.4, 'Underweight'),
(22.9, 'Normal'), (27.5, 'Overweight'),
(40.0, 'Moderately obese'), (float('inf'), 'Severely obese')]
for top, status in top_status:
if BMI <= top:
return BMI, status
def main():
put_markdown("### BMI calculator")
result = output()
put_row([
put_column([
put_input("height", placeholder="Your Height(cm):", type=FLOAT),
put_input("weight", placeholder="Your Weight(kg):", type=FLOAT),
put_buttons(
['Submit'],
onclick=lambda _: result.reset('Your BMI: %.1f, category: %s' % calculate(pin.weight, pin.height))
)
]),
result
])
hold()
if __name__ == '__main__':
import pywebio
pywebio.start_server(main, port=8080, debug=True) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For example, I'd like to have a grid display structure with inputs in the left column and outputs in the right column, but currently there's no scope parameter in input or input_group.
Beta Was this translation helpful? Give feedback.
All reactions