Recently I started learning python, I liked the PyQt5 library, I started learning. In general, the problem is the following: when opening a program, a window is displayed with the choice of the program language, for example, we select Ukrainian or Russian and the text changes to the one that was selected. I tried to create a function and enter the parameters from the main window, but I can't. And please tell me how to put the button Choose the language in the center of the window?
CODE:
from PyQt5.QtWidgets import (QApplication ,QWidget, QPushButton) from PyQt5 import QtCore from PyQt5 import QtWidgets import sys class MainWindow(QWidget): def __init__(self, parent=None): super().__init__(parent) self.secondWin = None self.initUI() def initUI(self): self.setWindowTitle('Product calculation') self.resize(1000, 640) qr = self.frameGeometry() cp = QtWidgets.QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft()) self.but = QPushButton(self) self.but.setText('Choose the language') self.but.resize(120, 30) self.but.clicked.connect(self.openCL) self.but.clicked.connect(self.hideBut) self.but.clicked.connect(self.showbut) self.but.move(400, 280) self.but.show() self.but1 = QPushButton(self) self.but1.setText('Create calculation') self.but1.resize(140, 32) self.but1.move(100, 100) self.but1.hide() self.but2 = QPushButton(self) self.but2.setText('Search a calculation') self.but2.resize(140, 32) self.but2.move(100, 150) self.but2.hide() self.but3 = QPushButton(self) self.but3.setText('Settings') self.but3.resize(140, 32) self.but3.move(100, 200) self.but3.hide() self.but4 = QPushButton(self) self.but4.setText('About program') self.but4.resize(140, 32) self.but4.move(100, 250) self.but4.hide() def hideBut(self): self.but.hide() def showbut(self): self.but1.show() self.but2.show() self.but3.show() self.but4.show() def openCL(self): if not self.secondWin: self.secondWin = ChooseLang(self) self.secondWin.show() class ChooseLang(QWidget): def __init__(self, parent=None): super().__init__(parent, QtCore.Qt.Window) self.initUI() def initUI(self): self.setWindowTitle('CL') self.resize(200, 100) self.butE = QPushButton(self) self.butE.setText('English') self.butE.move(20, 30) self.butE.clicked.connect(self.closeSW) self.butIta = QPushButton(self) self.butIta.setText('Italian') self.butIta.move(20, 60) self.butIta.clicked.connect(self.closeSW) self.butRu = QPushButton(self) self.butRu.setText('Russian') self.butRu.move(100, 30) self.butRu.clicked.connect(self.closeSW) self.butUa = QPushButton(self) self.butUa.setText('Ukrainian') self.butUa.move(100, 60) self.butUa.clicked.connect(self.closeSW) def closeSW(self): self.close() if __name__== '__main__': app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())