0

I just discovered the Python reflex module, I looked at the examples on the site and the videos on youtubed, but I could not make a counter that increases by the amount of a value we receive from the user, can anyone help?

import reflex as rx

from rxconfig import config

class Counter(rx.Base):
    count: int = 0
    m: int = 0

class State(rx.State):
    input_number: int = 0
    current: Counter = Counter(count=0,m=input_number)

    def increase(self,number:int):
        self.current.count +=  number
        self.current.m = number

def index() -> rx.Component:
    return rx.vstack(
        rx.input(
            name="input_number",
            type="number",
            placeholder="Type Your number:",
        ),
        rx.button(
            "Increase", on_click=State.increase("input_number"),
        ),
        rx.text(
            State.current.count
        ),
    )


app = rx.App()
app.add_page(index)

this is my attempt

0

Browse other questions tagged or ask your own question.