Qt Desinger ui files to pyi stub generation /u/sausix Python Education

I prefer using .ui files from Qt Designer to build UIs for PySide6. This is more convenient for me than compiling Python modules with pyside6-uic or similar tools.
I know pros and cons of both methods.

The only con (for me) of using ui files is missing type hints within IDEs.
For example self.toolBar is always an unknown attribute (but works on runtime of course).

Just found out that just having a .pyi stub file totally solves that issue!
So I was investigating for a pyi generator and got stuck a bit.

Existing tools method:

pyside6-uic still does not support type hints in its output. So mypy or stubgen are complaining a lot.
That could be solved by some grep magic. But mypy also has issues on typing attributes and it result in a lot of _typeshed.Incomplete statements which don’t help:

class Ui_MainWindow: menubar: Incomplete toolBar: Incomplete ... 

Related bug report: https://github.com/python/mypy/issues/14673

Isn’t there an existing solution yet for this easy task? I’m asking because I would be ready to create a transcoder which translates the ui xml into pyi statements.

Thank you.

submitted by /u/sausix
[link] [comments]

​r/learnpython I prefer using .ui files from Qt Designer to build UIs for PySide6. This is more convenient for me than compiling Python modules with pyside6-uic or similar tools. I know pros and cons of both methods. The only con (for me) of using ui files is missing type hints within IDEs. For example self.toolBar is always an unknown attribute (but works on runtime of course). Just found out that just having a .pyi stub file totally solves that issue! So I was investigating for a pyi generator and got stuck a bit. Existing tools method: pyside6-uic still does not support type hints in its output. So mypy or stubgen are complaining a lot. That could be solved by some grep magic. But mypy also has issues on typing attributes and it result in a lot of _typeshed.Incomplete statements which don’t help: class Ui_MainWindow: menubar: Incomplete toolBar: Incomplete … Related bug report: https://github.com/python/mypy/issues/14673 Isn’t there an existing solution yet for this easy task? I’m asking because I would be ready to create a transcoder which translates the ui xml into pyi statements. Thank you. submitted by /u/sausix [link] [comments] 

I prefer using .ui files from Qt Designer to build UIs for PySide6. This is more convenient for me than compiling Python modules with pyside6-uic or similar tools.
I know pros and cons of both methods.

The only con (for me) of using ui files is missing type hints within IDEs.
For example self.toolBar is always an unknown attribute (but works on runtime of course).

Just found out that just having a .pyi stub file totally solves that issue!
So I was investigating for a pyi generator and got stuck a bit.

Existing tools method:

pyside6-uic still does not support type hints in its output. So mypy or stubgen are complaining a lot.
That could be solved by some grep magic. But mypy also has issues on typing attributes and it result in a lot of _typeshed.Incomplete statements which don’t help:

class Ui_MainWindow: menubar: Incomplete toolBar: Incomplete ... 

Related bug report: https://github.com/python/mypy/issues/14673

Isn’t there an existing solution yet for this easy task? I’m asking because I would be ready to create a transcoder which translates the ui xml into pyi statements.

Thank you.

submitted by /u/sausix
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *