I'm upgrading from PySide2 version 5 to PySide6, and the release notes say that it supports snake-case method names as well as replacing getter and setter methods with properties. That sounds like a big improvement, but I can't figure out how to enable it. The release notes have a code sample, but it's not runnable. When I try to expand it into a runnable sample, the new version doesn't work.
Here's the old style that still works with PySide6:
import sys
from PySide6.QtWidgets import (QTableWidget, QPushButton, QVBoxLayout,
QApplication, QWidget)
class MyWidget(QWidget):
def __init__(self):
super().__init__()
table = QTableWidget()
table.setColumnCount(2)
button = QPushButton("Add")
button.setEnabled(False)
layout = QVBoxLayout(self)
layout.addWidget(table)
layout.addWidget(button)
if __name__ == "__main__":
app = QApplication([])
widget = MyWidget()
widget.resize(800, 600)
widget.show()
sys.exit(app.exec_())
Here's the new version that doesn't work:
from __feature__ import snake_case, true_property
import sys
from PySide6.QtWidgets import (QTableWidget, QPushButton, QVBoxLayout,
QApplication, QWidget)
class MyWidget(QWidget):
def __init__(self):
super().__init__()
table = QTableWidget()
table.column_count = 2
button = QPushButton("Add")
button.enabled = False
layout = QVBoxLayout(self)
layout.add_widget(table)
layout.add_widget(button)
if __name__ == "__main__":
app = QApplication([])
widget = MyWidget()
widget.resize(800, 600)
widget.show()
sys.exit(app.exec_())
When I run the new version, I get this error:
Traceback (most recent call last):
File "/home/don/.config/JetBrains/PyCharm2021.1/scratches/scratch2.py", line 1, in <module>
from __feature__ import snake_case, true_property
ModuleNotFoundError: No module named '__feature__'
I'm not surprised that breaks, where the heck is __feature__
supposed to come from? I tried switching it to __future__
, but that didn't work either. Just removing the __feature__
line doesn't work either.