Rio: Build Web and Desktop Apps in Pure Python, No JavaScript Needed

Summary
Rio is an innovative Python framework that allows developers to create web and desktop applications using pure Python, eliminating the need for HTML, CSS, or JavaScript. It provides a modern, declarative UI approach with over 50 built-in components, making app development efficient and enjoyable. With Rio, you can build powerful, type-safe applications that run seamlessly across different environments.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
Rio is an innovative framework that empowers developers to build web and desktop applications entirely in Python. It removes the need for traditional web technologies like HTML, CSS, and JavaScript, offering a streamlined development experience. With Rio, you can create modern, interactive user interfaces using a declarative approach, leveraging Python's simplicity and power.
Installation
Getting started with Rio is straightforward. You can install it using pip:
pip install rio-ui
After installation, you can quickly scaffold a new project using the Rio command-line utility:
rio new my-project --type website --template "Tic-Tac-Toe"
cd my-project
rio run
Examples
Rio adopts a component-based architecture, similar to React, making UI development intuitive. Here's a simple example demonstrating a button click counter:
# Define a component that counts button clicks
class ButtonClicker(rio.Component):
# Define the attributes of the component. Rio will watch these
# for changes and automatically update the GUI.
clicks: int = 0
# Define a method that increments the click count. We'll later
# make a button that calls this method whenever it is pressed.
def _on_press(self) -> None:
self.clicks += 1
# Define the `build` method. This method essentially tells Rio
# what a ButtonClicker component looks like. Whenever the state
# of the ButtonClicker component changes, Rio will call its
# `build` method and update the GUI according to the output.
def build(self) -> rio.Component:
return rio.Column(
rio.Button('Click me', on_press=self._on_press),
rio.Text(f'You clicked the button {self.clicks} time(s)'),
)
# Create an App and tell it to display a ButtonClicker when it starts
app = rio.App(build=ButtonClicker)
app.run_in_browser() # Or `app.run_in_window()` to run as local app!
Why Use Rio
Rio stands out for several compelling reasons:
- 100% Python: Develop full-stack applications without touching HTML, CSS, or JavaScript.
- Declarative UI: Enjoy a modern, intuitive way to build user interfaces.
- Rich Component Library: Access over 50 built-in components for common UI elements.
- Type-Safe: Integrates seamlessly with modern Python tooling, offering instant suggestions and problem highlighting.
- Versatile Deployment: Run your applications locally as desktop apps or deploy them as web applications.
- Open Source: A free and actively developed framework with a supportive community.
Links
Explore Rio further with these official resources: