Skip to content

Commit 064d91f

Browse files
authored
feature: add PySide6 support (#25)
Changes: * Added option to use PySide6 * use PyQt5 or PySide6 based on the already imported modules
1 parent 666e372 commit 064d91f

File tree

11 files changed

+62
-18
lines changed

11 files changed

+62
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pyqtlet2
22

3-
pyqtlet is a wrapper for Leaflet maps in PyQt5. In construction and design, it mimics the [official leaflet api](http://leafletjs.com/reference-1.3.0.html) as much as possible.
3+
pyqtlet is a wrapper for Leaflet maps in PyQt5 or PySide6. In construction and design, it mimics the [official leaflet api](http://leafletjs.com/reference-1.3.0.html) as much as possible.
44

55
## About
66

@@ -9,7 +9,7 @@ This is a fork of the repository pyqtlet from @skylarkdrones. Since the original
99
## Installation
1010

1111
``` bash
12-
pip3 install PyQt5
12+
pip3 install PyQt5 # or pip3 install PySide6
1313
pip3 install PyQtWebEngine
1414
pip3 install pyqtlet2
1515
```

docs/source/getting-started.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Google Earth and KML files for all our mapping needs.
1111

1212
.. note::
1313
pyqtlet was designed for people familiar with both `PyQt5 <http://zetcode.com/gui/pyqt5/>`_ and `Leaflet <https://leafletjs.com/examples/quick-start/>`_.
14-
It is suggested you go through the respective guides if not already familiar.
14+
It is suggested you go through the respective guides if not already familiar. PySide6 is also supported.
1515

1616

1717
Installation
1818
------------
1919

20-
pyqtlet does not have any external dependencies apart from PyQt5. So if you already
20+
pyqtlet does not have any external dependencies apart from PyQt5 or PySide6. So if you already
2121
have pyqtlet installed, then you just need to copy the pyqtlet folder into your
2222
project folder. You may also install pyqtlet from pip. This will install PyQt5 if
2323
it has not been installed already.

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pyqtlet
22
=======
33

4-
pyqtlet brings `Leaflet <https://leafletjs.com/>`_ maps to `PyQt5 <http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html>`_.
4+
pyqtlet brings `Leaflet <https://leafletjs.com/>`_ maps to `PyQt5 <http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html>`_ or PySide6.
55

66
`Leaflet <https://leafletjs.com/>`_ is the most popular mapping library on the web. It has most mapping features that you might need, excellent documentation, and a host of plugins. In contstruction and design, pyqtlet attempts to mimic the `official Leaflet API <http://leafletjs.com/reference-1.3.0.html>`_ as much as possible.
77

8-
pyqtlet allows you to bring in these leaflet maps into PyQt5 in just a couple of lines. It provides a mapWidget (which is a QWidget) as well as a namespace (L) in order to mimic the Leaflet API.
8+
pyqtlet allows you to bring in these leaflet maps into PyQt5 or PySide6 in just a couple of lines. It provides a mapWidget (which is a QWidget) as well as a namespace (L) in order to mimic the Leaflet API.
99

1010
.. code-block:: python
1111

pyqtlet2/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
"""
44

55
__author__ = 'Leon Friedmann <leon.friedmann@tum.de>'
6-
__version__ = '0.5.0'
6+
__version__ = '0.7.0'
7+
import sys
8+
9+
if 'PySide6' in sys.modules:
10+
API = 'PySide6'
11+
else:
12+
API = 'PyQt5'
713

814
from .mapwidget import MapWidget
915
from .leaflet import L

pyqtlet2/leaflet/control/control.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import os
44
import time
55

6-
from PyQt5.QtCore import pyqtSlot, pyqtSignal
6+
from ... import API
7+
8+
if API == 'PyQt5':
9+
from PyQt5.QtCore import pyqtSlot, pyqtSignal
10+
else:
11+
from PySide6.QtCore import Slot, Signal
12+
pyqtSlot = Slot
13+
pyqtSignal = Signal
714

815
from ..core import Evented
916

pyqtlet2/leaflet/core/evented.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import logging
22
import time
33

4-
from PyQt5.QtCore import QObject, QJsonValue
4+
from ... import API, mapwidget
55

6-
from ... import mapwidget
6+
if API == 'PyQt5':
7+
from PyQt5.QtCore import QObject, QJsonValue
8+
else:
9+
from PySide6.QtCore import QObject, QJsonValue
710

811

912
class Evented(QObject):

pyqtlet2/leaflet/layer/marker/marker.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from ..layer import Layer
22
from ..icon import Icon
33
from ...core.Parser import Parser
4-
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QJsonValue
4+
5+
from .... import API
6+
7+
if API == 'PyQt5':
8+
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QJsonValue
9+
else:
10+
from PySide6.QtCore import Slot, Signal, QJsonValue
11+
pyqtSlot, pyqtSignal = Slot, Signal
12+
513
from typing import List
614

715

pyqtlet2/leaflet/map/map.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import os
44
import time
55

6-
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QJsonValue
6+
from ... import API
7+
8+
if API == 'PyQt5':
9+
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QJsonValue
10+
else:
11+
from PySide6.QtCore import Slot, Signal, QJsonValue
12+
pyqtSignal = Signal
13+
pyqtSlot = Slot
714

815
from ... import mapwidget
916
from ..core import Evented

pyqtlet2/mapwidget.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import os
22
import time
33

4-
from PyQt5.QtCore import QEventLoop, QObject, Qt, QUrl, pyqtSignal
5-
from PyQt5.QtWebChannel import QWebChannel
6-
from PyQt5.QtWebEngineWidgets import ( QWebEngineView, QWebEnginePage, QWebEngineSettings,
4+
from . import API
5+
6+
if API == 'PyQt5':
7+
from PyQt5.QtCore import QEventLoop, QObject, Qt, QUrl, pyqtSignal
8+
from PyQt5.QtWebChannel import QWebChannel
9+
from PyQt5.QtWebEngineWidgets import ( QWebEngineView, QWebEnginePage, QWebEngineSettings,
710
QWebEngineScript )
11+
Signal = pyqtSignal
12+
else:
13+
from PySide6.QtCore import QEventLoop, QObject, QUrl, Signal, Qt
14+
from PySide6.QtWebChannel import QWebChannel
15+
from PySide6.QtWebEngineWidgets import QWebEngineView
16+
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineSettings, QWebEngineScript
817

918

1019
class MapWidget(QWebEngineView):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='pyqtlet2',
8-
version='0.6.1',
8+
version='0.7.0',
99
description='Bringing leaflet maps to PyQt',
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)