pyqtlet2


Namepyqtlet2 JSON
Version 0.9.3 PyPI version JSON
download
home_pagehttps://github.com/JaWeilBaum/pyqtlet2
SummaryBringing leaflet maps to Python Qt bindings
upload_time2023-02-02 15:33:53
maintainer
docs_urlNone
authorLeon Friedmann
requires_python
license
keywords leaflet qtpy maps python python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyqtlet2

pyqtlet is a Leaflet map wrapper for Qt bindings. In construction and design, it mimics the [official leaflet api](http://leafletjs.com/reference-1.3.0.html) as much as possible.

## About

This is a fork of the repository pyqtlet from @skylarkdrones. Since the original repository is not further maintained. Since I find this package very useful for a map implementation in the QT environment, I want to further develop this package. If you want to extend this package feel free to get in contact with me or create an Issue/Pull Request with a change! 

## Installation

You as a user need to specify the Qt package you want to use. Please check [qtpy](https://github.com/spyder-ide/qtpy) to find out which Qt bindings can be used. 



``` bash
pip3 install "pyqtlet2[PyQt5]"
# or
pip3 install "pyqtlet2[PySide6]"
```

If you have multiple Qt bindings installed in your environment, please specify the necessary environment variable inside your code.

``` python 
import os
os.environ['QT_API'] = 'pyqt5'
from qtpy import QtGui
```

Check if the installation was successful:

``` bash
# To test whether it is successfully working
python3 
>>> from pyqtlet import L, MapWidget
>>> # No errors
```

## Usage

``` python
import os
import sys
os.environ['QT_API'] = 'pyqt5'
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
from pyqtlet2 import L, MapWidget


class MapWindow(QWidget):
    def __init__(self):
        # Setting up the widgets and layout
        super().__init__()
        self.mapWidget = MapWidget()
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.mapWidget)
        self.setLayout(self.layout)

        # Working with the maps with pyqtlet
        self.map = L.map(self.mapWidget)
        self.map.setView([12.97, 77.59], 10)
        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map)
        self.marker = L.marker([12.934056, 77.610029])
        self.marker.bindPopup('Maps are a treasure.')
        self.map.addLayer(self.marker)
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    widget = MapWindow()
    sys.exit(app.exec_())
```

## Additional Leaflet Packages
- Leaflet.draw (Version 0.4.14) - https://github.com/Leaflet/Leaflet.draw
- Leaflet.RotatedMarker (Version 0.2.0) - https://github.com/bbecquet/Leaflet.RotatedMarker

## Using Unimplemented Leaflet Features
At this time, there is none actively adding features to pyqtlet. This means that there
are a lot of Leaflet features that are not implemented in pyqtlet. However, there is still
a way to access these features via the `runJavaScript` api. This allows arbitrary code to
be run within the map window.

For example, if we want to change the marker icon in the above example, add the following
2 lines of code after the `self.map.addLayer(self.marker)` statement.

``` python
        # Create a icon called markerIcon in the js runtime.
        self.map.runJavaScript('var markerIcon = L.icon({iconUrl: "https://leafletjs.com/examples/custom-icons/leaf-red.png"});')
        # Edit the existing python object by accessing it's jsName property
        self.map.runJavaScript(f'{self.marker.jsName}.setIcon(markerIcon);')
```

This technique will allow users to use all the features available in leaflet.

## Contributors

A big thank you, goes to all the contributors of this project!

<a href="https://github.com/JaWeilBaum/pyqtlet2/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=JaWeilBaum/pyqtlet2" />
</a>

## Contributing
In terms of contributing, there is a lot of work that still needs to be done. 
Specifically, there are a lot of leaflet features that need to be ported into pyqtlet. All contributions welcome.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JaWeilBaum/pyqtlet2",
    "name": "pyqtlet2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "leaflet,qtpy,maps,python,python3",
    "author": "Leon Friedmann",
    "author_email": "leon.friedmann@tum.de",
    "download_url": "https://files.pythonhosted.org/packages/f7/d5/b9425b56506c8b2ddc64309bde30dce4adc371c602f9715f36a523bf983e/pyqtlet2-0.9.3.tar.gz",
    "platform": null,
    "description": "# pyqtlet2\n\npyqtlet is a Leaflet map wrapper for Qt bindings. In construction and design, it mimics the [official leaflet api](http://leafletjs.com/reference-1.3.0.html) as much as possible.\n\n## About\n\nThis is a fork of the repository pyqtlet from @skylarkdrones. Since the original repository is not further maintained. Since I find this package very useful for a map implementation in the QT environment, I want to further develop this package. If you want to extend this package feel free to get in contact with me or create an Issue/Pull Request with a change! \n\n## Installation\n\nYou as a user need to specify the Qt package you want to use. Please check [qtpy](https://github.com/spyder-ide/qtpy) to find out which Qt bindings can be used. \n\n\n\n``` bash\npip3 install \"pyqtlet2[PyQt5]\"\n# or\npip3 install \"pyqtlet2[PySide6]\"\n```\n\nIf you have multiple Qt bindings installed in your environment, please specify the necessary environment variable inside your code.\n\n``` python \nimport os\nos.environ['QT_API'] = 'pyqt5'\nfrom qtpy import QtGui\n```\n\nCheck if the installation was successful:\n\n``` bash\n# To test whether it is successfully working\npython3 \n>>> from pyqtlet import L, MapWidget\n>>> # No errors\n```\n\n## Usage\n\n``` python\nimport os\nimport sys\nos.environ['QT_API'] = 'pyqt5'\nfrom qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget\nfrom pyqtlet2 import L, MapWidget\n\n\nclass MapWindow(QWidget):\n    def __init__(self):\n        # Setting up the widgets and layout\n        super().__init__()\n        self.mapWidget = MapWidget()\n        self.layout = QVBoxLayout()\n        self.layout.addWidget(self.mapWidget)\n        self.setLayout(self.layout)\n\n        # Working with the maps with pyqtlet\n        self.map = L.map(self.mapWidget)\n        self.map.setView([12.97, 77.59], 10)\n        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map)\n        self.marker = L.marker([12.934056, 77.610029])\n        self.marker.bindPopup('Maps are a treasure.')\n        self.map.addLayer(self.marker)\n        self.show()\n\nif __name__ == '__main__':\n    app = QApplication(sys.argv)\n    widget = MapWindow()\n    sys.exit(app.exec_())\n```\n\n## Additional Leaflet Packages\n- Leaflet.draw (Version 0.4.14) - https://github.com/Leaflet/Leaflet.draw\n- Leaflet.RotatedMarker (Version 0.2.0) - https://github.com/bbecquet/Leaflet.RotatedMarker\n\n## Using Unimplemented Leaflet Features\nAt this time, there is none actively adding features to pyqtlet. This means that there\nare a lot of Leaflet features that are not implemented in pyqtlet. However, there is still\na way to access these features via the `runJavaScript` api. This allows arbitrary code to\nbe run within the map window.\n\nFor example, if we want to change the marker icon in the above example, add the following\n2 lines of code after the `self.map.addLayer(self.marker)` statement.\n\n``` python\n        # Create a icon called markerIcon in the js runtime.\n        self.map.runJavaScript('var markerIcon = L.icon({iconUrl: \"https://leafletjs.com/examples/custom-icons/leaf-red.png\"});')\n        # Edit the existing python object by accessing it's jsName property\n        self.map.runJavaScript(f'{self.marker.jsName}.setIcon(markerIcon);')\n```\n\nThis technique will allow users to use all the features available in leaflet.\n\n## Contributors\n\nA big thank you, goes to all the contributors of this project!\n\n<a href=\"https://github.com/JaWeilBaum/pyqtlet2/graphs/contributors\">\n  <img src=\"https://contrib.rocks/image?repo=JaWeilBaum/pyqtlet2\" />\n</a>\n\n## Contributing\nIn terms of contributing, there is a lot of work that still needs to be done. \nSpecifically, there are a lot of leaflet features that need to be ported into pyqtlet. All contributions welcome.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Bringing leaflet maps to Python Qt bindings",
    "version": "0.9.3",
    "split_keywords": [
        "leaflet",
        "qtpy",
        "maps",
        "python",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "14e8e3c1ee62759a87ba642409b96860f50c648ba1e898df8b4114fb2a01157a",
                "md5": "ef1c7a25acabf8405a5a6f2a69830c45",
                "sha256": "c6ce718461cc4662b69623561d276975baac3cc2c17f5dddc8e448b91991c6ab"
            },
            "downloads": -1,
            "filename": "pyqtlet2-0.9.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ef1c7a25acabf8405a5a6f2a69830c45",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 110461,
            "upload_time": "2023-02-02T15:33:51",
            "upload_time_iso_8601": "2023-02-02T15:33:51.436382Z",
            "url": "https://files.pythonhosted.org/packages/14/e8/e3c1ee62759a87ba642409b96860f50c648ba1e898df8b4114fb2a01157a/pyqtlet2-0.9.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7d5b9425b56506c8b2ddc64309bde30dce4adc371c602f9715f36a523bf983e",
                "md5": "6249148120b6781e4e6b74de46c01f57",
                "sha256": "51b361bfb1305b63b4b10ff3f861881e3bd7894ed93e9dde294d5ba8a34784f5"
            },
            "downloads": -1,
            "filename": "pyqtlet2-0.9.3.tar.gz",
            "has_sig": false,
            "md5_digest": "6249148120b6781e4e6b74de46c01f57",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 103854,
            "upload_time": "2023-02-02T15:33:53",
            "upload_time_iso_8601": "2023-02-02T15:33:53.668669Z",
            "url": "https://files.pythonhosted.org/packages/f7/d5/b9425b56506c8b2ddc64309bde30dce4adc371c602f9715f36a523bf983e/pyqtlet2-0.9.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-02 15:33:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "JaWeilBaum",
    "github_project": "pyqtlet2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyqtlet2"
}
        
Elapsed time: 0.08768s