gradio-viewer


Namegradio-viewer JSON
Version 0.0.25 PyPI version JSON
download
home_pageNone
SummaryVisualise any type of files
upload_time2024-11-05 22:51:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords gradio-custom-component gradio-template-file
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ---
tags: [gradio-custom-component, File]
title: gradio_viewer
short_description: Visualise files
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---

# `gradio_viewer`
<a href="https://pypi.org/project/gradio_viewer/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_viewer"></a>  

Visualise any type of files

## Installation

```bash
pip install gradio_viewer
```

## Usage

```python
import gradio as gr
from gradio_viewer import Viewer


def set_interface():
    view_with_ms = Viewer(
        value=[
            "./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx",
            "./demo/data/mermaid_graph-2.html",
            "./demo/data/graphique_couts_annuels.png",
            "./demo/data/Le_Petit_Chaperon_Rouge.zouzou",
            "./demo/data/viewer.py",
        ],
        elem_classes=["visualisation"],
        n=0,
        height=300,
        visible=True,
        ms_files=True,
    )

    view_without_ms = Viewer(
        value=[
            "./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx",
            "./demo/data/mermaid_graph-2.html",
            "./demo/data/graphique_couts_annuels.png",
            "./demo/data/Le_Petit_Chaperon_Rouge.zouzou",
        ],
        elem_classes=["visualisation"],
        n=1,
        height=300,
        visible=True,
        ms_files=False,
    )
    empty_view1 = view_with_ms
    empty_view2 = view_without_ms
    return view_with_ms, view_without_ms, empty_view1, empty_view2


with gr.Blocks() as demo:
    with gr.Row():
        view_with_ms = Viewer(visible=False)
        view_without_ms = Viewer(visible=False)
        empty_view1 = Viewer(visible=False)
        empty_view2 = Viewer(visible=False)
    demo.load(
        set_interface, outputs=[view_with_ms, view_without_ms, empty_view1, empty_view2]
    ).then(
        fn=lambda: (
            Viewer(visible=False, value=None, elem_id="empty1"),
            Viewer(visible=False, value=[], elem_id="empty2"),
        ),
        outputs=[empty_view1, empty_view2],
    )

if __name__ == "__main__":
    demo.launch()

```

## `Viewer`

### 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>value</code></td>
<td align="left" style="width: 25%;">

```python
Any
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>height</code></td>
<td align="left" style="width: 25%;">

```python
int | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>info</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">

```python
int | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">

```python
int | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>interactive</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</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">None</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">None</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">None</td>
</tr>

<tr>
<td align="left"><code>load_fn</code></td>
<td align="left" style="width: 25%;">

```python
Callable[..., Any] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">

```python
Timer | float | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>n</code></td>
<td align="left" style="width: 25%;">

```python
int
```

</td>
<td align="left"><code>0</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>max_size</code></td>
<td align="left" style="width: 25%;">

```python
int
```

</td>
<td align="left"><code>5000000</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>max_pages</code></td>
<td align="left" style="width: 25%;">

```python
int
```

</td>
<td align="left"><code>100</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>ms_files</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>libre_office</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>
</tbody></table>


### Events

| name | description |
|:-----|:------------|
| `change` |  |
| `upload` |  |



### User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

- **As output:** Is passed, the data after preprocessing, sent to the user's function in the backend.
- **As input:** Should return, expects a `str` filepath or URL, or a `list[str]` of filepaths/URLs.

 ```python
 def predict(
     value: str
 ) -> str | list[str] | None:
     return value
 ```
 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gradio-viewer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "gradio-custom-component, gradio-template-File",
    "author": null,
    "author_email": "ngaudemet <nicolaenji@yahoo.com>",
    "download_url": "https://files.pythonhosted.org/packages/ee/46/f663a8475797b2e1e7ef76fffa23bfa560f209085d9795c5a24df32e9842/gradio_viewer-0.0.25.tar.gz",
    "platform": null,
    "description": "---\ntags: [gradio-custom-component, File]\ntitle: gradio_viewer\nshort_description: Visualise files\ncolorFrom: blue\ncolorTo: yellow\nsdk: gradio\npinned: false\napp_file: space.py\n---\n\n# `gradio_viewer`\n<a href=\"https://pypi.org/project/gradio_viewer/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_viewer\"></a>  \n\nVisualise any type of files\n\n## Installation\n\n```bash\npip install gradio_viewer\n```\n\n## Usage\n\n```python\nimport gradio as gr\nfrom gradio_viewer import Viewer\n\n\ndef set_interface():\n    view_with_ms = Viewer(\n        value=[\n            \"./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx\",\n            \"./demo/data/mermaid_graph-2.html\",\n            \"./demo/data/graphique_couts_annuels.png\",\n            \"./demo/data/Le_Petit_Chaperon_Rouge.zouzou\",\n            \"./demo/data/viewer.py\",\n        ],\n        elem_classes=[\"visualisation\"],\n        n=0,\n        height=300,\n        visible=True,\n        ms_files=True,\n    )\n\n    view_without_ms = Viewer(\n        value=[\n            \"./demo/data/Le_Petit_Chaperon_Rouge_Modifie.docx\",\n            \"./demo/data/mermaid_graph-2.html\",\n            \"./demo/data/graphique_couts_annuels.png\",\n            \"./demo/data/Le_Petit_Chaperon_Rouge.zouzou\",\n        ],\n        elem_classes=[\"visualisation\"],\n        n=1,\n        height=300,\n        visible=True,\n        ms_files=False,\n    )\n    empty_view1 = view_with_ms\n    empty_view2 = view_without_ms\n    return view_with_ms, view_without_ms, empty_view1, empty_view2\n\n\nwith gr.Blocks() as demo:\n    with gr.Row():\n        view_with_ms = Viewer(visible=False)\n        view_without_ms = Viewer(visible=False)\n        empty_view1 = Viewer(visible=False)\n        empty_view2 = Viewer(visible=False)\n    demo.load(\n        set_interface, outputs=[view_with_ms, view_without_ms, empty_view1, empty_view2]\n    ).then(\n        fn=lambda: (\n            Viewer(visible=False, value=None, elem_id=\"empty1\"),\n            Viewer(visible=False, value=[], elem_id=\"empty2\"),\n        ),\n        outputs=[empty_view1, empty_view2],\n    )\n\nif __name__ == \"__main__\":\n    demo.launch()\n\n```\n\n## `Viewer`\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>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nAny\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>height</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</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\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>info</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\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</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\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>interactive</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\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>True</code></td>\n<td align=\"left\">None</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\">None</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\">None</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\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>load_fn</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nCallable[..., Any] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nTimer | float | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>n</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>0</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>max_size</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>5000000</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>max_pages</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>100</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>ms_files</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\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>libre_office</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\">None</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` |  |\n| `upload` |  |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As output:** Is passed, the data after preprocessing, sent to the user's function in the backend.\n- **As input:** Should return, expects a `str` filepath or URL, or a `list[str]` of filepaths/URLs.\n\n ```python\n def predict(\n     value: str\n ) -> str | list[str] | None:\n     return value\n ```\n \n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Visualise any type of files",
    "version": "0.0.25",
    "project_urls": null,
    "split_keywords": [
        "gradio-custom-component",
        " gradio-template-file"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ca99b6603a6d9dfc258fd8f36ffca62f4df38fc6b6b9a0c268858a1f40e0325",
                "md5": "6f191734bf507175a1eabbdeda5988e6",
                "sha256": "2ee10be7924f27476758ea3156977b6b845c8996b6be9986fab784df64e4ccab"
            },
            "downloads": -1,
            "filename": "gradio_viewer-0.0.25-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f191734bf507175a1eabbdeda5988e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 1259353,
            "upload_time": "2024-11-05T22:50:59",
            "upload_time_iso_8601": "2024-11-05T22:50:59.778692Z",
            "url": "https://files.pythonhosted.org/packages/2c/a9/9b6603a6d9dfc258fd8f36ffca62f4df38fc6b6b9a0c268858a1f40e0325/gradio_viewer-0.0.25-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee46f663a8475797b2e1e7ef76fffa23bfa560f209085d9795c5a24df32e9842",
                "md5": "069c5217d110c82e6e8624b4905e54ed",
                "sha256": "acace7b3513e52590bef248af606ca6399478c4a251b54ed4f442a0912c9968b"
            },
            "downloads": -1,
            "filename": "gradio_viewer-0.0.25.tar.gz",
            "has_sig": false,
            "md5_digest": "069c5217d110c82e6e8624b4905e54ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1426699,
            "upload_time": "2024-11-05T22:51:04",
            "upload_time_iso_8601": "2024-11-05T22:51:04.551360Z",
            "url": "https://files.pythonhosted.org/packages/ee/46/f663a8475797b2e1e7ef76fffa23bfa560f209085d9795c5a24df32e9842/gradio_viewer-0.0.25.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 22:51:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gradio-viewer"
}
        
Elapsed time: 0.33893s