A modern, GPU-accelerated Python UI framework.
Project description
NEUI (Neo UI)
NEUI is a modern, GPU-accelerated Python UI framework. It features a custom Flexbox-like layout engine, a React-inspired event system, and beautiful default styling.
Features
- Modern Look: Dark mode by default, rounded corners, and smooth rendering.
- Flexbox Layout: Easy
rowandcollayouts withjustify,align, andgap. - GPU Accelerated: Built on
skia-pythonandglfwfor high performance. - Interactive: Built-in support for Hover, Click, Focus, and Drag events.
- Components:
Box,Text,InputButton,Card,Toggle,Slider
Installation
pip install neui
Quick Start: Calculator App
from neui import App, ui, cui
class CalculatorApp:
def __init__(self):
self.display_text = "0"
self.display_element = None
self.current_op = None
self.prev_val = 0
self.new_entry = True
def on_digit(self, digit):
if self.new_entry:
self.display_text = str(digit)
self.new_entry = False
else:
self.display_text += str(digit)
self.update_display()
def on_op(self, op):
self.prev_val = float(self.display_text)
self.current_op = op
self.new_entry = True
def on_equal(self):
if self.current_op:
curr = float(self.display_text)
if self.current_op == '+': res = self.prev_val + curr
elif self.current_op == '-': res = self.prev_val - curr
elif self.current_op == '*': res = self.prev_val * curr
elif self.current_op == '/': res = self.prev_val / curr if curr != 0 else 0
if res.is_integer():
self.display_text = str(int(res))
else:
self.display_text = str(res)
self.current_op = None
self.new_entry = True
self.update_display()
def on_clear(self):
self.display_text = "0"
self.current_op = None
self.prev_val = 0
self.new_entry = True
self.update_display()
def update_display(self):
if self.display_element:
self.display_element.text = self.display_text
length = len(self.display_text)
if length > 10:
self.display_element.style['font_size'] = max(20, 40 - (length - 10) * 2)
else:
self.display_element.style['font_size'] = 40
def build(self):
app = App(title="NEUI Calculator", width=360, height=550)
with ui.Box(style={"bg": "#121212", "w": "100%", "h": "100%", "padding": 20, "layout": "col", "gap": 15}) as root:
# Display
with cui.Card(style={"w": "100%", "h": 100, "bg": "#1E1E1E", "justify": "end", "align": "end", "padding": 20}):
self.display_element = ui.Text("0", style={"font_size": 40, "color": "white", "weight": "bold"})
# Keypad
rows = [
['7', '8', '9', '/'],
['4', '5', '6', '*'],
['1', '2', '3', '-'],
['C', '0', '=', '+']
]
for row in rows:
with ui.Box(style={"layout": "row", "gap": 12, "w": "100%", "h": 70}):
for key in row:
color = "#333333"
if key in ['/', '*', '-', '+', '=']: color = "#FF9F0A"
if key == 'C': color = "#A5A5A5"
def make_handler(k):
if k.isdigit(): return lambda: self.on_digit(int(k))
if k in ['+', '-', '*', '/']: return lambda: self.on_op(k)
if k == '=': return self.on_equal
if k == 'C': return self.on_clear
return None
cui.Button(key, on_click=make_handler(key),
style={"w": 70, "h": 70, "bg": color, "radius": 35, "font_size": 28})
app.add(root)
app.run()
if __name__ == "__main__":
calc = CalculatorApp()
calc.build()
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
neui-0.1.1.tar.gz
(15.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
neui-0.1.1-py3-none-any.whl
(18.5 kB
view details)
File details
Details for the file neui-0.1.1.tar.gz.
File metadata
- Download URL: neui-0.1.1.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22483d154917396f84cf0084210d75e460937fd0465b7ccc9ea3938ca25f51a7
|
|
| MD5 |
85a5c0e180bb5266cfcc52211980ad0a
|
|
| BLAKE2b-256 |
02bfb0f71ea6cff1c83bc34fb4462db0606b66867ff3f301886040c5a91063d1
|
File details
Details for the file neui-0.1.1-py3-none-any.whl.
File metadata
- Download URL: neui-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ac1c9856db90a382e30ca8e619e6739086f23a5744fc60908e67499c697242
|
|
| MD5 |
27c857e5955ebafdec140b38f743788c
|
|
| BLAKE2b-256 |
004976e3c8ff9d234f4b22928bc4634dea6aabc1f89f5b5425237a9b8e2792bc
|