DeprecationWarning: sipPyTypeDict() is deprecated, the extension module should use sipPyTypeDictRef() instead class PaintBoard(QWidget):
时间: 2023-12-29 19:25:50 浏览: 83
根据提供的引用内容,出现了两个DeprecationWarning警告。第一个警告是关于PyQt5改为PyQt6后的报错,警告信息是"sipPyTypeDict() is deprecated, the extension module should use sipPyTypeDictRef() instead"。第二个警告是关于Python 3.9和PyCharm环境中的报错,警告信息是"Application.make_handler() is deprecated, use AppRunner API instead"。
针对第一个警告,可以尝试使用新的方法sipPyTypeDictRef()来替代sipPyTypeDict()。具体代码如下所示:
```python
class PaintBoard(QWidget):
def __init__(self):
super().__init__()
# 其他初始化代码
def init(self):
# 替换为新的方法
sipPyTypeDictRef()
# 其他代码
```
针对第二个警告,可以尝试使用AppRunner API来替代make_handler()方法。具体代码如下所示:
```python
class PaintBoard(QWidget):
def __init__(self):
super().__init__()
# 其他初始化代码
def init(self):
# 替换为新的方法
app_runner = AppRunner(app)
srv = await loop.create_server(app_runner.handle_request, '127.0.0.1', 80)
# 其他代码
```