0
import sys
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QDialog, QApplication, QPushButton, QLineEdit, QFormLayout
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.le = QLineEdit()
self.le.setText("Host")
self.pb = QPushButton()
self.pb.setText("Connect")
layout = QFormLayout()
layout.addWidget(self.le)
layout.addWidget(self.pb)
self.setLayout(layout)
self.connect(self.pb, SIGNAL("clicked()"),self.button_click)
self.setWindowTitle("Learning")
def button_click(self):
# shost is a QString object
shost = self.le.text()
#what should I write here to access the other python file and give shost as input string to that file
app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()
文本該文本作爲輸入到下面給出的其他python文件。我需要修改上面的代碼中的button_click(self)函數,以便它將lineedit中的文本作爲下面的python文件的輸入。如何給一個文件作爲輸入到其他文件的輸出,如何給,當我在lineedit輸入文字,然後點擊連接按鈕也應該給在LineEdit進入PyQt4中到另一個文件中,輸入字符串現在
# Requiredfile.py
Enteredstring = input('Enter string:')
print Enteredstring