S
S
studprogrammist2018-02-02 19:46:46
PyQt
studprogrammist, 2018-02-02 19:46:46

How to link QT Form and QtPy files in Pycharm?

Help linking Pycharm 2017.3.3 with PyQt5.
Tried to follow this video instruction.
True, I have Windows 10.
Installation sequence.
1. PyCharm 2017.3.3
2. python-3.5.2-webinstall
3. PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x32-2
At the moment I have:
5a7494bd721c3450874353.png
The interpreter in PyCharm is configured as follows:
5a7495ab02f49875083298.png
When starting a file with the extension .ui command External Tools > Qt Designer, “Qt Designer” opens, that is, everything is fine here. In the .py file, I compile the code:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    sys.exit(app.exec_())

The code compiles, that is, everything is fine here too. And the problem is that changes made in the .ui file are not reflected in the .py file, although it should change. For example, I added a button to “Qt Designer” and when compiling a .py file, it appeared in the program.
At the same time, when creating a .py file, there is no “edit” “From”:
5a7495da7f604765634815.png
It should be something like this, as far as I understand:
5a7495e1980ec061399790.png
With this “edit”, as far as I understand, I should bind .py to .ui ...
But for some reason I have then I don't have it...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
studprogrammist, 2018-02-03
@studprogrammist

I found on the Internet a drag source for a .py file and it all worked :)
Here it is:

from PyQt5 import uic, QtWidgets
import sys

class Ui(QtWidgets.QDialog):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('window.ui', self)
        self.show()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    sys.exit(app.exec_())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question