UPDATE我创建了一个函数,从logingui
文件中的QLineEdit
中获取文本,它起作用了。我不知道为什么同一个函数从不同的文件导入时不能工作。在
我正在尝试从QLineEdit
获取文本,单击一个按钮,我有两个文件,logingui
和{logingui
的代码
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import login.loginlogic
class LoginForm(QWidget):
def __init__(self):
QWidget.__init__(self, parent=None)
object = login.loginlogic
formLayout = QFormLayout()
# vboxlayout = QVBoxLayout()
serifFont = QFont("Arial", 10)
unamelbl = QLabel("Username")
unamelbl.setFont(serifFont)
pwdlbl = QLabel("Password")
pwdlbl.setFont(serifFont)
self.unamele = QLineEdit()
self.pwdle = QLineEdit()
self.unamele.setPlaceholderText("Username")
self.pwdle.setPlaceholderText("Password")
self.loginButton = QPushButton("Login")
self.loginButton.setStyleSheet("background-color: #99ff99; font-size: 15px;")
self.loginButton.setFont(serifFont)
self.loginButton.clicked.connect(object.handleLogin)
formLayout.addRow(unamelbl)
formLayout.addRow(self.unamele)
formLayout.addRow(pwdlbl)
formLayout.addRow(self.pwdle)
formLayout.addRow(self.loginButton)
formLayout.setSpacing(20)
self.setLayout(formLayout)
self.setStyleSheet("background-color: rgb(255,255,255)")
self.setMinimumSize(420, 320)
self.setMaximumSize(420, 320)
self.setContentsMargins(60, 50, 60, 50)
self.setWindowIcon(QIcon("favicon.ico"))
self.show()
def handlelogin(self):
u = self.unamele.text()
print(u)
if __name__ == '__main__':
app = QApplication(sys.argv)
form = LoginForm()
app.exec_()
这是来自loginlogic
的代码
现在我得到的输出是
your code reached here
*blank line*
我知道这是一个空行,因为当我再次点击按钮时,它只会留下一个空行和到达这里的文本。另外,当我运行logingui
时,我确实会在其中写入一些文本。不留空白。在
目前没有回答
相关问题 更多 >
编程相关推荐