Metadata-Version: 2.4
Name: tkinter-toggle
Version: 0.1.1
Summary: A tkinter toggle widget is a reusable UI component for tkinter application.
Project-URL: Homepage, https://github.com/akarshit-1609/tkinter-toggle
Project-URL: Issues, https://github.com/akarshit-1609/tkinter-toggle/issues
Author-email: Akarshit kumar <akarshitk03@gmail.com>
License-Expression: LGPL-3.0-only
License-File: COPYING
License-File: COPYING.LESSER
Classifier: Environment :: MacOS X
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: X11 Applications
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# tkinter-toggle

A tkinter toggle widget is a reusable UI component that lets users instantly switch between two states (like On/Off) by dynamically updating the UI and executing code upon interaction.

## Installation

It is recommended to install Python packages inside a virtual environment to prevent dependency conflicts.

**1. Create and activate a virtual environment (Optional but recommended):**
```bash
# On Windows
python -m venv venv
venv\Scripts\activate

# On macOS/Linux
python3 -m venv venv
source venv/bin/activate
```


**2. Install the package:**

```bash
pip install tkinter-toggle

```

## Quick Start

Import the toggle widget and attach it to your Tkinter window. Don't forget to call `.pack()`, `.grid()`, or `.place()` to display it!

```python
import tkinter as tk
from tkinter_toggle import tkToggle

def on_click(event):
    print(event.value)

root = tk.Tk()

# Create the instance
toggle = tkToggle(root, default=False, size=30, bg="red", command=on_click)

# Show the toggle widget on the window
toggle.pack()

root.mainloop()

```

## Configuration

When initializing `tkToggle(master, ...)`, you can pass several optional arguments to customize its behavior and appearance.

### Arguments

| Argument | Type | Default | Optional | Description |
| --- | --- | --- | --- | --- |
| `default` | `bool` | `False` | Yes | The initial state or value of the toggle widget. |
| `size` | `int` | `20` | Yes | The dimensions (width/height) of the widget. |
| `bg` | `str` | `"#0000ff"` | Yes | Background color (hex code or Tkinter color name). |
| `command` | `Callable` | `""` | Yes | Function to execute when the user interacted with toggle widget. |

*Note: The first argument must always be the parent window or frame (`master`).*

## Methods

Once initialized, you can interact with the widget programmatically using its built-in methods:

* **`set_value(value: bool)`**: Updates the current state of the toggle widget to the given boolean value.
* **`get_value() -> bool`**: Returns the current state of the toggle widget.
* **`toggle()`**: Reverse the current state of the toggle widget.

## Full Example

Here is a complete working example. You can also view this code directly in the repository at [`tests/example.py`](https://github.com/akarshit-1609/tkinter-toggle/blob/main/tests/example.py).

```python
import tkinter as tk
from tkinter_toggle import tkToggle

def on_click(event):
    print(event.value)

# Initialize the main window
root = tk.Tk()
root.geometry("300x200+100+100")
root.title("Toggle Demo")

# Create and configure the widget
toggle = tkToggle(
    root, 
    default=False, 
    size=30, 
    bg="green", 
    command=on_click
)

# Display the toggle widget
toggle.pack(pady=20)

# Modify the value programmatically
toggle.toggle()

# Run the application
root.mainloop()

```

## PyPI Project

The official package registry, release history, and download statistics are available on the Python Package Index (PyPI):  
[https://pypi.org/project/tkinter-toggle/](https://pypi.org/project/tkinter-toggle/)

## License

This project is licensed under the GNU Lesser General Public License (LGPL). See the [COPYING.LESSER](https://github.com/akarshit-1609/tkinter-toggle/blob/main/COPYING.LESSER) and [COPYING](https://github.com/akarshit-1609/tkinter-toggle/blob/main/COPYING) files for full details.

---