{"id":24324125,"url":"https://github.com/bornalgo/stacked-widget","last_synced_at":"2026-04-24T12:05:27.441Z","repository":{"id":272954739,"uuid":"917874551","full_name":"bornalgo/stacked-widget","owner":"bornalgo","description":"This repository provides a customizable stacked widget for PyQt/PySide, where you can display two widgets stacked on top of each other with configurable alignment.","archived":false,"fork":false,"pushed_at":"2025-01-17T18:47:11.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T03:44:58.118Z","etag":null,"topics":["custom","gui","overlays","pyqt","pyqt4","pyqt5","pyqt6","pyside","pyside2","pyside6","python","qt","stackedwidget","widgets"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bornalgo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-16T20:05:23.000Z","updated_at":"2025-01-28T11:32:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"173281da-afba-438a-a6d2-812907b2602e","html_url":"https://github.com/bornalgo/stacked-widget","commit_stats":null,"previous_names":["bornalgo/stacked-widget"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bornalgo/stacked-widget","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bornalgo%2Fstacked-widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bornalgo%2Fstacked-widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bornalgo%2Fstacked-widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bornalgo%2Fstacked-widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bornalgo","download_url":"https://codeload.github.com/bornalgo/stacked-widget/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bornalgo%2Fstacked-widget/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261453277,"owners_count":23160479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom","gui","overlays","pyqt","pyqt4","pyqt5","pyqt6","pyside","pyside2","pyside6","python","qt","stackedwidget","widgets"],"created_at":"2025-01-17T19:32:45.990Z","updated_at":"2026-04-24T12:05:27.436Z","avatar_url":"https://github.com/bornalgo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## `stacked-widget`\n![StackedWidget_Sample](images/screenshot.png)\n\n**`StackedWidget`** is a custom PyQt/PySide widget that enables overlaying one widget on top of another with flexible alignment and margin configurations. This is particularly useful for GUI designs where layered widgets (e.g., buttons, labels, or overlays) are needed.\n\n### Features\n- Overlay a top widget on a bottom widget with alignment options (`Left`, `Right`, `Top`, `Bottom`, `Center`, etc.).\n- Supports dynamic resizing and alignment adjustments on window resize.\n- Easy to integrate with PyQt or PySide applications.\n- Fully customizable margins and alignment settings.\n\n---\n\n### Table of Contents\n1. [Installation](#installation)\n2. [Usage](#usage)\n3. [Examples](#examples)\n4. [API Reference](#api-reference)\n5. [Use Cases](#use-cases)\n6. [Contributing](#contributing)\n7. [License](#license)\n\n---\n\n### Installation\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/bornalgo/stacked-widget.git\n   cd StackedWidget\n   ```\n2. Install the required dependencies:\n   ```bash\n   pip install PySide2  # Or PySide6/PyQt6/PyQt5/PyQt4/PySide based on your preference\n   ```\n3. Install the package:\n   ```bash\n   python setup.py install\n   ```\n\n\n---\n\n### Usage\n```python\nfrom PySide2.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QPushButton, QCheckBox, QWidget\nfrom balQt.stacked_widget import StackedWidget\n\n# Create the application\napp = QApplication([])\n\n# Main window setup\nwindow = QMainWindow()\nwindow.setWindowTitle(\"Stacked Widget Example\")\n\n# Create bottom and top widgets\nbutton = QPushButton(\"Click Me!\")\nbutton.setEnabled(False)\ncheckbox = QCheckBox(\"Enable Button\")\n\n# Connect checkbox state change to toggle button enabled state\ncheckbox.stateChanged.connect(lambda: button.setEnabled(checkbox.isChecked()))\n\n# Create a StackedWidget\nstacked_widget = StackedWidget(button, checkbox)\n\n# Setup layout\nlayout = QVBoxLayout()\nlayout.addWidget(stacked_widget)\n\ncontainer = QWidget()\ncontainer.setLayout(layout)\nwindow.setCentralWidget(container)\n\n# Show window\nwindow.show()\n\n# Run application\napp.exec_()\n```\n\n---\n\n### Examples\n#### Example 1: Overlay a Checkbox on a Button\nOverlay a checkbox on a button, where the checkbox controls the button's enabled state.\n\n```python\ndef toggle_button_state(checkbox, button):\n    button.setEnabled(checkbox.isChecked())\n\ncheckbox.stateChanged.connect(lambda: toggle_button_state(checkbox, button))\n```\n\n#### Example 2: Display a Loading Overlay\nUse `StackedWidget` to overlay a \"loading spinner\" or a progress bar on top of an underlying content widget.\n\n---\n\n### API Reference\n#### `class StackedWidget(QWidget)`\nA custom widget for overlaying widgets.\n\n**Parameters:**\n- `bottom_widget (QWidget)`: Widget at the base.\n- `top_widget (QWidget)`: Widget overlaid on the bottom widget.\n- `parent (QWidget, optional)`: Parent widget. Defaults to `None`.\n- `margin (int, optional)`: Space between the widgets. Defaults to `0`.\n- `alignment (Qt.Alignment, optional)`: Alignment of the `top_widget` (e.g., `Qt.AlignRight`). Defaults to `Qt.AlignRight`.\n\n**Methods:**\n- `__init__(bottom_widget, top_widget, parent=None, margin=0, alignment=Qt.AlignRight)`: Initializes the `StackedWidget`.\n- `resizeEvent(event)`: Dynamically adjusts widget alignment and size upon resizing.\n\n---\n\n### Use Cases\n1. **Interactive User Interfaces:**\n   - Overlay a checkbox or a label on a button or image.\n2. **Loading Screens:**\n   - Place a spinner or progress indicator on top of a widget.\n3. **Advanced Layouts:**\n   - Use layered designs for applications like form builders or dashboards.\n4. **Dynamic States:**\n   - Display dynamic states (e.g., \"Processing\", \"Completed\") over widgets.\n\n---\n\n### Contributing\nContributions are welcome! If you'd like to add features, fix bugs, or suggest improvements:\n1. Fork the repository.\n2. Create a feature branch (`git checkout -b feature/new-feature`).\n3. Commit your changes (`git commit -m \"Add new feature\"`).\n4. Push to the branch (`git push origin feature/new-feature`).\n5. Open a pull request.\n\n---\n\n### License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n### Keywords\n- `PyQt`\n- `PySide`\n- `StackedWidget`\n- `Qt Custom Widgets`\n- `Overlays`\n- `GUI Development`\n- `Python GUI`\n\n---\n\n### Repository Structure\n```\nStackedWidget/\n├── balQt\n│   ├── __init__.py\n│   └── stacked_widget.py\n├── images\n│   └── screenshot.png\n├── .gitignore          # Ignore artifacts\n├── example.py          # Usage example\n├── LICENSE             # License file\n├── README.md           # Documentation\n└── setup.py            # Setup file\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbornalgo%2Fstacked-widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbornalgo%2Fstacked-widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbornalgo%2Fstacked-widget/lists"}