@LehaBezuglov

Как сохранить текст из LineEdit в другой файл?

Мне нужно перенести тот текст что был введён в LineEdit(их 2) в переменные в файл dan.py
design.py
# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'design.ui'
##
## Created by: Qt User Interface Compiler version 6.3.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QGridLayout, QLabel, QLineEdit,
    QMainWindow, QPushButton, QSizePolicy, QWidget)
import files_rcm

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(449, 246)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setStyleSheet(u"QMainWindow {\n"
"	background-color:rgb(85, 0, 127)\n"
"}")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName(u"gridLayout")
        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        font = QFont()
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setStyleSheet(u"QLabel {\n"
"	color:rgb(85, 255, 255);\n"
"}")

        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)

        self.label_3 = QLabel(self.centralwidget)
        self.label_3.setObjectName(u"label_3")
        sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy)
        font1 = QFont()
        font1.setPointSize(8)
        self.label_3.setFont(font1)
        self.label_3.setStyleSheet(u"QLabel {\n"
"	color:rgb(85, 255, 255);\n"
"}")

        self.gridLayout.addWidget(self.label_3, 2, 0, 1, 2)

        self.lineEdit_2 = QLineEdit(self.centralwidget)
        self.lineEdit_2.setObjectName(u"lineEdit_2")
        sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy1)
        self.lineEdit_2.setStyleSheet(u"")

        self.gridLayout.addWidget(self.lineEdit_2, 4, 0, 1, 2)

        self.label_2 = QLabel(self.centralwidget)
        self.label_2.setObjectName(u"label_2")
        sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(sizePolicy)
        font2 = QFont()
        font2.setPointSize(11)
        self.label_2.setFont(font2)
        self.label_2.setPixmap(QPixmap(u":/icons/icons/download.ico"))

        self.gridLayout.addWidget(self.label_2, 0, 1, 1, 1)

        self.lineEdit = QLineEdit(self.centralwidget)
        self.lineEdit.setObjectName(u"lineEdit")
        sizePolicy1.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy1)
        self.lineEdit.setStyleSheet(u"")

        self.gridLayout.addWidget(self.lineEdit, 3, 0, 1, 2)

        self.pushButton = QPushButton(self.centralwidget)
        self.pushButton.setObjectName(u"pushButton")

        self.gridLayout.addWidget(self.pushButton, 5, 0, 1, 2)

        self.label_4 = QLabel(self.centralwidget)
        self.label_4.setObjectName(u"label_4")
        sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
        self.label_4.setSizePolicy(sizePolicy2)
        self.label_4.setStyleSheet(u"QLabel {\n"
"	color:rgb(85, 0, 127);\n"
"}")

        self.gridLayout.addWidget(self.label_4, 6, 0, 1, 1)

        self.label_5 = QLabel(self.centralwidget)
        self.label_5.setObjectName(u"label_5")
        sizePolicy2.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth())
        self.label_5.setSizePolicy(sizePolicy2)
        self.label_5.setStyleSheet(u"QLabel {\n"
"	color:rgb(85, 0, 127);\n"
"}")

        self.gridLayout.addWidget(self.label_5, 6, 1, 1, 1)

        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
        self.label.setText(QCoreApplication.translate("MainWindow", u"\u0412\u0430\u0441 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 InstallerCreator by LehaBezuglov", None))
        self.label_3.setText(QCoreApplication.translate("MainWindow", u"\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 zip \u0430\u0440\u0445\u0438\u0432 \u0441 \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438(http)", None))
        self.lineEdit_2.setInputMask("")
        self.lineEdit_2.setText(QCoreApplication.translate("MainWindow", u"\u0421\u0441\u044b\u043b\u043a\u0430", None))
        self.label_2.setText("")
        self.lineEdit.setText(QCoreApplication.translate("MainWindow", u"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435", None))
        self.pushButton.setText(QCoreApplication.translate("MainWindow", u"PushButton", None))
        self.label_4.setText("")
        self.label_5.setText("")
    # retranslateUi

files_rcm
# Resource object code (Python 3)
# Created by: object code
# Created by: The Resource Compiler for Qt version 6.3.0
# WARNING! All changes made in this file will be lost!

from PySide6 import QtCore

qt_resource_data = b"\
\x00\x00\x00\xf9\
\x00\
\x00\x09\x9ex\x9c\xed\x96?\x0e\x820\x14\x87\x7f,\x1a\
'7\xc3\xc8\xe8h\xe4\x00vg\xe2\x06\x8c\xdcB\xd8\
\xb8\x05\x9b\xdc\xc0\xd9\xc4+x\x00\x8f\xc0\xe0H\xac\xef\
AQB\x80T\x8a\x93\xbc\xe6\x83\xd2?_Rx\x05\
\x00\x8b\x8am\x83\x8e\x0e\x92\x15\xb0\x01\xb0%\xa8\x09;\
T\xedeP\xdf\x09\x15uH)\xf9\x94\x11\x05_N\
\x04\xbb2\xe5\xdeO\xe8m\xc3n\xf1C\xbfh\xf9/\
\xbc&\x13\xd8\xf1\x8f~\x8a%qV,\xbe\xf0;D\
\xa4\x08z\xe6X\xa8\xd2\xba\x9e\xc7u\xabgl\xd0\xf0\
9\x9akN:r#1\xbd\x97\xca\x1d\x0e\xe4_h\
\xe8\xf60\xbc\xaf\xb9\xcf\x1b\xe9v\x89\x87\xc6\x1e\xe21\
\xee\x08\xffMs\x8f2\xb7\x11~\x9f8*\xd2\x0eg\
\xda\xe8\xf7\x0d\x9f\x83\xe8\xf0\x8b)\xf2g\xf6\xcf\xfe\xd9\
_\xfe\xea\xdc\x1bn\xae\xdb:s\xa3\xf2\xd3Q\xc5Z\
\xe6\x1f\xaeD\x9cC\xc64\x8e\xca\x93^\x03\x05\x0eo\
\xcav\x0d^w\x22\xdb\x90\
"

qt_resource_name = b"\
\x00\x05\
\x00o\xa6S\
\x00i\
\x00c\x00o\x00n\x00s\
\x00\x0c\
\x08\x1a\x85\xff\
\x00d\
\x00o\x00w\x00n\x00l\x00o\x00a\x00d\x00.\x00i\x00c\x00o\
"

qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x10\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x81.\xc2\x14B\
"

def qInitResources():
    QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

def qCleanupResources():
    QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

qInitResources()


main.py
from calendar import c
from colorsys import yiq_to_rgb
import os
import sys
import urllib.request

from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtGui import QFontDatabase

import design


class Win(QMainWindow):
    def __init__(self):
        super(Win, self).__init__()
        self.ui = design.Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.pushButton.clicked.connect(self.new_name)
        self.ui.lineEdit.textChanged.connect(self.ui.label_4.setText)
        self.ui.lineEdit_2.textChanged.connect(self.ui.label_5.setText)
  • Вопрос задан
  • 36 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы