# `gradio_modal`
<a href="https://pypi.org/project/gradio_modal/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_modal"></a>
A popup modal component
## Installation
```bash
pip install gradio_modal
```
## Usage
```python
import gradio as gr
from gradio_modal import Modal
with gr.Blocks() as demo:
with gr.Tab("Tab 1"):
text_1 = gr.Textbox(label="Input 1")
text_2 = gr.Textbox(label="Input 2")
text_1.submit(lambda x:x, text_1, text_2)
show_btn = gr.Button("Show Modal")
show_btn2 = gr.Button("Show Modal 2")
gr.Examples(
[["Text 1", "Text 2"], ["Text 3", "Text 4"]],
inputs=[text_1, text_2],
)
with gr.Tab("Tab 2"):
gr.Markdown("This is tab 2")
with Modal(visible=False) as modal:
for i in range(5):
gr.Markdown("Hello world!")
with Modal(visible=False) as modal2:
for i in range(100):
gr.Markdown("Hello world!")
show_btn.click(lambda: Modal(visible=True), None, modal)
show_btn2.click(lambda: Modal(visible=True), None, modal2)
if __name__ == "__main__":
demo.launch()
```
## `Modal`
### Initialization
<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">If False, modal will be hidden.</td>
</tr>
<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string or list of strings that are assigned as the class of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>allow_user_close</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If True, user can close the modal (by clicking outside, clicking the X, or the escape key).</td>
</tr>
<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
</tr>
</tbody></table>
### Events
| name | description |
|:-----|:------------|
| `blur` | This listener is triggered when the Modal is unfocused/blurred. |
Raw data
{
"_id": null,
"home_page": null,
"name": "gradio-modal",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "Modal, Popup, gradio-custom-component, gradio-template-Column",
"author": null,
"author_email": "YOUR NAME <YOUREMAIL@domain.com>",
"download_url": "https://files.pythonhosted.org/packages/e2/fd/3b383f9ee8d60625e9e26871ba4adcacbedeab132041b94290758e02e543/gradio_modal-0.0.4.tar.gz",
"platform": null,
"description": "\n# `gradio_modal`\n<a href=\"https://pypi.org/project/gradio_modal/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_modal\"></a> \n\nA popup modal component\n\n## Installation\n\n```bash\npip install gradio_modal\n```\n\n## Usage\n\n```python\nimport gradio as gr\nfrom gradio_modal import Modal\n\nwith gr.Blocks() as demo:\n with gr.Tab(\"Tab 1\"):\n text_1 = gr.Textbox(label=\"Input 1\")\n text_2 = gr.Textbox(label=\"Input 2\")\n text_1.submit(lambda x:x, text_1, text_2)\n show_btn = gr.Button(\"Show Modal\")\n show_btn2 = gr.Button(\"Show Modal 2\")\n gr.Examples(\n [[\"Text 1\", \"Text 2\"], [\"Text 3\", \"Text 4\"]],\n inputs=[text_1, text_2],\n )\n with gr.Tab(\"Tab 2\"):\n gr.Markdown(\"This is tab 2\")\n with Modal(visible=False) as modal:\n for i in range(5):\n gr.Markdown(\"Hello world!\")\n with Modal(visible=False) as modal2:\n for i in range(100):\n gr.Markdown(\"Hello world!\")\n show_btn.click(lambda: Modal(visible=True), None, modal)\n show_btn2.click(lambda: Modal(visible=True), None, modal2)\n\nif __name__ == \"__main__\":\n demo.launch()\n\n```\n\n## `Modal`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">If False, modal will be hidden.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string or list of strings that are assigned as the class of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>allow_user_close</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If True, user can close the modal (by clicking outside, clicking the X, or the escape key).</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `blur` | This listener is triggered when the Modal is unfocused/blurred. |\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A popup modal component",
"version": "0.0.4",
"project_urls": null,
"split_keywords": [
"modal",
" popup",
" gradio-custom-component",
" gradio-template-column"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "053d76f454de84ae1dccbf2b7023e933afb8dde5fdd89e9476786726ef770737",
"md5": "f4d21e00e3375b7ef73193606cbf64c7",
"sha256": "d96e817d2e934d9e1b835b06474f45fd349b5ccea499d1536bfb4bd38f62dedb"
},
"downloads": -1,
"filename": "gradio_modal-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f4d21e00e3375b7ef73193606cbf64c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1106241,
"upload_time": "2024-10-15T23:46:04",
"upload_time_iso_8601": "2024-10-15T23:46:04.130390Z",
"url": "https://files.pythonhosted.org/packages/05/3d/76f454de84ae1dccbf2b7023e933afb8dde5fdd89e9476786726ef770737/gradio_modal-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2fd3b383f9ee8d60625e9e26871ba4adcacbedeab132041b94290758e02e543",
"md5": "f169bedcfd0d4436e0cf2f572cc29aac",
"sha256": "717ae699072a171648cfa1b84bc153be84e92d04e9ad58c1bc59af68ef332726"
},
"downloads": -1,
"filename": "gradio_modal-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "f169bedcfd0d4436e0cf2f572cc29aac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 1180812,
"upload_time": "2024-10-15T23:46:06",
"upload_time_iso_8601": "2024-10-15T23:46:06.134622Z",
"url": "https://files.pythonhosted.org/packages/e2/fd/3b383f9ee8d60625e9e26871ba4adcacbedeab132041b94290758e02e543/gradio_modal-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-15 23:46:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "gradio-modal"
}