Add a function wrapper that makes the linter happy when used for Qt slots

This commit is contained in:
Veronica Berglyd Olsen
2024-10-29 17:37:50 +01:00
parent b2d71acd93
commit 4eace705e3
3 changed files with 48 additions and 36 deletions
+12
View File
@@ -29,6 +29,7 @@ import unicodedata
import uuid
import xml.etree.ElementTree as ET
from collections.abc import Callable
from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
@@ -414,6 +415,10 @@ def numberToRoman(value: int, toLower: bool = False) -> str:
return roman.lower() if toLower else roman
##
# Qt Helpers
##
def cssCol(col: QColor, alpha: int | None = None) -> str:
"""Convert a QColor object to an rgba entry to use in CSS."""
return f"rgba({col.red()}, {col.green()}, {col.blue()}, {alpha or col.alpha()})"
@@ -429,6 +434,13 @@ def describeFont(font: QFont) -> str:
return "Error"
def qtLambda(func: Callable, *args: Any, **kwargs: Any) -> Callable:
"""A replacement for Python lambdas that works for Qt slots."""
def wrapper(*args_: Any, **kwargs_: Any) -> None:
func(*args, **kwargs)
return wrapper
##
# Encoder Functions
##