readme
This commit is contained in:
62
README.md
62
README.md
@@ -74,6 +74,66 @@ data_table = await DataTable.create(api_endpoint="/api/users")
|
||||
|
||||
### Additional Components
|
||||
|
||||
#### FileDrop
|
||||
Drag-and-drop file upload component with customizable styling:
|
||||
|
||||
```python
|
||||
from niceguiex.components import FileDrop
|
||||
|
||||
def handle_files(files: List[Dict[str, Any]]):
|
||||
# For multiple files
|
||||
for file in files:
|
||||
print(f"File: {file['name']}, Size: {file['size']}")
|
||||
# Access content with file['content']
|
||||
|
||||
def handle_single_file(file: Dict[str, Any]):
|
||||
# For single file mode, returns dict directly
|
||||
print(f"Uploaded: {file['name']}")
|
||||
# Use file['path'] if return_content=False for large files
|
||||
|
||||
# Multiple files
|
||||
FileDrop(
|
||||
on_upload=handle_files,
|
||||
multiple=True,
|
||||
accept='.pdf,.txt,.docx',
|
||||
max_size=5 # 5MB limit
|
||||
)
|
||||
|
||||
# Single file with temp path (for large files)
|
||||
FileDrop(
|
||||
on_upload=handle_single_file,
|
||||
multiple=False,
|
||||
return_content=False # Returns temp file path instead of content
|
||||
)
|
||||
```
|
||||
|
||||
#### ImageDrop
|
||||
Specialized file drop for images that returns PIL Image objects:
|
||||
|
||||
```python
|
||||
from niceguiex.components import ImageDrop
|
||||
from PIL import Image
|
||||
|
||||
def handle_image(img: Image.Image):
|
||||
# Receives PIL Image object directly
|
||||
print(f"Image size: {img.size}")
|
||||
print(f"Image format: {img.format}")
|
||||
# Process image with PIL methods
|
||||
img.thumbnail((200, 200))
|
||||
img.save('thumbnail.jpg')
|
||||
|
||||
def handle_multiple_images(images: List[Image.Image]):
|
||||
# For multiple images, receives list of PIL Images
|
||||
for img in images:
|
||||
print(f"Processing {img.size[0]}x{img.size[1]} image")
|
||||
|
||||
ImageDrop(
|
||||
on_upload=handle_image,
|
||||
multiple=False,
|
||||
max_size=15 # 15MB limit
|
||||
)
|
||||
```
|
||||
|
||||
#### AutoScrollArea
|
||||
Automatically scrolling area that follows content as it's added:
|
||||
|
||||
@@ -96,7 +156,7 @@ with auto_scroll:
|
||||
Enhanced textarea for chat interfaces with Enter to send, Shift+Enter for new line:
|
||||
|
||||
```python
|
||||
from chat_input import ChatInput
|
||||
from niceguiex.components import ChatInput
|
||||
|
||||
async def handle_message(message: str):
|
||||
print(f"User sent: {message}")
|
||||
|
||||
Reference in New Issue
Block a user