Answer the question
In order to leave comments, you need to log in
What data should be displayed and how?
I have this file with code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Yulia.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import os
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
if __name__ == "__main__":
from Core3 import *
class Ui_MainWidget(object):
def setupUi(self, MainWidget):
MainWidget.setObjectName("MainWidget")
MainWidget.setEnabled(True)
MainWidget.resize(391, 500)
MainWidget.setMinimumSize(QtCore.QSize(0, 0))
MainWidget.setMaximumSize(QtCore.QSize(10000000, 10000000))
MainWidget.setAutoFillBackground(False)
self.label = QtWidgets.QLabel(MainWidget)
self.label.setGeometry(QtCore.QRect(80, 0, 241, 51))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(36)
font.setBold(False)
font.setWeight(50)
font.setStyleStrategy(QtGui.QFont.PreferDefault)
self.label.setFont(font)
self.label.setTextFormat(QtCore.Qt.AutoText)
self.label.setObjectName("label")
self.Program1 = QtWidgets.QLineEdit(MainWidget)
self.Program1.setGeometry(QtCore.QRect(10, 100, 371, 31))
self.Program1.setText("")
self.Program1.setObjectName("Program1")
self.Program1_2 = QtWidgets.QLineEdit(MainWidget)
self.Program1_2.setGeometry(QtCore.QRect(10, 180, 371, 31))
self.Program1_2.setText("")
self.Program1_2.setObjectName("Program1_2")
self.ProgramN1 = QtWidgets.QLabel(MainWidget)
self.ProgramN1.setGeometry(QtCore.QRect(110, 60, 171, 41))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(19)
font.setBold(False)
font.setWeight(50)
font.setStyleStrategy(QtGui.QFont.PreferDefault)
self.ProgramN1.setFont(font)
self.ProgramN1.setTextFormat(QtCore.Qt.AutoText)
self.ProgramN1.setObjectName("ProgramN1")
self.ProgramN2 = QtWidgets.QLabel(MainWidget)
self.ProgramN2.setGeometry(QtCore.QRect(110, 140, 171, 41))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(19)
font.setBold(False)
font.setWeight(50)
font.setStyleStrategy(QtGui.QFont.PreferDefault)
self.ProgramN2.setFont(font)
self.ProgramN2.setTextFormat(QtCore.Qt.AutoText)
self.ProgramN2.setObjectName("ProgramN2")
self.pushButton = QtWidgets.QPushButton(MainWidget)
self.pushButton.setGeometry(QtCore.QRect(20, 390, 351, 41))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(20)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(MainWidget)
self.pushButton_2.setGeometry(QtCore.QRect(20, 440, 351, 41))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(20)
self.pushButton_2.setFont(font)
self.pushButton_2.setObjectName("pushButton_2")
self.retranslateUi(MainWidget)
QtCore.QMetaObject.connectSlotsByName(MainWidget)
def retranslateUi(self, MainWidget):
_translate = QtCore.QCoreApplication.translate
MainWidget.setWindowTitle(_translate("MainWidget", "Юлька"))
self.label.setText(_translate("MainWidget", "Юлия 0.2.0"))
self.ProgramN1.setText(_translate("MainWidget", "Программа №1"))
self.ProgramN2.setText(_translate("MainWidget", "Программа №2"))
self.pushButton.setText(_translate("MainWidget", "Запустить программу №1"))
self.pushButton_2.setText(_translate("MainWidget", "Запустить программу №2"))
class Window(QtWidgets.QMainWindow, Ui_MainWidget):
def __init__(self):
super(Window, self).__init__()
# self.ui = Ui_MainWidget()
# self.ui.setupUi(self)
self.setupUi(self)
self.pushButton.clicked.connect(lambda: self.StartProgram(1, 1)) # +++ lambda
self.pushButton_2.clicked.connect(lambda: self.StartProgram(2, 1)) # +++ lambda
def StartProgram(self, NumberProgram, NumberAnswer):
if NumberProgram == 1 and NumberAnswer == 1:
speak("Запускаю первую программу")
# text1 = self.Program1.toPlainText() # ---
text1 = self.Program1.text() # +++
print(text1)
elif NumberProgram == 1 and NumberAnswer == 2:
speak(result)
# text1 = self.Program1.toPlainText() # ---
text1 = self.Program1.text() # +++
print(text1)
elif NumberProgram == 2 and NumberAnswer == 1:
speak("Запускаю вторую программу")
# text1 = self.Program1_2.toPlainText() # ---
text1 = self.Program1_2.text() # +++
print(text1)
elif NumberProgram == 2 and NumberAnswer == 2:
speak(result)
# text1 = self.Program1_2.toPlainText() # ---
text1 = self.Program1_2.text() # +++
print(text1)
if __name__ == '__main__':
app = QtWidgets.QApplication([])
application = Window()
application.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