In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "PyQt5 how to achieve user login GUI interface and jump after login", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "PyQt5 how to achieve user login GUI interface and jump after login" bar!
Import all the expansion packs required by the business.
Import sys # system parameter manipulation from PyQt5.QtWidgets import * # module contains a classic desktop style user interface that provides a set of UI elements from PyQt5.QtCore import * # this module is used to process time, files and directories, various data types, streams, URL, MIME types, threads or processes from PyQt5.QtGui import * # classed window system integration, event handling, two-dimensional graphics, basic imaging, fonts and text
Create the main interface window.
Class MainWindow (QMainWindow): def _ init__ (self, * args, * * kwargs):''constructor. Initialization parameter attribute: param args:: param kwargs:' 'super (). _ _ init__ (* args, * * kwargs) self.setWindowTitle (' main function page') self.setFixedWidth (600) self.setFixedHeight
Create a login dialog box.
Class LoginDialog (QDialog): def _ _ init__ (self, * args, * * kwargs):''constructor Initialize the contents of the login dialog box: param args:: param kwargs:''super (). _ _ init__ (* args, * * kwargs) self.setWindowTitle (' Welcome to login') # set title self.resize (200200) # set wide and high self.setFixedSize (self.width () Self.height () self.setWindowFlags (Qt.WindowCloseButtonHint) # set Hidden button to close X''self.frame = QFrame (self) # initialize Frame object self.verticalLayout = QVBoxLayout (self.frame) # set horizontal layout self.verticalLayout self.login_id = QLineEdit () # define user name input box self.login_id.setPlaceholderText ("Please enter login account") # set the prompt self.verticalLayout.addWidget (self.login_id) displayed by default # add the login account setting to the page control self.passwd = QLineEdit () # define password input box self.passwd.setPlaceholderText ("Please enter login password" ) # set the default prompt self.verticalLayout.addWidget (self.passwd) # add the login password setting to the page control self.button_enter = QPushButton () # define the login button self.button_enter.setText ("login") # the button displays the value as login self.verticalLayout.addWidget (self.button_enter) # add the button To page control self.button_quit = QPushButton () # define return button self.button_quit.setText ("return") # button display value is return self.verticalLayout.addWidget (self.button_quit) # add button to page control # bind button event self.button_enter.clicked.connect (self.button_enter_verify) Self.button_quit.clicked.connect (QCoreApplication.instance () .quit) # return button bind to exit def button_enter_verify (self): # verify whether the account is correct if self.login_id.text ()! = "admin": print ("test1") return # verify whether the password is correct If self.passwd.text ()! = "admin@1234": print ("test2") return # verified Set the QDialog object state to allow self.accept ()
Finally, the application is started through the mian entry function.
If _ _ name__ = = "_ main__": # create application window_application = QApplication (sys.argv) # set login window login_ui = LoginDialog () # verify whether the verification has passed if login_ui.exec_ () = QDialog.Accepted: # initialize the main function window main_window = MainWindow () # display window Main_window.show () # setup Application exit sys.exit (window_application.exec_ ()) Thank you for your reading The above is the "PyQt5 how to achieve user login GUI interface and jump after logging" content, after the study of this article, I believe that PyQt5 how to achieve user login GUI interface and jump after the problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.