dreamweb

🚀 DreamWeb

A Flutter-like Python Web Framework

Build beautiful web UIs using pure Python with a Flutter-style API. No HTML, CSS, or JavaScript knowledge required!

✨ Features

🚀 Quick Start

Installation

pip install dreamweb

Create Your First App

from dreamweb import App
from dreamweb.common import *


class CounterApp(App):
    def __init__(self):
        super().__init__()
        self.count = State(0)
    
    def build(self):
        return Container(
            width="100%",
            height="100vh",
            background="gradient-purple-pink",
            align="center",
            justify="center",
            children=[
                Container(
                    width=400,
                    padding=40,
                    background="white",
                    rounded=16,
                    shadow="xl",
                    children=[
                        Text(
                            "Counter App",
                            size="2xl",
                            weight="bold",
                            color="gray-900"
                        ),
                        Text(
                            f"Count: {self.count.value}",
                            size="xl",
                            color="gray-700"
                        ),
                        Row(
                            spacing=10,
                            children=[
                                Button(
                                    text="Increment",
                                    color="blue",
                                    size="lg",
                                    on_click=lambda: self.count.set(self.count.value + 1)
                                )
                            ]
                        )
                    ]
                )
            ]
        )


if __name__ == "__main__":
    CounterApp().run(dev=True)

Run the App

python main.py

Visit http://localhost:8000 to see your app! 🎉

📚 Widget Library

Layout Widgets

Text Widgets

Input Widgets

API Widgets

# Example: Fetch data from an API
FetchData(
    url="https://api.github.com/users/octocat",
    on_success=lambda data: self.user.set(data),
    on_error=lambda error: print(error)
)

Media Widgets

Advanced (Raw HTML/CSS)

🎨 Styling

All styling is done through widget parameters:

Colors

Use named colors or hex values:

Sizes

Spacing

# Single value (all sides)
padding=20

# Dictionary (specific sides)
padding={'top': 10, 'right': 20, 'bottom': 10, 'left': 20}

🔄 State Management

from dreamweb import App
from dreamweb.common import *

class MyApp(App):
    def __init__(self):
        super().__init__()
        self.counter = State(0)
        self.name = State("John")
    
    def increment(self):
        self.counter.set(self.counter.value + 1)
    
    def build(self):
        return Text(f"Count: {self.counter.value}")

🏗️ Build for Production

# In your app file, change dev=True to dev=False
if __name__ == "__main__":
    MyApp().run(dev=False)

This will create a build/ directory with:

📖 Examples

Check the examples/ directory for:

🆚 Comparison

Feature DreamWeb Flutter Web Flet
Language Python Dart Python
Learning Curve ⭐⭐ ⭐⭐⭐⭐ ⭐⭐⭐
Hot Reload
Output HTML/JS WASM WebSocket
Styling Parameters Parameters Parameters
Raw HTML/CSS

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - feel free to use this in your projects!

🌟 Why DreamWeb?


Made with ❤️ by the DreamWeb team