| Crates.io | termux-gui |
| lib.rs | termux-gui |
| version | 0.3.0 |
| created_at | 2025-10-04 09:07:52.66629+00 |
| updated_at | 2025-10-05 01:53:00.190384+00 |
| description | Rust bindings for Termux:GUI - Build Android GUI apps in Rust on Termux |
| homepage | |
| repository | https://github.com/termux/termux-gui-rust-bindings |
| max_upload_size | |
| id | 1867740 |
| size | 104,492 |
A Rust library for building Android GUI applications using Termux:GUI. This project provides idiomatic Rust bindings for the Termux:GUI plugin, making it easy to create native Android interfaces from the Termux terminal environment.
✅ Complete Termux:GUI Protocol Implementation - Full support for the low-level communication protocol
✅ Rich Widget Library - 12+ UI components (Button, TextView, EditText, WebView, etc.)
✅ Advanced Layouts - 7 layout types including Linear, Grid, Frame, Tab, and Scroll layouts
✅ WebView Integration - Full web content support with JavaScript execution
✅ Type Safety - Leverages Rust's type system for compile-time correctness
✅ Memory Safety - Zero-cost abstractions with guaranteed memory safety
✅ Comprehensive Examples - 21 working examples covering all components
✅ International Ready - 100% English documentation, ready for worldwide use
Add this library to your Rust project:
cargo add termux-gui
Or add it manually to your Cargo.toml:
[dependencies]
termux-gui = "0.3.0"
pkg install rust
cd termux-gui-rust-demo
cargo build --release
Run any of the v2 examples (which use the new library API):
# Button demo
cargo run --example button_demo_v2
# Input fields demo
cargo run --example input_demo_v2
# Complex layout demo
cargo run --example grid_layout_demo_v2
# WebView demo
cargo run --example webview_demo_v2
Or run the pre-built binaries:
./target/release/examples/button_demo_v2
use termux_gui::{Activity, Result};
fn main() -> Result<()> {
// Create a full-screen activity
let mut activity = Activity::new(false)?;
// Create vertical layout
let layout = activity.create_linear_layout(None)?;
// Add a button
let button = activity.create_button("Click Me!", Some(layout.id()))?;
// Button will generate click events
// Handle them in your event loop
Ok(())
}
For complete working examples, see the examples/ directory.
src/
├── lib.rs # Public API and exports
├── error.rs # Error types
├── connection.rs # Socket communication
├── activity.rs # Activity management
├── view.rs # Base view operations
└── components/ # UI components (19 files)
├── button.rs
├── text_view.rs
├── edit_text.rs
├── checkbox.rs
├── switch.rs
├── radio.rs
├── spinner.rs
├── layout.rs # All layout types
├── image_view.rs
├── progress_bar.rs
├── toggle_button.rs
├── space.rs
└── web_view.rs
The library implements the Termux:GUI protocol using:
Rust's type system ensures:
Each widget has comprehensive examples in the examples/ directory. The examples demonstrate:
# Enable debug logging
RUST_LOG=debug cargo run --example button_demo_v2
# Test a specific example
cargo build --release --example checkbox_demo_v2
./target/release/examples/checkbox_demo_v2
| Feature | Python | Rust |
|---|---|---|
| Type Safety | Runtime | Compile-time |
| Memory Safety | Runtime | Compile-time |
| Performance | Good | Excellent |
| Error Handling | Exceptions | Result<T, E> |
| Deployment | Interpreter required | Single binary |
| Learning Curve | Easy | Moderate |
| Concurrency | GIL limitations | Fearless concurrency |
MIT License - See LICENSE file for details
Contributions are welcome! Please feel free to submit issues or pull requests.
Version: 0.3.0
Status: Production Ready
Last Updated: 2024-10-05