Start working on stubs for 2.6.0 (extensions, etc.).

This commit is contained in:
Mikaël Capelle
2024-08-11 13:31:30 +02:00
parent dd80b67a0a
commit 6fe9b1d569
6 changed files with 8862 additions and 2 deletions
File diff suppressed because it is too large Load Diff
+7
View File
@@ -146,6 +146,9 @@ def main() -> None:
[
# the "real" IPlugin is IPluginBase
"IPlugin",
# this is deprecated
"PluginSetting"
],
),
"mobase.widgets": extract_objects(mobase.widgets), # type: ignore
@@ -171,6 +174,10 @@ def main() -> None:
# Create the corresponding object:
c = register.make_object(n, o)
for n, o in objects:
c = register.get_object(n)
if isinstance(c, Class):
# Clean the class (e.g., remove duplicates methods due to wrappers):
clean_class(c)
+1 -1
View File
@@ -33,7 +33,7 @@ def load_mobase(path: os.PathLike[Any]) -> Module:
os.add_dll_directory(str(path.joinpath("dlls"))) # type: ignore
# We need to add plugins/data to sys.path, mainly for PyQt6
sys.path.insert(1, path.joinpath("plugins", "plugin_python", "libs").as_posix())
sys.path.insert(1, path.joinpath("proxies", "python", "libs").as_posix())
import mobase # type: ignore
+3 -1
View File
@@ -234,6 +234,8 @@ def make_class(e: type, register: MobaseRegister) -> Class:
# members to exclude
EXCLUDED_MEMBERS = [
"__init_subclass__",
"__dict__",
"__doc__",
"__module__",
"__subclasshook__",
"__hash__",
@@ -346,7 +348,7 @@ def make_class(e: type, register: MobaseRegister) -> Class:
direct_bases: list[Class] = []
for c in e.__bases__:
if c.__module__ != "pybind11_builtins":
if c.__module__ not in ("pybind11_builtins", "builtins"):
b = register.get_object(c.__name__)
assert isinstance(b, Class)
direct_bases.append(b)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,172 @@
from __future__ import annotations
__version__ = "2.5.2"
from typing import List, Tuple, Union, overload
import PyQt6.QtCore
import PyQt6.QtGui
import PyQt6.QtWidgets
class TaskDialog:
"""
Customizable choice dialog.
"""
def __init__(
self: TaskDialog,
parent: PyQt6.QtWidgets.QWidget | None = None,
title: str = "",
main: str = "",
content: str = "",
details: str = "",
icon: PyQt6.QtWidgets.QMessageBox.Icon = PyQt6.QtWidgets.QMessageBox.Icon.NoIcon,
buttons: list[TaskDialogButton] = [],
remember: Union[str, tuple[str, str]] = "",
) -> None:
"""
Construct a new TaskDialog.
Args:
parent: Parent widget of the dialog.
title: Title of the dialog.
main: Header of the dialog (big text at the top).
content: Main message of the dialog (text below main).
details: Details for the dialog, initially collapsed (bottom of the dialog).
icon: Icon for the dialog.
buttons: List of buttons for the dialog.
remember: Remember the choice for this dialog.
"""
...
def addButton(self: TaskDialog, button: TaskDialogButton) -> TaskDialog:
"""
Add a custom button to this TaskDialog.
Args:
button: Button to add to the dialog.
"""
...
def addContent(self: TaskDialog, widget: PyQt6.QtWidgets.QWidget) -> None:
"""
Add a custom widget content to this TaskDialog. Widget content are put between
content and buttons (above buttons).
Args:
widget: Widget to add.
"""
...
def exec(self: TaskDialog) -> PyQt6.QtWidgets.QMessageBox.StandardButton:
"""
Display this dialog and wait for user-interaction to return. This is a blocking
function.
Returns:
The button clicked by the user. Without custom buttons, this return Ok,
otherwise it returns the button set in the TaskDialogButton.
"""
...
def setContent(self: TaskDialog, content: str) -> TaskDialog:
"""
Set the top-level message of this dialog.
Args:
content: Top-level message to set.
"""
...
def setDetails(self: TaskDialog, details: str) -> TaskDialog:
"""
Set the details for this TaskDialog.
The details are hidden by default and the user can display them by clicking
the "Details" button at the bottom of the TaskDialog.
Args:
details: Details content to display. Can be a multi-line string.
"""
...
def setIcon(self: TaskDialog, icon: PyQt6.QtWidgets.QMessageBox.Icon) -> TaskDialog:
"""
Set the icon of the dialog.
Args:
icon: Icon of the dialog.
"""
...
def setMain(self: TaskDialog, main: str) -> TaskDialog:
"""
Set the main message of the dialog. The main message is displayed at the top of
the dialog in large font.
Args:
main: Main message of the dialog.
"""
...
def setRemember(self: TaskDialog, action: str, file: str = "") -> TaskDialog:
"""
Configure the dialog to remember user-choice.
"""
...
def setTitle(self: TaskDialog, title: str) -> TaskDialog:
"""
Set the title of the dialog.
Args:
title: Title of the dialog.
"""
...
def setWidth(self: TaskDialog, width: int) -> None:
"""
Set the width of the dialog.
Args:
width: Width of the dialog.
"""
...
class TaskDialogButton:
"""
Special button to be used inside TaskDialog widgets.
"""
@property
def button(self) -> PyQt6.QtWidgets.QMessageBox.StandardButton: ...
@button.setter
def button(self, arg0: PyQt6.QtWidgets.QMessageBox.StandardButton) -> None: ...
@property
def description(self) -> str: ...
@description.setter
def description(self, arg0: str) -> None: ...
@property
def text(self) -> str: ...
@text.setter
def text(self, arg0: str) -> None: ...
@overload
def __init__(
self: TaskDialogButton,
text: str,
description: str,
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
) -> None:
"""
Create a TaskDialogButton.
Args:
text: Label of the button.
description: Description of the button.
button: Value returned by TaskDialog.exec() if this button is clicked.
"""
...
@overload
def __init__(
self: TaskDialogButton,
text: str,
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
) -> None:
"""
Create a TaskDialogButton without description.
Args:
text: Label of the button.
button: Value returned by TaskDialog.exec() if this button is clicked.
"""
...