Answer the question
In order to leave comments, you need to log in
Instead of Ui_MainWindow, Ui_Form, how so?
After converting the .ui format to .py (It's Python, if anything), I have to import the Ui_Form class, unlike the others, who have it called Ui_MainWindow. What is the difference between them??? I'm using the latest version of Python 3.7.3, and PyQt 5.12.2.
Here is an example code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\games\python2\gui\copyper.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(204, 172)
Form.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.Copy = QtWidgets.QPushButton(Form)
self.Copy.setGeometry(QtCore.QRect(60, 50, 75, 23))
self.Copy.setObjectName("Copy")
self.Vvod = QtWidgets.QTextEdit(Form)
self.Vvod.setGeometry(QtCore.QRect(20, 10, 161, 31))
self.Vvod.setObjectName("Vvod")
self.Vivod = QtWidgets.QTextBrowser(Form)
self.Vivod.setGeometry(QtCore.QRect(20, 80, 161, 81))
self.Vivod.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.Vivod.setLocale(QtCore.QLocale(QtCore.QLocale.Russian, QtCore.QLocale.Russia))
self.Vivod.setObjectName("Vivod")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Copyper"))
self.Copy.setText(_translate("Form", "Copy"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question