Skip to content

Commit

Permalink
Improve Python Support (#567)
Browse files Browse the repository at this point in the history
- Reduce requirements for the python build.
- Fix version number.
- Generate type hints for *.pyi files.
- Make functional for sip-build
- Reduced the unnecessary depth of the package.

NOTE: This is a breaking change for python users, where, `from PyQtAds import QtAds` is changed to `import PyQtAds as QtAds`( or simply `import PyQtAds`)
  • Loading branch information
nateskulic authored Oct 5, 2023
1 parent c0985f6 commit 55ef6ef
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion demo/status_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

from PyQt5 import uic
from PyQtAds import QtAds
import PyQtAds as QtAds

UI_FILE = os.path.join(os.path.dirname(__file__), 'StatusDialog.ui')
StatusDialogUI, StatusDialogBase = uic.loadUiType(UI_FILE)
Expand Down
2 changes: 1 addition & 1 deletion examples/autohide/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar,
QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog)

from PyQtAds import QtAds
import PyQtAds as QtAds

UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui')
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
Expand Down
2 changes: 1 addition & 1 deletion examples/centralwidget/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar,
QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog)

from PyQtAds import QtAds
import PyQtAds as QtAds

UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui')
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
Expand Down
4 changes: 2 additions & 2 deletions examples/deleteonclose/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from PyQtAds import QtAds
import PyQtAds as QtAds
from PyQt5.QtGui import QCloseEvent
from PyQt5.QtCore import (qDebug, pyqtSlot, QObject, pyqtSignal)
from PyQt5.QtWidgets import (QMainWindow, QAction, QTextEdit, QApplication,
Expand Down Expand Up @@ -70,4 +70,4 @@ def on_action2_triggered():
action.triggered.connect(on_action2_triggered)

w.show()
app.exec_()
app.exec_()
4 changes: 2 additions & 2 deletions examples/dockindock/dockindock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QMessageBox,
QInputDialog, QMenu, QLineEdit)
from PyQt5.QtGui import QIcon
from PyQtAds import QtAds
import PyQtAds as QtAds

from dockindockmanager import DockInDockManager
from perspectiveactions import LoadPerspectiveAction, RemovePerspectiveAction
Expand Down Expand Up @@ -200,4 +200,4 @@ def dumpStatus(self, echo: callable = print, widget: QtAds.CDockWidget = None, t

for closed in self.getManager().dockWidgetsMap().values():
if not closed in visible_widgets:
self.dumpStatus(widget=closed, tab=tab, suffix=" (closed)")
self.dumpStatus(widget=closed, tab=tab, suffix=" (closed)")
4 changes: 2 additions & 2 deletions examples/dockindock/dockindockmanager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtWidgets import QAction, QMenu, QInputDialog, QLineEdit
from PyQt5.QtCore import QSettings

from PyQtAds import QtAds
import PyQtAds as QtAds

CHILD_PREFIX = "Child-"

Expand Down Expand Up @@ -211,4 +211,4 @@ def move(self, widget: QtAds.CDockWidget, move_to: QtAds.CDockManager) -> None:
widget.dockManager().removeDockWidget(widget)
move_to.addDockWidget(QtAds.CenterDockWidgetArea, widget, move_to.getInsertDefaultPos())
else:
assert False
assert False
4 changes: 2 additions & 2 deletions examples/dockindock/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
from PyQt5.QtCore import Qt
from PyQtAds import QtAds
import PyQtAds as QtAds

from perspectives import PerspectivesManager
from dockindock import DockInDockWidget
Expand Down Expand Up @@ -69,4 +69,4 @@ def cleanup(self):

w = MainWindow()
w.show()
app.exec_()
app.exec_()
4 changes: 2 additions & 2 deletions examples/dockindock/perspectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import atexit

from PyQt5.QtCore import pyqtSignal, QSettings, QObject
from PyQtAds import QtAds
import PyQtAds as QtAds

from dockindockmanager import DockInDockManager
from dockindock import DockInDockWidget
Expand Down Expand Up @@ -200,4 +200,4 @@ def savePerspectives(self) -> None:
except FileNotFoundError:
pass
if not shutil.copy(settings.fileName(), to_save):
assert False
assert False
4 changes: 2 additions & 2 deletions examples/emptydockarea/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel, QComboBox, QTableWidget,
QAction, QWidgetAction, QSizePolicy, QInputDialog)
from PyQt5.QtGui import QCloseEvent
from PyQtAds import QtAds
import PyQtAds as QtAds


UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui')
Expand Down Expand Up @@ -105,4 +105,4 @@ def closeEvent(self, event: QCloseEvent):

w = CMainWindow()
w.show()
app.exec_()
app.exec_()
2 changes: 1 addition & 1 deletion examples/sidebar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PyQt5.QtCore import Qt, QMargins
from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QPlainTextEdit

from PyQtAds import QtAds
import PyQtAds as QtAds

UI_FILE = os.path.join(os.path.dirname(__file__), 'MainWindow.ui')
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PyQt5.QtGui import QCloseEvent
from PyQt5.QtWidgets import QApplication, QLabel

from PyQtAds import QtAds
import PyQtAds as QtAds

UI_FILE = os.path.join(os.path.dirname(__file__), 'MainWindow.ui')
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Specify the build system.
[build-system]
requires = ["sip >=6.0.2, <6.3", "PyQt-builder >=1.6, <2", "PyQt5==5.15.4", "PyQt5-sip<13,>=12.8"]
requires = ["sip >=6.0.2", "PyQt-builder >=1.6", "PyQt5>=5.15", "PyQt5-sip>=12.8"]
build-backend = "sipbuild.api"

# Specify the PEP 566 metadata for the project.
[tool.sip.metadata]
name = "PyQtAds"
version = "4.0.2"
version = "4.4.1"
summary = "Python bindings for Qt Advanced Docking System"
home-page = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/"
license = "LGPL v2.1"
Expand All @@ -16,8 +16,10 @@ description-content-type = "text/markdown"

[tool.sip.project]
tag-prefix = "QtAds"
dunder-init = true

[tool.sip.bindings.ads]
pep484-pyi = true
define-macros = ["ADS_SHARED_EXPORT"]
sip-file = "ads.sip"
include-dirs = ["src"]
Expand Down
2 changes: 2 additions & 0 deletions sip/ads.sip
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
%Module(name=PyQtAds, call_super_init=True, keyword_arguments="Optional", use_limited_api=True)
%HideNamespace(name=ads)

%Import QtCore/QtCoremod.sip
%DefaultSupertype sip.simplewrapper

Expand Down

0 comments on commit 55ef6ef

Please sign in to comment.