Home > Mobile >  For help, call the QMessagebox after the collapse
For help, call the QMessagebox after the collapse

Time:09-23

# - * - coding: utf-8 - * -

# Form implementation generated from reading the UI file 'Qt1. UI'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
The import sys
The from Pyqt5 development import Qt1

The from PyQt5 import QtCore QtGui, QtWidgets
The from PyQt5. QtWidgets import *

The class Ui_MainWindow (object) :
Def setupUi (self, the MainWindow) :
MainWindow. SetObjectName (" MainWindow ")
MainWindow. Resize (800, 600)
Self. Centralwidget=QtWidgets. QWidget (MainWindow)
Self. Centralwidget. SetObjectName (" centralwidget ")
Self. HorizontalLayoutWidget=QtWidgets. QWidget (self centralwidget)
Self. HorizontalLayoutWidget. SetGeometry (QtCore QRect (210, 150, 296, 59))
Self. HorizontalLayoutWidget. SetObjectName (" horizontalLayoutWidget ")
Self. GridLayout=QtWidgets. QGridLayout (self horizontalLayoutWidget)
The self. The gridLayout. SetContentsMargins (0, 0, 0, 0)
The self. The gridLayout. SetObjectName (" gridLayout ")
Self. GridLayout_2=QtWidgets. QGridLayout ()
Self. GridLayout_2. SetObjectName (" gridLayout_2 ")
The self. The label=QtWidgets. QLabel (self horizontalLayoutWidget)
Self. Label. SetObjectName (" label ")
Self. GridLayout_2. AddWidget (self. Label, 0, 0, 1, 1)
Self. Label_2=QtWidgets. QLabel (self horizontalLayoutWidget)
Self. Label_2. SetObjectName (" label_2 ")
Self. GridLayout_2. AddWidget (self. Label_2, 1, 0, 1, 1)
The self. The gridLayout. AddLayout (self gridLayout_2, 0, 0, 1, 1)
Self. VerticalLayout_2=QtWidgets. QVBoxLayout ()
Self. VerticalLayout_2. SetObjectName (" verticalLayout_2 ")
The self. The lineEdit=QtWidgets. QLineEdit (self horizontalLayoutWidget)
The self. The lineEdit. SetObjectName (" lineEdit ")
Self. VerticalLayout_2. AddWidget (self lineEdit)
Self. LineEdit_2=QtWidgets. QLineEdit (self horizontalLayoutWidget)
Self. LineEdit_2. SetEchoMode (QtWidgets. QLineEdit. Password)
Self. LineEdit_2. SetObjectName (" lineEdit_2 ")
Self. VerticalLayout_2. AddWidget (self lineEdit_2)
The self. The gridLayout. AddLayout (self. VerticalLayout_2, 0, 1, 1, 1)
The self. The pushButton=QtWidgets. QPushButton (self. Centralwidget)
The self. The pushButton. SetGeometry (QtCore QRect (240, 250, 93, 28))
The self. The pushButton. SetObjectName (" pushButton ")
Self. PushButton_2=QtWidgets. QPushButton (self centralwidget)
Self. PushButton_2. SetGeometry (QtCore QRect (380, 250, 93, 28))
Self. PushButton_2. SetObjectName (" pushButton_2 ")
The self. The radioButton=QtWidgets. QRadioButton (self centralwidget)
The self. The radioButton. SetGeometry (QtCore QRect (538, 186, 115, 19))
The self. The radioButton. SetObjectName (" radioButton ")
MainWindow. SetCentralWidget (self. Centralwidget)
The self. The menubar=QtWidgets. QMenuBar (MainWindow)
The self. The menubar. SetGeometry (QtCore QRect (0, 0, 800, 26))
The self. The menubar. SetObjectName (" menubar ")
MainWindow. SetMenuBar (self. Menubar)
The self. The statusbar=QtWidgets. QStatusBar (MainWindow)
The self. The statusbar. SetObjectName (" statusbar ")
MainWindow. SetStatusBar (self. The statusbar)

Self. RetranslateUi (MainWindow)
The self. The pushButton. Clicked. Connect (self) for the)
Self. PushButton_2. Clicked. Connect (MainWindow. Close)
The self. The radioButton. Clicked. Connect (self. RadioButton)
QtCore. QMetaObject. ConnectSlotsByName (MainWindow)



Def for the (self) :
Text=self. LineEdit. Text ()
Text2=self. LineEdit_2. Text ()
If the text=='11' and text2=='11' :
QMessageBox. About (self, "title", "login successful")
The else:
QMessageBox. About (self, "title", "login failed")


Def radiobutton (self) :
If the self. The radioButton. IsChecked () :
Self. LineEdit_2. SetEchoMode (QtWidgets. QLineEdit. Normal)
The else:
Self. LineEdit_2. SetEchoMode (QtWidgets. QLineEdit. Password)

Def retranslateUi (self, the MainWindow) :
_translate=QtCore. QCoreApplication. Translate
MainWindow. SetWindowTitle (_translate (" MainWindow ", "login"))
The self. The label. The setText (_translate (" MainWindow ", "User Name:"))
Self. Label_2. SetText (_translate (" MainWindow ", "the User PassWord:"))
The self. The lineEdit. SetPlaceholderText (_translate (" MainWindow ", "please enter the user name"))
Self. LineEdit_2. SetPlaceholderText (_translate (" MainWindow ", "please enter the password"))
The self. The pushButton. SetText (_translate (" MainWindow ", "Login"))
Self. PushButton_2. SetText (_translate (" MainWindow ", "Cancel"))
The self. The radioButton. SetText (_translate (" MainWindow ", "show"))



If __name__=="__main__ ':
# to create QApplication class instances
App=QApplication (sys. Argv)
Create a window #
MainWindow=QMainWindow ()
UI=Qt1. Ui_MainWindow ()
UI. SetupUi (mainWindow)
MainWindow. The show ()
Sys. Exit (app. The exec ())

CodePudding user response:

Look at how to switch to English?
  •  Tags:  
  • Qt
  • Related