用pyqt5 编写一个可实现账号密码登录的界面 5C

用pyqt5 编写一个可实现账号密码登录的界面,点击登录可跳转主界面的程序代码。刚学,弄了好几天都没头绪,求大神帮帮忙。

2个回答

参考这个:https://www.cnblogs.com/ansang/p/7895075.html
至于你要完整的功能,还需要数据库,这个你就要系统学习了。

weixin_42409938
Jane-King 好的,谢谢,还是得慢慢磨
大约 2 年之前 回复

-*- coding: cp936 -*-

from PyQt4.QtGui import *

from PyQt4.QtCore import *

import sys

from PyQt4 import QtGui, QtCore
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))

NUM=0

class main():
def init(self,parent=None):

super(main,self).__init__(parent)

self.num=10
print self.num

def setnum(self,s):
    self.num=s

class MessageBoxDlg(QDialog):

def init(self,parent=None):

super(MessageBoxDlg,self).__init__(parent)

self.setWindowTitle("Login")

self.label=QLabel("Please input your accout and passwd:")
# self.gridLayout0

    #self.hboxlayout1
    self.textField1= QtGui.QLineEdit()
    self.showButton = QLabel( u"Password:" )
    self.hboxlayout1 = QtGui.QHBoxLayout()
    self.hboxlayout1.addWidget( self.showButton )
    self.hboxlayout1.addWidget( self.textField1 )        
    #self.hboxlayout1.addStretch(1)

    #self.hboxlayout4
    self.textField4= QtGui.QLineEdit()
    self.showButton4 = QLabel( u"User:    " )
    self.hboxlayout4 = QtGui.QHBoxLayout()
    self.hboxlayout4.addWidget( self.showButton4 )
    self.hboxlayout4.addWidget( self.textField4 )        
    #self.hboxlayout1.addStretch(1)

    # self.hboxlayout2
    questionButton=QPushButton("OK")  
    informationButton=QPushButton("Cancel")
    self.hboxlayout2 = QtGui.QHBoxLayout() 
    self.hboxlayout2.addWidget( questionButton ) 
    self.hboxlayout2.addWidget( informationButton )
    #self.hboxlayout2.addStretch(1)

    self.vboxlayout3 = QtGui.QVBoxLayout() 
    self.vboxlayout3.setMargin(10)   
    self.vboxlayout3.setSpacing(6)
    self.vboxlayout3.addWidget( self.label )
    self.vboxlayout3.addLayout( self.hboxlayout4 )
    self.vboxlayout3.addLayout( self.hboxlayout1 )
    self.vboxlayout3.addLayout( self.hboxlayout2 )

    self.setLayout( self.vboxlayout3 )

gridLayout=QGridLayout(self)

#gridLayout.addWidget(self.textField1,0,0,1,0)

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

gridLayout.addWidget(questionButton,1,0)

gridLayout.addWidget(informationButton,1,1)

    self.connect(questionButton,SIGNAL("clicked()"),self.slotQuestion)  
    self.connect(informationButton,SIGNAL("clicked()"),self.slotInformation)  


def slotQuestion(self):
    global NUM
    NUM=5
    print NUM
    pass

def slotInformation(self):  
    sys.exit()

app=QApplication(sys.argv)

MessageBox=MessageBoxDlg()

MessageBox.show()

app.exec_()

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问