Notifications

Toast notification system for alerts, progress, and feedback

Overview#

The Notifications system provides toast notifications for displaying alerts, progress updates, and user feedback. Notifications appear in the top-right corner of the editor and support multiple types with automatic dismiss behavior.

Quick Start#

from witwin import Notifications
 
# Simple notifications
Notifications.info("Title", "This is an info message")
Notifications.success("Done", "Operation completed successfully")
Notifications.warning("Warning", "This might cause issues")
Notifications.error("Error", "Something went wrong")
 
# Progress notification
Notifications.progress("task_1", "Processing", 50, "Halfway done...")

API Reference#

from witwin import Notifications
 
# Notification types
Notifications.info(title, message)
Notifications.success(title, message)
Notifications.warning(title, message)
Notifications.error(title, message)
 
# Progress notification
Notifications.progress(id, title, progress, message=None)

Notification Types#

TypeColorUse Case
InfoBlueGeneral information
SuccessGreenCompleted operations
WarningYellowPotential issues
ErrorRedErrors and failures
ProgressBlueLong-running tasks

Usage Examples#

Basic Notifications#

from witwin import Notifications
 
# Information
Notifications.info("Welcome", "Connected to server")
 
# Success
Notifications.success("Saved", "Scene saved successfully")
 
# Warning
Notifications.warning("Memory", "High memory usage detected")
 
# Error
Notifications.error("Failed", "Could not load model")

Progress Notifications#

Progress notifications are updateable by ID:

from witwin import Notifications
 
# Start progress
Notifications.progress("export", "Exporting", 0, "Starting export...")
 
# Update progress
for i in range(100):
    process_frame(i)
    Notifications.progress("export", "Exporting", i + 1, f"Frame {i+1}/100")
 
# Complete
Notifications.success("Export Complete", "Video saved to output.mp4")

Training Progress#

from witwin import Notifications
 
for epoch in range(epochs):
    train_loss = train_epoch()
 
    # Show progress
    progress = int((epoch + 1) / epochs * 100)
    Notifications.progress(
        "training",
        "Training Model",
        progress,
        f"Epoch {epoch+1}/{epochs} - Loss: {train_loss:.4f}"
    )
 
Notifications.success("Training Complete", f"Final loss: {train_loss:.4f}")

Data Processing#

from witwin import Notifications
 
Notifications.info("Processing", "Starting data analysis...")
 
try:
    result = analyze_data(dataset)
    Notifications.success("Analysis Complete", f"Found {result.count} patterns")
except Exception as e:
    Notifications.error("Analysis Failed", str(e))

Behavior#

Auto-Dismiss#

TypeDefault Timeout
Info5 seconds
Success5 seconds
Warning8 seconds
ErrorManual dismiss
ProgressOn completion

Stacking#

  • Notifications stack vertically
  • Maximum visible: 5 notifications
  • Older notifications pushed up
  • Click to dismiss

Progress Updates#

  • Same ID updates existing notification
  • Different ID creates new notification
  • Progress 100 auto-dismisses after delay
  • Progress can be cancelled by not updating

Visual Layout#

┌────────────────────────────────┐
│        Editor Interface        │
│                                │
│                    ┌──────────┐│
│                    │ ✓ Saved  ││
│                    │ Success  ││
│                    └──────────┘│
│                    ┌──────────┐│
│                    │ ⚠ Memory ││
│                    │ Warning  ││
│                    └──────────┘│
│                    ┌──────────┐│
│                    │ ▶ Export ││
│                    │ ████░ 75%││
│                    └──────────┘│
└────────────────────────────────┘

Integration#

With Console#

Errors can be logged to both Console and Notifications:

from witwin import Console, Notifications
 
try:
    result = risky_operation()
except Exception as e:
    Console.error(f"Operation failed: {e}")
    Notifications.error("Operation Failed", str(e))

With Results#

Notify when results are ready:

from witwin import Results, Notifications
 
Results.plot(x, y, title="Analysis")
Results.commit(message="Final results")
Notifications.success("Results Ready", "Check the Results panel")