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_()
当我在下面输入文本时,点击下面的文本输入。我需要修改上面代码中的button_click(self)函数,以便它将lineedit中的文本作为以下python文件的输入。在
^{pr2}$
考虑到你的pyqt代码是正确的
在所需文件.py进口和进口所需文件.py并将shost变量传递给该文件。在
这是你的所需文件.py在
^{pr2}$所以在这里你得到了所需文件.py,对shost做任何你想做的事
相关问题 更多 >
编程相关推荐