or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

compatibility.mdcore-package.mddevelopment-tools.mdindex.mdqt-modules.mduic-module.md

core-package.mddocs/

0

# Core Package Interface

1

2

Main QtPy package constants, exception classes, and binding information that provide the foundation for Qt binding abstraction and compatibility management.

3

4

## Capabilities

5

6

### Version Information

7

8

Access to QtPy and underlying Qt binding version information.

9

10

```python { .api }

11

__version__: str

12

"""QtPy version string (e.g., "2.4.3")"""

13

14

QT_VERSION: str | None

15

"""Version of Qt framework being used"""

16

17

PYQT_VERSION: str | None

18

"""Version of PyQt binding if being used, None otherwise"""

19

20

PYSIDE_VERSION: str | None

21

"""Version of PySide binding if being used, None otherwise"""

22

```

23

24

Usage example:

25

26

```python

27

import qtpy

28

print(f"QtPy version: {qtpy.__version__}")

29

print(f"Qt version: {qtpy.QT_VERSION}")

30

if qtpy.PYQT_VERSION:

31

print(f"PyQt version: {qtpy.PYQT_VERSION}")

32

```

33

34

### API Detection

35

36

Information about the currently selected Qt binding and available bindings.

37

38

```python { .api }

39

API: str

40

"""Currently selected API name ('pyqt5', 'pyside2', 'pyqt6', 'pyside6')"""

41

42

API_NAME: str

43

"""Display name of currently selected API ('PyQt5', 'PySide2', 'PyQt6', 'PySide6')"""

44

45

QT5: bool

46

"""True if Qt5 is being used"""

47

48

QT6: bool

49

"""True if Qt6 is being used"""

50

51

PYQT5: bool

52

"""True if PyQt5 is being used"""

53

54

PYQT6: bool

55

"""True if PyQt6 is being used"""

56

57

PYSIDE2: bool

58

"""True if PySide2 is being used"""

59

60

PYSIDE6: bool

61

"""True if PySide6 is being used"""

62

```

63

64

Usage example:

65

66

```python

67

import qtpy

68

69

# Check which binding is active

70

print(f"Using {qtpy.API_NAME}")

71

72

# Conditional logic based on binding

73

if qtpy.QT6:

74

print("Using Qt6 features")

75

elif qtpy.QT5:

76

print("Using Qt5 features")

77

78

# Check specific binding

79

if qtpy.PYQT5:

80

print("PyQt5 specific code")

81

elif qtpy.PYSIDE6:

82

print("PySide6 specific code")

83

```

84

85

### API Configuration Constants

86

87

Constants for configuring and working with different Qt bindings.

88

89

```python { .api }

90

QT_API: str

91

"""Environment variable name for selecting Qt API ('QT_API')"""

92

93

PYQT5_API: list[str]

94

"""Names of the expected PyQt5 api (['pyqt5'])"""

95

96

PYQT6_API: list[str]

97

"""Names of the expected PyQt6 api (['pyqt6'])"""

98

99

PYSIDE2_API: list[str]

100

"""Names of the expected PySide2 api (['pyside2'])"""

101

102

PYSIDE6_API: list[str]

103

"""Names of the expected PySide6 api (['pyside6'])"""

104

105

API_NAMES: dict[str, str]

106

"""Mapping of API names to display names"""

107

108

binding_specified: bool

109

"""True if a binding was explicitly specified via QT_API environment variable"""

110

111

initial_api: str

112

"""The initially requested API before any fallback logic"""

113

```

114

115

### Version Requirements

116

117

Minimum supported versions for Qt and bindings.

118

119

```python { .api }

120

QT5_VERSION_MIN: str

121

"""Minimum supported Qt5 version"""

122

123

QT6_VERSION_MIN: str

124

"""Minimum supported Qt6 version"""

125

126

PYQT5_VERSION_MIN: str

127

"""Minimum supported PyQt5 version"""

128

129

PYQT6_VERSION_MIN: str

130

"""Minimum supported PyQt6 version"""

131

132

PYSIDE2_VERSION_MIN: str

133

"""Minimum supported PySide2 version"""

134

135

PYSIDE6_VERSION_MIN: str

136

"""Minimum supported PySide6 version"""

137

138

QT_VERSION_MIN: str

139

"""Minimum supported Qt version (alias for QT5_VERSION_MIN)"""

140

141

PYQT_VERSION_MIN: str

142

"""Minimum supported PyQt version (alias for PYQT5_VERSION_MIN)"""

143

144

PYSIDE_VERSION_MIN: str

145

"""Minimum supported PySide version (alias for PYSIDE2_VERSION_MIN)"""

146

```

147

148

### Exception Classes

149

150

Comprehensive error handling for different binding and module availability scenarios.

151

152

```python { .api }

153

class PythonQtError(RuntimeError):

154

"""Generic error superclass for QtPy."""

155

156

class PythonQtWarning(RuntimeWarning):

157

"""Warning class for QtPy."""

158

159

class PythonQtValueError(ValueError):

160

"""Error raised if an invalid QT_API is specified."""

161

162

class QtBindingsNotFoundError(PythonQtError, ImportError):

163

"""Error raised if no bindings could be found."""

164

165

def __init__(self): ...

166

167

class QtModuleNotFoundError(ModuleNotFoundError, PythonQtError):

168

"""Raised when a Python Qt binding submodule is not installed/supported."""

169

170

def __init__(self, *, name: str, msg: str | None = None, **msg_kwargs): ...

171

172

class QtModuleNotInOSError(QtModuleNotFoundError):

173

"""Raised when a module is not supported on the current operating system."""

174

175

class QtModuleNotInQtVersionError(QtModuleNotFoundError):

176

"""Raised when a module is not implemented in the current Qt version."""

177

178

class QtBindingMissingModuleError(QtModuleNotFoundError):

179

"""Raised when a module is not supported by a given binding."""

180

181

class QtModuleNotInstalledError(QtModuleNotFoundError):

182

"""Raise when a module is supported by the binding, but not installed."""

183

184

def __init__(self, *, missing_package: str | None = None, **superclass_kwargs): ...

185

```

186

187

Usage example:

188

189

```python

190

import qtpy

191

192

try:

193

from qtpy import QtWebEngine

194

except qtpy.QtModuleNotFoundError as e:

195

print(f"Module not available: {e}")

196

# Handle missing module gracefully

197

198

try:

199

from qtpy import QtMacExtras

200

except qtpy.QtModuleNotInOSError as e:

201

print(f"Module not supported on this OS: {e}")

202

```