dash-google-picker


Namedash-google-picker JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryGoogle picker component for dash
upload_time2023-09-04 23:06:43
maintainer
docs_urlNone
authorlpawlick
requires_python>=3.6
licenseMIT
keywords dash google file picker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dash Google Picker
[![PyPI version](https://badge.fury.io/py/dash-google-picker.svg)](https://badge.fury.io/py/dash-google-picker)

The `dash_google_picker` is a Python module that allows the integration of Google's Picker API with a Dash application. The module provides a Dash component `GooglePicker` to easily implement the Google Picker functionality into your application, enabling your users to select files from their Google Drive account, among other data sources.

## Features

- Leverages Google Picker API for seamless integration with Google Drive.
- Allows selection of multiple files from Google Drive.
- Customizable views and features according to Google Picker API.

## [Documentation](https://docs.pawlick.dev/projects/dash_google_picker/)

## Installation

Use pip to install the package:

```bash
pip install dash-google-picker
```

## Prerequisites

Follow the official [Google Picker Guide](https://developers.google.com/drive/picker/guides/overview) to create the required credentials.

## Usage

The usage example below shows how to use the `GooglePicker` component in your Dash application.

```python
from typing import List
from dash import Dash, dcc, html, Input, Output, State, dcc
from dash_google_picker import GooglePicker 
from dash_google_picker.Documents import GoogleDocuments, GoogleDocument
import os

app = Dash(__name__)

app.layout = html.Div([
    html.Button('Open Google Picker', id='open-picker-button', n_clicks=0),
    GooglePicker(
        id='google-picker',
        client_id='GOOGLE_CLIENT_ID',
        developer_key='GOOGLE_DEVELOPER_KEY'
        ),
    dcc.Markdown(id='display-documents', style={'whiteSpace': 'pre-wrap'}),
    html.Div(id='display-action')
])

if __name__ == '__main__':
    app.run_server(debug=True)
```

The picker view can be customised, for more information see the `GooglePicker` component documentation or the [Google Picker API Documentation](https://developers.google.com/picker/docs/reference).

## Callbacks

The `GooglePicker` component generates two outputs `documents` and `action`. The `documents` output contains a list of documents selected by the user, and `action` contains the current action status.

```python
@app.callback(
    Output('google-picker', 'open'),
    [Input('open-picker-button', 'n_clicks')],
    [State('google-picker', 'open')]
)
def open_google_picker(n_clicks, is_open):
    if n_clicks > 0:
        return not is_open
    return False

@app.callback(
    Output('display-documents', 'children'),
    [Input('google-picker', 'documents')],
    prevent_initial_call=True
)
def display_output(documents):
    docs : List[GoogleDocument] = GoogleDocuments(documents)
    x = "\n".join([f"{prop}: {getattr(obj, prop)}" for obj in docs for prop in dir(obj) if not prop.startswith("__")])
    return x

@app.callback(
    Output('display-action', 'children'),
    [Input('google-picker', 'action')],
    prevent_initial_call=True
)
def display_action(action):
    if action == "loaded":
        return "Opened the Google Picker Popup"
    elif action == "picked":
        return "Picked a document"
    elif action == "cancelled":
        return "Cancelled the Google Picker Popup"
    return f'Action: {action}'
```

## License

[MIT](https://github.com/lpawlick/dash_google_picker/blob/master/LICENSE) 

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dash-google-picker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "dash google file picker",
    "author": "lpawlick",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "# Dash Google Picker\n[![PyPI version](https://badge.fury.io/py/dash-google-picker.svg)](https://badge.fury.io/py/dash-google-picker)\n\nThe `dash_google_picker` is a Python module that allows the integration of Google's Picker API with a Dash application. The module provides a Dash component `GooglePicker` to easily implement the Google Picker functionality into your application, enabling your users to select files from their Google Drive account, among other data sources.\n\n## Features\n\n- Leverages Google Picker API for seamless integration with Google Drive.\n- Allows selection of multiple files from Google Drive.\n- Customizable views and features according to Google Picker API.\n\n## [Documentation](https://docs.pawlick.dev/projects/dash_google_picker/)\n\n## Installation\n\nUse pip to install the package:\n\n```bash\npip install dash-google-picker\n```\n\n## Prerequisites\n\nFollow the official [Google Picker Guide](https://developers.google.com/drive/picker/guides/overview) to create the required credentials.\n\n## Usage\n\nThe usage example below shows how to use the `GooglePicker` component in your Dash application.\n\n```python\nfrom typing import List\nfrom dash import Dash, dcc, html, Input, Output, State, dcc\nfrom dash_google_picker import GooglePicker \nfrom dash_google_picker.Documents import GoogleDocuments, GoogleDocument\nimport os\n\napp = Dash(__name__)\n\napp.layout = html.Div([\n    html.Button('Open Google Picker', id='open-picker-button', n_clicks=0),\n    GooglePicker(\n        id='google-picker',\n        client_id='GOOGLE_CLIENT_ID',\n        developer_key='GOOGLE_DEVELOPER_KEY'\n        ),\n    dcc.Markdown(id='display-documents', style={'whiteSpace': 'pre-wrap'}),\n    html.Div(id='display-action')\n])\n\nif __name__ == '__main__':\n    app.run_server(debug=True)\n```\n\nThe picker view can be customised, for more information see the `GooglePicker` component documentation or the [Google Picker API Documentation](https://developers.google.com/picker/docs/reference).\n\n## Callbacks\n\nThe `GooglePicker` component generates two outputs `documents` and `action`. The `documents` output contains a list of documents selected by the user, and `action` contains the current action status.\n\n```python\n@app.callback(\n    Output('google-picker', 'open'),\n    [Input('open-picker-button', 'n_clicks')],\n    [State('google-picker', 'open')]\n)\ndef open_google_picker(n_clicks, is_open):\n    if n_clicks > 0:\n        return not is_open\n    return False\n\n@app.callback(\n    Output('display-documents', 'children'),\n    [Input('google-picker', 'documents')],\n    prevent_initial_call=True\n)\ndef display_output(documents):\n    docs : List[GoogleDocument] = GoogleDocuments(documents)\n    x = \"\\n\".join([f\"{prop}: {getattr(obj, prop)}\" for obj in docs for prop in dir(obj) if not prop.startswith(\"__\")])\n    return x\n\n@app.callback(\n    Output('display-action', 'children'),\n    [Input('google-picker', 'action')],\n    prevent_initial_call=True\n)\ndef display_action(action):\n    if action == \"loaded\":\n        return \"Opened the Google Picker Popup\"\n    elif action == \"picked\":\n        return \"Picked a document\"\n    elif action == \"cancelled\":\n        return \"Cancelled the Google Picker Popup\"\n    return f'Action: {action}'\n```\n\n## License\n\n[MIT](https://github.com/lpawlick/dash_google_picker/blob/master/LICENSE) \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Google picker component for dash",
    "version": "1.1.0",
    "project_urls": {
        "Documentation": "https://docs.pawlick.dev/projects/dash_google_picker",
        "Source": "https://github.com/lpawlick/dash_google_picker",
        "Tracker": "https://github.com/lpawlick/dash_google_picker/issues"
    },
    "split_keywords": [
        "dash",
        "google",
        "file",
        "picker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "219b70067fc2f068a0ab0112f08ddd701816b0c22eed9fc61de076ada44d28b9",
                "md5": "4d83f89e7a89ebbf37ecc475beb68f4f",
                "sha256": "753bae4cd461720f3f64eb78b04c6e548d28f07498bf715f265648f3c76203d9"
            },
            "downloads": -1,
            "filename": "dash_google_picker-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d83f89e7a89ebbf37ecc475beb68f4f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 19293,
            "upload_time": "2023-09-04T23:06:43",
            "upload_time_iso_8601": "2023-09-04T23:06:43.586563Z",
            "url": "https://files.pythonhosted.org/packages/21/9b/70067fc2f068a0ab0112f08ddd701816b0c22eed9fc61de076ada44d28b9/dash_google_picker-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-04 23:06:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lpawlick",
    "github_project": "dash_google_picker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "dash-google-picker"
}
        
Elapsed time: 0.97163s