This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import sys | |
import PyQt5.QtCore | |
import PyQt5.QtWidgets | |
import PyQt5.uic | |
import sip | |
system_info = f'''\ | |
sys.version: {sys.version} | |
sys.platform: {sys.platform} | |
QT_VERSION_STR: {PyQt5.QtCore.QT_VERSION_STR} | |
PYQT_VERSION_STR: {PyQt5.QtCore.PYQT_VERSION_STR} | |
SIP_VERSION_STR: {sip.SIP_VERSION_STR}''' | |
ui_text = '''\ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<ui version="4.0"> | |
<class>Form</class> | |
<widget class="QWidget" name="Form"> | |
<layout class="QVBoxLayout" name="layout"> | |
<item> | |
<widget class="MyWidget" name="compactepc_5"> | |
<property name="layoutDirection"> | |
<enum>Qt::RightToLeft</enum> | |
</property> | |
</widget> | |
</item> | |
</layout> | |
</widget> | |
<customwidgets> | |
<customwidget> | |
<class>MyWidget</class> | |
<extends>QWidget</extends> | |
<header>bad2</header> | |
</customwidget> | |
</customwidgets> | |
<resources/> | |
<connections/> | |
</ui> | |
''' | |
# note that <header>__main__</header> avoids the exception | |
my_widget_ui_text = '''\ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<ui version="4.0"> | |
<class>Form</class> | |
<widget class="QWidget" name="Form"> | |
<layout class="QGridLayout" name="gridLayout"> | |
</layout> | |
</widget> | |
<resources/> | |
<connections/> | |
</ui> | |
''' | |
MyWidgetUi, MyWidgetUiBase = PyQt5.uic.loadUiType(io.StringIO(my_widget_ui_text)) | |
class MyWidget(MyWidgetUiBase): | |
def __init__(self, parent=None): | |
super().__init__(parent=parent) | |
self.ui = MyWidgetUi() | |
self.ui.setupUi(self) | |
def main(): | |
print(system_info) | |
app = PyQt5.QtWidgets.QApplication([]) | |
instance = PyQt5.uic.loadUi(io.StringIO(ui_text)) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✘ ~/tmp master ● venv3.7.4/bin/python ~/st.src/bad2.py | |
sys.version: 3.7.4 (default, Aug 2 2019, 12:58:45) | |
[GCC 6.3.0 20170516] | |
sys.platform: linux | |
QT_VERSION_STR: 5.13.0 | |
PYQT_VERSION_STR: 5.13.0 | |
SIP_VERSION_STR: 4.19.18 | |
Traceback (most recent call last): | |
File "/home/altendky/st.src/bad2.py", line 78, in <module> | |
main() | |
File "/home/altendky/st.src/bad2.py", line 74, in main | |
instance = PyQt5.uic.loadUi(io.StringIO(ui_text)) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/__init__.py", line 227, in loadUi | |
return DynamicUILoader(package).loadUi(uifile, baseinstance, resource_suffix) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/Loader/loader.py", line 72, in loadUi | |
return self.parse(filename, resource_suffix, basedir) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 1030, in parse | |
actor(elem) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 828, in createUserInterface | |
self.traverseWidgetTree(elem) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 806, in traverseWidgetTree | |
handler(self, child) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 503, in createLayout | |
self.traverseWidgetTree(elem) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 806, in traverseWidgetTree | |
handler(self, child) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 546, in handleItem | |
self.traverseWidgetTree(elem) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 806, in traverseWidgetTree | |
handler(self, child) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 264, in createWidget | |
self.stack.push(self.setupObject(widget_class, parent, elem)) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/uiparser.py", line 230, in setupObject | |
self.wprops.setProperties(obj, branch) | |
File "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py", line 417, in setProperties | |
getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]), prop_name[1:]))(prop_value) | |
TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment