https://github.com/Bbalduzz/flet_math
render LaTex formulas in flet
https://github.com/Bbalduzz/flet_math
Last synced: 3 days ago
JSON representation
render LaTex formulas in flet
- Host: GitHub
- URL: https://github.com/Bbalduzz/flet_math
- Owner: Bbalduzz
- License: other
- Created: 2025-03-16T14:17:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-19T10:08:25.000Z (over 1 year ago)
- Last Synced: 2025-06-02T20:27:22.184Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flet - flet_math - Renders LaTeX and TeX math formulas. Wraps [`flutter_math_fork`](https://pub.dev/packages/flutter_math_fork). (Extensions / Community Extensions)
README
A flet extension to render LaTex formulas
## Installation
available in pypi:
```cmd
pip install flet_math
```
1. Add the dependency to your `pyproject.toml`:
```toml
dependencies = [
"flet_math" # or flet_math @ git+https://github.com/Bbalduzz/flet_math.git
]
```
2. Build with `flet build`:
```cmd
flet build -v
```
## Basic Usage
Here's a simple example of rendering a mathematical equation:
```python
import flet as ft
from flet_math import Math
def main(page: ft.Page):
page.title = "Flet Math Example"
page.theme_mode = ft.ThemeMode.LIGHT
page.padding = 20
page.scroll = ft.ScrollMode.AUTO
page.add(
ft.Text("Flet Math - LaTeX Rendering", size=30, weight=ft.FontWeight.BOLD),
ft.Divider(),
ft.Text("Basic equation:", size=20),
Math(
tex=r"E = mc^2",
text_size=24,
),
)
page.update()
ft.app(target=main)
```
## Properties
The `Math` control supports the following properties:
### Core Properties
- `tex` (str): The LaTeX formula to render
- `text_color` (ColorValue): Color of the rendered text
- `text_size` (number): Size of the rendered text
- `font_family` (str): Font family for the text
- `font_weight` (FontWeight | str): Weight of the font
- `text_align` (TextAlign): Text alignment
- `selectable` (bool): Whether the text can be selected
### Layout Properties
- `cross_axis_alignment` (CrossAxisAlignment): Cross-axis alignment
- `main_axis_alignment` (MainAxisAlignment): Main-axis alignment
### Control Properties
- `width` (number): Width of the control
- `height` (number): Height of the control
- `expand` (bool): Whether to expand to fill available space
- `opacity` (number): Opacity of the control
- `tooltip` (str): Tooltip text
- `visible` (bool): Whether the control is visible
- `disabled` (bool): Whether the control is disabled
### Animation Properties
- `animate_opacity` (bool): Animate opacity changes
- `animate_position` (bool): Animate position changes
- `animate_scale` (bool): Animate scale changes
- `animate_size` (bool): Animate size changes
- `on_animation_end` (callable): Callback when animation ends
- `rotate` (number): Rotation angle
- `scale` (number): Scale factor