htag
raw JSON → 2.0.27 verified Sat May 09 auth: no python
htag is a Python GUI toolkit for building beautiful applications for mobile, web, and desktop from a single codebase, using a reactive component model similar to React. Version 2.0.27 runs on Python >= 3.10. It is actively maintained with regular releases.
pip install htag Common errors
error ImportError: cannot import name 'HTag' from 'htag' ↓
cause Incorrect import path or old version (<2.0).
fix
Install or upgrade to htag >= 2.0:
pip install -U htag, then use from htag import HTag. error AttributeError: 'MyApp' object has no attribute 'init' ↓
cause Component class defined `__init__` instead of `init`.
fix
Override
def init(self): (no underscores) in your component class. Warnings
breaking htag 2.0 dropped the old imperative API. The `HTag` class now uses a reactive pattern; components must override `init()` instead of `__init__`. ↓
fix Migrate components to subclass `HTag` and define `def init(self):` instead of `__init__`.
breaking The `run()` method signature changed. In htag 2.x, runners require an explicit import from `htag.runners`. ↓
fix Replace `HTag.run()` with explicit runner import, e.g., `from htag.runners import BrowserHTTP`.
gotcha Event handlers must be defined as methods of the HTag subclass, not as standalone functions or lambdas in some contexts. ↓
fix Define event handlers inside the class; use `self.bind(event, handler)` or decorate with `@HTag.event`.
Imports
- HTag
from htag import HTag - Tag wrong
from htag import Tagcorrectfrom htag.tag import Tag
Quickstart
from htag import HTag
class MyApp(HTag):
def init(self):
self += "Hello World!"
if __name__ == "__main__":
from htag.runners import BrowserHTTP
BrowserHTTP(MyApp).run()