Okay I cannot understand what the actual issue is but I went through and created that window with what I believe are all its bells and whistles and have rendered it below. Hope this helps solve whatever the issue is/was??
# -*- coding: utf-8 -*-
#Изначально подключаются необходимые библиотеки
from PyQt5.QtCore import pyqtSlot, QSize
from PyQt5.QtGui import QFont, QColor, QPalette
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout
from PyQt5.QtWidgets import QPushButton, QLabel, QLineEdit
class HeaderLabel(QLabel):
def __init__(self, Text):
QLabel.__init__(self)
# -------
self.setText(Text)
# -------
FontHeader = QFont()
FontHeader.setFamily('Segoe Print')
FontHeader.setPointSize(14)
# -------
self.setFont(FontHeader)
self.setStyleSheet('QLabel:hover {color:red}')
class BasicButton(QPushButton):
def __init__(self, Text, Width):
QPushButton.__init__(self)
# -------
self.setText(Text)
# -------
BtnSize = QSize(Width, 61)
self.setFixedSize(BtnSize)
# -------
StyleValues = 'QPushButton {'
StyleValues += 'background-color:grey; '
StyleValues += 'border:none; '
StyleValues += 'color:white; '
StyleValues += ' } '
StyleValues += 'QPushButton:hover{'
StyleValues += 'background-color:white; '
StyleValues += 'color:black; '
StyleValues += ' } '
self.setStyleSheet(StyleValues)
self.setAutoFillBackground(True)
# -------
BtnFont = QFont()
BtnFont.setPixelSize(20)
BtnFont.setBold(True)
self.setFont(BtnFont)
# -------
self.setAutoExclusive(False)
self.setAutoDefault(False)
self.setAutoRepeat(False)
self.setDefault(False)
self.setFlat(False)
class CenterPanel(QWidget):
def __init__(self, parent):
QWidget.__init__(self)
self.Parent = parent
# -------
Palet = QPalette()
Palet.setColor(QPalette.Window, QColor(243, 239, 255))
self.setPalette(Palet)
self.setAutoFillBackground(True)
# -------
lblHeadr1 = HeaderLabel('Введите текст')
# -------
HBox1 = QHBoxLayout()
HBox1.addStretch(1)
HBox1.addWidget(lblHeadr1)
HBox1.addStretch(1)
# -------
self.lneBigArea1 = QLineEdit()
self.lneBigArea1.setMinimumHeight(121)
self.lneBigArea1.setMaximumHeight(121)
self.lneBigArea1.setReadOnly(False)
# -------
HBox2 = QHBoxLayout()
HBox2.addWidget(self.lneBigArea1)
# -------
self.btnOne = BasicButton('Очистить поля', 181)
self.btnOne.clicked.connect(self.Shift)
# -------
self.btnTwo = BasicButton('Выполнить', 171)
self.btnTwo.clicked.connect(self.DoNothing)
# -------
HBox3 = QHBoxLayout()
HBox3.addWidget(self.btnOne)
HBox3.addSpacing(40)
HBox3.addWidget(self.btnTwo)
HBox3.addStretch(1)
# -------
lblHeadr2 = HeaderLabel('Результат преобразования')
# -------
HBox4 = QHBoxLayout()
HBox4.addStretch(1)
HBox4.addWidget(lblHeadr2)
HBox4.addStretch(1)
# -------
self.lneBigArea2 = QLineEdit()
self.lneBigArea2.setMinimumHeight(131)
self.lneBigArea2.setMaximumHeight(131)
self.lneBigArea2.setStyleSheet("background:transparent;")
self.lneBigArea2.setReadOnly(True)
# -------
HBox5 = QHBoxLayout()
HBox5.addWidget(self.lneBigArea2)
# -------
self.btnTre = BasicButton('Закрыть программу', 241)
self.btnTre.clicked.connect(self.CloseApp)
# -------
HBox6 = QHBoxLayout()
HBox6.addStretch(1)
HBox6.addWidget(self.btnTre)
# -------
VBox = QVBoxLayout()
VBox.addLayout(HBox1)
VBox.addLayout(HBox2)
VBox.addSpacing(20)
VBox.addLayout(HBox3)
VBox.addSpacing(20)
VBox.addLayout(HBox4)
VBox.addSpacing(20)
VBox.addLayout(HBox5)
VBox.addLayout(HBox6)
VBox.addStretch(1)
# -------
self.setLayout(VBox)
@pyqtSlot()
def Shift(self):
intab = 'абвгдежзийклмнопрстуфхцчшщъыьэюя АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
outtab = 'яюэьыъщшчцхфутсрпонмлкйизжедгвба5ЯЭЮЬЫЪЩШЧЦХФУТСРПОНМЛКЙИЗЖЕДГВБА'
# I have no idea what this is doing other than it takes something from the
# first box and puts it in the second box
trans = self.lneBigArea1.text()
self.lneBigArea2.setText(trans.translate(str.maketrans(intab, outtab)))
# Так как программа закрывается сразу же после ее запуска, то пришлось оставить строчку для ввода
# input(" Нажмите для выхода ... ")
@pyqtSlot()
def DoNothing(self):
self.Parent.SetStatus('Sorry I do not do anything')
@pyqtSlot()
def CloseApp(self):
self.Parent.CloseApp()
class MainDisply(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
Top=300; Left=500; Width=618; Hight=538
self.setGeometry(Left, Top, Width, Hight)
self.setWindowTitle('Атбаш')
self.CenterPane = CenterPanel(self)
self.setCentralWidget(self.CenterPane)
self.StatusMsg = self.statusBar()
def SetStatus(self, Text):
self.StatusMsg.showMessage(Text)
def CloseApp(self):
self.close()
if __name__ == "__main__":
MainEventHandler = QApplication([])
# Следующий код отвечает за открытие интерфейса
MainApplication = MainDisply()
MainApplication.show()
# Выход из приложения
MainEventHandler.exec()