Complete technical documentation for developers
---
The main application class providing a complete GUI framework with professional timer and ETA tracking.
from bravura import get_audio_analyzer_framework
# Get the framework class
AppClass = get_audio_analyzer_framework()
# Create instance
app = AppClass(root=None, **kwargs)
root (tk.Tk, optional): Existing tkinter root window. If None, creates new window.**kwargs: Additional configuration options
# Set window properties
app.set_title(title: str) # Set window title
app.set_geometry(geometry: str) # Set size "WIDTHxHEIGHT+X+Y"
app.set_min_size(width: int, height: int) # Set minimum window size
app.set_resizable(width: bool, height: bool) # Enable/disable resizing
app.set_icon(icon_path: str) # Set window icon
# Window control
app.run() # Start main event loop
app.close() # Close application
app.minimize() # Minimize window
app.maximize() # Maximize window
app.center_window() # Center on screen
# Add messages to the log (using TerminalLog component)
app.log(message: str) # Add message to log
app._log_message(message: str) # Internal logging method
# The framework uses the TerminalLog component internally
# For standalone usage:
from bravura.components import TerminalLog, create_terminal_log
log = create_terminal_log(parent, height=12)
log.log("Message")
log.log_warning("Warning message")
log.log_error("Error message")
log.clear()
log.save_to_file("log.txt")
# Progress bar control
app.set_progress(value: float) # Set progress (0-100)
app.start_progress_animation() # Start rainbow animation
app.stop_progress_animation() # Stop animation
app.reset_progress() # Reset to 0
# Progress configuration
app.set_progress_animation(style: str) # "rainbow", "pulse", "gradient"
app.set_progress_speed(speed: float) # Animation speed (0.1-2.0)
app.set_progress_color(color: str) # Custom color ("#RRGGBB")
# Professional status bar with timer and ETA
app.set_status(message: str) # Set left status section
app.status_var.set(message) # Main status message
app.progress_info_var.set(message) # Center progress message
# Timer and ETA functionality
app._start_timer() # Start timer
app._reset_timer() # Reset timer
app._update_progress_with_eta(percent, msg) # Update progress with ETA
# For standalone usage of StatusBar:
from bravura.components import StatusBar, create_status_bar
status = create_status_bar(parent)
status.pack(fill=tk.X, side=tk.BOTTOM)
status.start_timer()
status.set_status("Processing...")
status.set_progress_message("File 5 of 100")
status.update_eta("00:05:23")
status.reset_timer()
# Apply built-in themes
app.apply_theme(theme_name: str) # "default", "dark", "black", "white", "blue_deep", "pink_professional"
# Custom theming
app.set_custom_colors(colors: dict) # Apply custom color scheme
app.set_background_color(color: str) # Window background
app.set_accent_color(color: str) # Accent elements
app.reset_theme() # Reset to default
app.root # Tkinter root window
app.VERSION # Framework version string
app.theme_manager # Theme manager instance
app.worker # Background worker instance
app.eta_estimator # ETA calculation system
app.glow_manager # Glowing progress bar manager
app.overall_progress_var # Progress variable (0-100)
app.status_var # Status message variable
app.progress_info_var # Progress info variable
app.timer_eta_var # Timer and ETA display variable
app.start_time # Timer start time (or None)
# Public methods for integration
app.log(msg: str) # Add message to log
app.set_progress(pct: float, msg: str=None) # Set progress with message
app.set_status(text: str) # Set status bar text
app.run_task(func, *args, **kwargs) # Run function in background
app.run() # Start the main event loop
---
Professional menu system with keyboard shortcuts, submenus, and dynamic manipulation.
from bravura.components import MenuSystem, create_menu_system
# Create menu system
menu = create_menu_system(root)
# Or use class directly
menu = MenuSystem(root, tearoff=False)
# Add a menu with items
menu.add_menu("File", [
{"label": "New", "command": new_file, "accelerator": "Ctrl+N"},
{"label": "Open...", "command": open_file, "accelerator": "Ctrl+O"},
"separator",
{"label": "Exit", "command": app.quit}
])
# Command items (default)
{"label": "Save", "command": save_file, "accelerator": "Ctrl+S"}
# Checkbutton items
{"label": "Show Toolbar", "type": "checkbutton", "variable": toolbar_var}
# Radiobutton items
{"label": "Tool 1", "type": "radiobutton", "variable": tool_var, "value": "tool1"}
# Separators
"separator"
# Submenus/cascades
{
"label": "Recent Files",
"submenu": [
{"label": "file1.txt", "command": lambda: open_recent("file1.txt")},
{"label": "file2.txt", "command": lambda: open_recent("file2.txt")}
]
}
# Add items to existing menu
menu.add_item("File", {
"label": "Print...",
"command": print_file,
"accelerator": "Ctrl+P"
})
# Remove items
menu.remove_item("File", "Print...") # Returns True if successful
# Enable/disable items
menu.set_item_state("File", "Save", "disabled")
menu.set_item_state("File", "Save", "normal")
# Get item state
state = menu.get_item_state("File", "Save") # Returns "normal", "disabled", or "active"
# Update item properties
menu.update_item("File", "Save", command=new_save_func, label="Save All")
# Access menus
file_menu = menu.get_menu("File") # Returns tk.Menu object
# Enable/disable entire menus
menu.enable_menu("Edit")
menu.disable_menu("Edit")
# Remove menus
menu.remove_menu("Tools")
# Clear all items from a menu
menu.clear_menu("File")
# Get information about menu items
items = menu.get_menu_items("File")
for item in items:
print(f"Label: {item.get('label')}")
print(f"Type: {item.get('type')}") # command, checkbutton, radiobutton, separator
print(f"State: {item.get('state')}") # normal, disabled, active
print(f"Accelerator: {item.get('accelerator')}")
print(f"Index: {item.get('index')}")
from bravura.components import create_menu_system
import tkinter as tk
class MyApp:
def __init__(self):
self.root = tk.Tk()
self.root.title("My Application")
# Create menu system
self.menu = create_menu_system(self.root)
# Add File menu
self.menu.add_menu("File", [
{"label": "New", "command": self.new_file, "accelerator": "Ctrl+N"},
{"label": "Open...", "command": self.open_file, "accelerator": "Ctrl+O"},
{"label": "Save", "command": self.save_file, "accelerator": "Ctrl+S"},
"separator",
{
"label": "Recent Files",
"submenu": [
{"label": "doc1.txt", "command": lambda: self.open_recent("doc1.txt")},
{"label": "doc2.txt", "command": lambda: self.open_recent("doc2.txt")},
]
},
"separator",
{"label": "Exit", "command": self.root.quit, "accelerator": "Alt+F4"}
])
# Add Edit menu
self.menu.add_menu("Edit", [
{"label": "Undo", "command": self.undo, "accelerator": "Ctrl+Z"},
{"label": "Redo", "command": self.redo, "accelerator": "Ctrl+Y"},
"separator",
{"label": "Cut", "command": self.cut, "accelerator": "Ctrl+X"},
{"label": "Copy", "command": self.copy, "accelerator": "Ctrl+C"},
{"label": "Paste", "command": self.paste, "accelerator": "Ctrl+V"}
])
# Add View menu with checkbuttons
self.toolbar_var = tk.BooleanVar(value=True)
self.statusbar_var = tk.BooleanVar(value=True)
self.menu.add_menu("View", [
{
"label": "Toolbar",
"type": "checkbutton",
"variable": self.toolbar_var,
"command": self.toggle_toolbar
},
{
"label": "Status Bar",
"type": "checkbutton",
"variable": self.statusbar_var,
"command": self.toggle_statusbar
}
])
def new_file(self):
print("File > New")
def open_file(self):
print("File > Open")
# After opening, enable save
self.menu.set_item_state("File", "Save", "normal")
def save_file(self):
print("File > Save")
# Disable save after saving
self.menu.set_item_state("File", "Save", "disabled")
def toggle_toolbar(self):
visible = self.toolbar_var.get()
print(f"Toolbar: {'visible' if visible else 'hidden'}")
# Run the app
app = MyApp()
app.root.mainloop()
menu.root # Tkinter root window
menu.menubar # Main menubar widget
menu.menus # Dict of menu label -> Menu widget
menu.tearoff # Whether menus can be torn off
---
Professional loading screen with animations.
from components.universal_loading_dialog import UniversalLoadingDialog
loading = UniversalLoadingDialog()
# Display control
loading.show() # Show loading dialog
loading.hide() # Hide dialog (keep in memory)
loading.close() # Close and cleanup
loading.run() # Run modal dialog
# Progress updates
loading.update_progress(value: float, status: str = None)
loading.set_status(message: str) # Update status message
# Animations
loading.start_loading_music() # Start background music
loading.stop_loading_music() # Stop music
loading.center_window() # Center on screen
# Window properties
loading.window_width = 500 # Dialog width
loading.window_height = 300 # Dialog height
# Animation settings
loading.animation_speed = 1.0 # Speed multiplier
loading.color_transition_speed = 0.1 # Color change speed
# Convenience functions
from components.universal_loading_dialog import create_loading_dialog, simulate_loading_with_steps
loading = create_loading_dialog() # Quick creation
simulate_loading_with_steps(loading, steps) # Automated sequence
---
Clean, professional progress bar with three style variants. Available in all tiers.
from bravura.components import BasicProgressBar
# Create with style variant
progress = BasicProgressBar(parent, style="standard", width=400, height=22)
progress.pack()
progress.set_value(65)
BasicProgressBar(
parent=widget, # Parent widget
style="standard", # "standard", "success", or "warning"
width=400, # Bar width in pixels
height=22, # Bar height in pixels
show_text=True # Show percentage text
)
"standard": Teal accent (#20C6B7) - Default professional style"success": Green accent (#28A745) - For successful operations"warning": Orange accent (#F2842E) - For warnings or attention
# Progress control
progress.set_value(value: float) # Set progress (0-100)
# Layout
progress.pack(**kwargs) # Pack layout
progress.grid(**kwargs) # Grid layout
progress.place(**kwargs) # Place layout
progress.destroy() # Clean up and destroy
Beautiful gradient progress bar with smooth purpleβpink color transition. Available in all tiers.
from bravura.components import GradientProgressBar
# Create gradient bar
gradient = GradientProgressBar(parent, width=400, height=22)
gradient.pack()
gradient.set_value(75)
GradientProgressBar(
parent=widget, # Parent widget
width=400, # Bar width in pixels
height=22, # Bar height in pixels
show_text=True # Show percentage text
)
# Progress control
gradient.set_value(value: float) # Set progress (0-100)
# Layout
gradient.pack(**kwargs) # Pack layout
gradient.grid(**kwargs) # Grid layout
gradient.place(**kwargs) # Place layout
gradient.destroy() # Clean up and destroy
---
Advanced animated progress bar with rainbow color cycling, pulsing effects, and three animation modes.
from glowing_progress_bar import GlowingProgressBar, GlowingProgressManager
manager = GlowingProgressManager(root)
progress = GlowingProgressBar(parent, manager, **options)
GlowingProgressBar(
parent=widget, # Parent widget
manager=manager, # Progress manager instance
label_text="Progress:", # Label text
bar_type="rainbow", # "single", "multi", "rainbow"
width=400, # Bar width in pixels
height=28, # Bar height in pixels
base_color="#0078d7" # Base color for single/multi modes
)
# Progress control
progress.set_progress(value: float) # Set progress (0-100)
progress.start_glow_animation() # Start animation
progress.stop_glow_animation() # Stop animation
# Layout
progress.pack(**kwargs) # Pack layout
progress.grid(**kwargs) # Grid layout
progress.place(**kwargs) # Place layout
progress.destroy() # Clean up and destroy
The GlowingProgressBar initializes its canvas elements asynchronously for proper rendering. When calling start_glow_animation() immediately after creation, the animation will silently fail because canvas elements aren't ready yet.
β Wrong (animation won't start):
bar = GlowingProgressBar(parent, manager, bar_type="rainbow", width=500)
bar.pack()
bar.start_glow_animation() # Too early - canvas not ready!
β Correct (delay animation start):
bar = GlowingProgressBar(parent, manager, bar_type="rainbow", width=500)
bar.pack()
# Wait for canvas initialization
root.after(100, bar.start_glow_animation) # Works correctly!
Alternative (with setup):
bar = GlowingProgressBar(parent, manager, bar_type="rainbow", width=500)
bar.pack()
def start_animation():
bar.start_glow_animation()
bar.set_progress(50)
bar.set_label_text("Processing...")
root.after(100, start_animation)
See COMMON_MISTAKES.md for detailed explanation.
---
Manages themes and animations for progress bars.
manager = GlowingProgressManager(root)
# Built-in themes
manager.apply_theme("default") # Default theme
manager.apply_theme("dark") # Dark theme
manager.apply_theme("black") # Black theme
manager.apply_theme("blue_deep") # Deep blue theme
manager.apply_theme("pink_professional") # Professional pink theme
# Get current theme colors
colors = manager.get_theme_colors() # Returns color dictionary
# Animation control
manager.stop_all_animations() # Stop all registered animations
---
{
"bg_primary": "#f0f0f0", # Main background
"bg_secondary": "#e0e0e0", # Secondary background
"text_main": "#000000", # Primary text
"text_secondary": "#444444", # Secondary text
"accent_color_1": "#0078d7", # Primary accent
"accent_color_2": "#00AA00", # Secondary accent
"border_color": "#adadad", # Border color
"progress_bar_fg": "#0078d7", # Progress bar fill
"overall_progress_fg": "#00AA00" # Overall progress fill
}
custom_theme = {
"bg_primary": "#2d2d2d", # Dark background
"bg_secondary": "#3d3d3d", # Darker secondary
"text_main": "#ffffff", # White text
"text_secondary": "#cccccc", # Light gray text
"accent_color_1": "#0099ff", # Blue accent
"accent_color_2": "#00cc00", # Green accent
"border_color": "#555555", # Gray border
"progress_bar_fg": "#0099ff", # Blue progress
"overall_progress_fg": "#00cc00" # Green progress
}
app.apply_custom_theme(custom_theme)
# Theme utilities
def hex_to_rgb(hex_color: str) -> tuple # Convert hex to RGB
def rgb_to_hex(rgb_color: tuple) -> str # Convert RGB to hex
def lighten_color(color: str, factor: float) # Lighten a color
def darken_color(color: str, factor: float) # Darken a color
def get_contrast_color(color: str) -> str # Get contrasting color
---
# File dialog helpers
def select_files(title="Select Files", filetypes=None) -> list
def select_directory(title="Select Directory") -> str
def save_file_dialog(title="Save File", defaultext=".txt") -> str
# System utilities
def get_system_theme() -> str # "light" or "dark"
def is_dark_mode() -> bool # Check if dark mode
def get_screen_size() -> tuple # (width, height)
def center_window_on_screen(window) # Center any window
# Input validation
def validate_file_path(path: str) -> bool # Check if file exists
def validate_directory(path: str) -> bool # Check if directory exists
def validate_color(color: str) -> bool # Check if valid color format
def validate_geometry(geometry: str) -> bool # Check geometry string format
---
# Method 1: Extend BravuraFramework
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
class MyCustomApp(BravuraFramework):
def __init__(self):
super().__init__()
self.add_custom_section()
def add_custom_section(self):
# Add your custom UI section
custom_frame = ttk.LabelFrame(
self.main_frame,
text="Custom Section",
padding="10"
)
custom_frame.grid(row=4, column=0, columnspan=2, sticky="ew")
# Add custom widgets
self.setup_custom_widgets(custom_frame)
def setup_custom_widgets(self, parent):
# Your custom widget logic here
pass
# Method 2: Use standalone components
from bravura.components import StatusBar, MenuSystem, TerminalLog
import tkinter as tk
root = tk.Tk()
root.title("My App")
# Add professional components
menu = MenuSystem(root)
menu.add_menu("File", [
{"label": "Exit", "command": root.quit}
])
log = TerminalLog(root, height=12)
log.pack(fill=tk.BOTH, expand=True)
status = StatusBar(root)
status.pack(fill=tk.X, side=tk.BOTTOM)
status.start_timer()
root.mainloop()
class CustomProgressBar(GlowingProgressBar):
def _animate_custom_effect(self, pulse_factor: float):
# Your custom animation logic
# Return (fill_color, outline_color)
return "#FF6B9D", "#FF1493"
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
class EventAwareApp(BravuraFramework):
def __init__(self):
super().__init__()
self.setup_event_handlers()
def setup_event_handlers(self):
# Bind custom events
self.root.bind("<Configure>", self.on_window_resize)
# Note: WM_DELETE_WINDOW is already handled by framework
def on_window_resize(self, event):
# Handle window resize
self._log_message(f"Window resized to {event.width}x{event.height}")
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
class ThreadedApp(BravuraFramework):
def start_background_task(self):
# Use the built-in Worker system
self.worker.run(
self.background_job,
on_message=self._on_worker_message
)
def background_job(self, emit, cancel):
# Background processing with proper thread safety
for i in range(101):
if cancel.is_set():
emit("CANCELLED")
return
# Emit messages to UI thread
emit("PROGRESS", percent=i, message=f"Processing {i}%")
time.sleep(0.1)
emit("DONE")
---
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
try:
app = BravuraFramework()
app.theme_manager.apply_theme("invalid_theme")
except Exception as e:
app.log(f"Theme error: {e}")
# Framework handles errors gracefully with fallbacks
---
app.log() or app._log_message() instead of print() for debuggingapp.glowing_progress_bar.stop_glow_animation()Worker system for thread-safe background operationsapp._reset_timer()
# Proper cleanup
def cleanup_application():
if hasattr(app, 'glowing_progress_bar'):
app.glowing_progress_bar.stop_glow_animation() # Stop animations
app.log_text.delete(1.0, tk.END) # Clear log
app.root.quit() # Close application
---
import sqlite3
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
class DatabaseApp(BravuraFramework):
def __init__(self):
super().__init__()
self.setup_database()
def setup_database(self):
self._log_message("Connecting to database...")
try:
self.db = sqlite3.connect("myapp.db")
self._log_message("Database connected successfully")
except Exception as e:
self._log_message(f"Database error: {e}")
import requests
from bravura import get_audio_analyzer_framework
BravuraFramework = get_audio_analyzer_framework()
class WebAPIApp(BravuraFramework):
def fetch_data(self):
self._log_message("Fetching data from API...")
# Use built-in Worker for thread safety
self.worker.run(self._fetch_worker, on_message=self._on_worker_message)
def _fetch_worker(self, emit, cancel):
try:
emit("LOG", text="Connecting to API...")
response = requests.get("https://api.example.com/data")
emit("LOG", text="Data fetched successfully")
emit("DONE")
except Exception as e:
emit("ERROR", error=str(e))
---
Current API version: 1.0.0
---
Premium animated background with buttery-smooth 60 FPS performance and minimal CPU usage.
from bravura.components import AmbientBackground
# Create with theme-aware colors
ambient_bg = AmbientBackground(
parent_widget=root,
width=1200,
height=800,
theme_tokens=theme_manager.get_current_theme_colors(),
enable_animation=True,
animation_speed="medium",
particle_count=30,
glow_effects=True
)
AmbientBackground(
parent_widget, # Required: Parent tkinter widget
width=None, # Optional: Width in pixels (auto-detect)
height=None, # Optional: Height in pixels (auto-detect)
tokens=None, # Optional: Theme tokens (deprecated)
theme_tokens=None, # Recommended: Theme color tokens
enable_animation=True, # Enable 60 FPS animation
animation_speed="medium", # Drift speed: "slow", "medium", "fast"
particle_count=20, # Number of glow particles (10-60)
glow_effects=True, # Enable radial glow effects
reduced_motion=False, # Accessibility: disable animations
auto_create=True # Automatically create on init
)
Create or recreate the animated background canvas at 60 FPS.
Start buttery-smooth 60 FPS particle animation.
Stop particle animation (preserves background).
Update theme colors instantly without recreating the component.
# Instant theme update - 10x faster, no visual pop
ambient_bg.set_theme_tokens(theme_manager.get_current_theme_colors())
Performance: ~10ms vs ~100ms for recreation, smooth transition, no flicker.
Clean up and remove the ambient background completely.
ambient_bg.TARGET_FPS # 60 (constant)
ambient_bg.FRAME_TIME_MS # ~16.67ms per frame
ambient_bg.animation_running # Boolean: animation state
ambient_bg.particle_count # Current number of particles
Animation Quality:
CPU Efficiency:
Example Performance:
# Standard configuration (20 particles)
# CPU usage: <1% on modern systems
# Frame time: 16.67ms (60 FPS)
# Visual quality: Professional, premium
# Maximum configuration (40 particles)
# CPU usage: <2% on modern systems
# Frame time: 16.67ms (60 FPS maintained)
# Visual quality: Ultra-rich, enterprise-grade
---
Professional button with advanced features for hero actions.
from bravura.components import PremiumButton
button = PremiumButton(
parent,
text="Save Project",
command=callback,
style="primary", # primary, secondary, success, danger, warning
loading=False, # Enable loading state
icon=None, # Optional icon text
width=None, # Optional width in characters
height=None, # Optional height in pixels (NEW in v2.0.0)
bg_color=None, # Optional background color (NEW in v2.0.0)
fg_color=None, # Optional text color (NEW in v2.0.0)
hover_color=None, # Optional hover color (NEW in v2.0.0)
theme_tokens=None, # Optional theme tokens
**kwargs # Additional tk.Button options
)
parent (tk.Widget): Parent widgettext (str): Button labelcommand (Callable): Click callback functionstyle (str): Color style - "primary", "secondary", "success", "danger", "warning"loading (bool): Enable loading spinner animationicon (str, optional): Icon text to display before labelwidth (int, optional): Button width in charactersheight (int, optional): NEW Button height in pixels (e.g., 30, 36, 40)bg_color (str, optional): NEW Custom background color (hex: "#RRGGBB")fg_color (str, optional): NEW Custom text color (hex: "#RRGGBB")hover_color (str, optional): NEW Custom hover color (hex: "#RRGGBB")theme_tokens (dict, optional): Theme tokens for color customization**kwargs: Additional tk.Button configuration optionsColor Precedence: Individual color parameters (bg_color, fg_color, hover_color) take precedence over theme_tokens and are preserved across theme changes.
# Loading state
button.set_loading(loading: bool) # Enable/disable loading spinner
# Text and icon
button.set_text(text: str) # Update button text
button.set_icon(icon: str) # Update button icon
# State control
button.set_enabled(enabled: bool) # Enable/disable button
β Primary page actions (Save, Submit, Publish)
β Actions with loading states
β Actions with icons
β Dense toolbars (use CompactPremiumButton)
β Form buttons (use CompactPremiumButton)
class MyApp:
def create_hero_action(self):
# Standard usage
self.save_btn = PremiumButton(
self.header,
text="πΎ Save Project",
command=self.save_project,
style="primary"
)
self.save_btn.pack(side=tk.RIGHT, padx=10)
def create_custom_button(self):
# Custom colors (NEW in v2.0.0)
self.custom_btn = PremiumButton(
self.toolbar,
text="Custom Action",
command=self.custom_action,
bg_color="#8B5CF6", # Purple background
fg_color="#FFFFFF", # White text
hover_color="#A78BFA", # Light purple hover
height=30 # Compact height
)
self.custom_btn.pack(side=tk.LEFT, padx=5)
def save_project(self):
self.save_btn.set_loading(True)
# ... perform save operation ...
self.save_btn.set_loading(False)
---
Compact premium button for dense UIs with character-based widths.
from bravura.components import CompactPremiumButton
button = CompactPremiumButton(
parent,
text="Refresh",
command=callback,
style="primary", # primary, secondary, success, danger, warning
width=12, # CHARACTER-based width (not pixels!)
tokens=None, # Optional theme tokens
**kwargs # Additional tk.Button options
)
parent (tk.Widget): Parent widgettext (str): Button labelcommand (Callable): Click callback functionstyle (str): Color style - "primary", "secondary", "success", "danger", "warning"width (int, optional): Button width in characters (e.g., 15 = ~15 characters)tokens (dict, optional): Theme tokens for color customization**kwargs: Additional tk.Button configuration options| Feature | PremiumButton | CompactPremiumButton |
|---|---|---|
| Width | Pixel-based | Character-based |
| Padding | padx=12, pady=6 | padx=4, pady=2 |
| Font | 11pt bold | 9pt normal |
| Border | bd=2 | bd=1 |
| Use Case | Hero actions | Dense UIs |
β Toolbars with multiple actions
β Form control buttons (OK, Cancel, Apply)
β Table row actions
β Any layout requiring compact sizing
β Hero actions (use PremiumButton)
β Actions needing loading states (use PremiumButton)
class ToolbarApp:
def create_toolbar(self):
toolbar = tk.Frame(self.root)
# Multiple compact buttons fit nicely
for action in ["Bold", "Italic", "Underline", "Color"]:
btn = CompactPremiumButton(
toolbar,
text=action,
command=lambda a=action: self.format_text(a),
width=8,
style="primary"
)
btn.pack(side=tk.LEFT, padx=2)
def create_form(self):
form_frame = tk.Frame(self.root)
# Form buttons with uniform sizing
CompactPremiumButton(
form_frame,
text="OK",
command=self.on_ok,
width=10,
style="success"
).pack(side=tk.LEFT, padx=5)
CompactPremiumButton(
form_frame,
text="Cancel",
command=self.on_cancel,
width=10,
style="secondary"
).pack(side=tk.LEFT, padx=5)
---
Intelligent factory for automatic button component selection.
from bravura.components import ButtonFactory
button = ButtonFactory.create(
parent,
text="Save",
command=callback,
context="hero", # hero, toolbar, form, action, secondary
style="primary",
width=None,
loading=False,
icon=None,
**kwargs
)
| Context | Creates | Use For |
|---|---|---|
| `hero` | PremiumButton | Primary page actions |
| `toolbar` | CompactPremiumButton | Toolbar actions |
| `form` | CompactPremiumButton | Form controls |
| `action` | CompactPremiumButton | Secondary actions |
| `secondary` | Themed ttk.Button | Background actions |
# Hero action (creates PremiumButton)
hero_btn = ButtonFactory.create_hero(
parent,
text="Save",
command=save,
style="primary"
)
# Toolbar action (creates CompactPremiumButton)
toolbar_btn = ButtonFactory.create_toolbar(
parent,
text="Refresh",
command=refresh,
width=12
)
# Form button (creates CompactPremiumButton)
form_btn = ButtonFactory.create_form(
parent,
text="OK",
command=ok,
width=10,
style="success"
)
class SmartApp:
def create_ui(self):
# Factory automatically selects appropriate component
# Hero action β PremiumButton
self.save_btn = ButtonFactory.create(
self.header,
text="πΎ Save Project",
command=self.save,
context="hero"
)
# Toolbar actions β CompactPremiumButton
self.refresh_btn = ButtonFactory.create(
self.toolbar,
text="Refresh",
command=self.refresh,
context="toolbar",
width=12
)
# Form buttons β CompactPremiumButton
self.ok_btn = ButtonFactory.create(
self.form,
text="OK",
command=self.on_ok,
context="form",
width=10
)
---
For technical questions about the API:
---
Β© 2025 Wigley Studios LLC. Complete API reference for serious developers.