Home > other >  Python for help
Python for help

Time:01-31

Using pyqt5 only made a GUI interface, but can't click on the button to get the signal, that is to say the user input user name and password, click on the confirmation for less than the user's input, here is the source code, please tell great god to


GUI interface code below
 

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

# Form implementation generated from reading the UI file 'untitled. UI'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# the run again. Do not edit this file unless you know what you are doing.


The from PyQt5 import QtCore QtGui, QtWidgets


The class Ui_mainWindow (object) :
Def setupUi (self, the mainWindow) :
MainWindow. SetObjectName (" mainWindow ")
MainWindow. Resize (487, 381)
Self. Centralwidget=QtWidgets. QWidget (mainWindow)
Self. Centralwidget. SetObjectName (" centralwidget ")
The self. The pushButton=QtWidgets. QPushButton (self. Centralwidget)
The self. The pushButton. SetGeometry (QtCore QRect (300, 250, 111, 41))
The self. The pushButton. SetObjectName (" pushButton ")
Self. TextBrowser=QtWidgets. QTextBrowser (self centralwidget)
Self. TextBrowser. SetGeometry (QtCore QRect (10, 30, 221, 301))
Self. TextBrowser. SetObjectName (" textBrowser ")
Self. Label_3=QtWidgets. QLabel (self centralwidget)
Self. Label_3. SetGeometry (QtCore QRect (10, 10, 54, 12))
Self. Label_3. SetObjectName (" label_3 ")
Self. LayoutWidget=QtWidgets. QWidget (self centralwidget)
Self. LayoutWidget. SetGeometry (QtCore QRect (250, 40, 225, 141))
Self. LayoutWidget. SetObjectName (" layoutWidget ")
Self. GridLayout=QtWidgets. QGridLayout (self layoutWidget)
The self. The gridLayout. SetContentsMargins (0, 0, 0, 0)
The self. The gridLayout. SetObjectName (" gridLayout ")
The self. The label=QtWidgets. QLabel (self layoutWidget)
Self. Label. SetObjectName (" label ")
The self. The gridLayout. AddWidget (self. Label, 2, 0, 1, 1)
Self. LineEdit_2=QtWidgets. QLineEdit (self layoutWidget)
Self. LineEdit_2. SetText (" ")
Self. LineEdit_2. SetObjectName (" lineEdit_2 ")
The self. The gridLayout. AddWidget (self lineEdit_2, 4, 1, 1, 1)
Self. Label_2=QtWidgets. QLabel (self layoutWidget)
Self. Label_2. SetObjectName (" label_2 ")
The self. The gridLayout. AddWidget (self label_2, 0, 0, 1, 1)
The self. The lineEdit=QtWidgets. QLineEdit (self layoutWidget)
The self. The lineEdit. SetText (" ")
The self. The lineEdit. SetObjectName (" lineEdit ")
The self. The gridLayout. AddWidget (self. The lineEdit, 1, 1, 1, 1)
Self. Label_2. Raise_ ()
Self. Label. Raise_ ()
Self. LineEdit_2. Raise_ ()
The self. The lineEdit. Raise_ ()
MainWindow. SetCentralWidget (self. Centralwidget)
The self. The menubar=QtWidgets. QMenuBar (mainWindow)
The self. The menubar. SetGeometry (QtCore QRect (0, 0, 487, 23))
The self. The menubar. SetObjectName (" menubar ")
Self. Menugui=QtWidgets. QMenu (self. The menubar)
Self. Menugui. SetObjectName (" menugui ")
The self. The menu=QtWidgets. QMenu (self. The menubar)
Self. Menu. SetObjectName (" menu ")
MainWindow. SetMenuBar (self. Menubar)
The self. The statusbar=QtWidgets. QStatusBar (mainWindow)
The self. The statusbar. SetObjectName (" statusbar ")
MainWindow. SetStatusBar (self. The statusbar)
Self. Actioncaidan=QtWidgets. QAction (mainWindow)
Self. Actioncaidan. SetObjectName (" actioncaidan ")
Self. Menugui. AddAction (self actioncaidan)
The self. The menubar. AddAction (self) menugui) menuAction ())
The self. The menubar. AddAction (self. Menu. MenuAction ())

Self. RetranslateUi (mainWindow)
# the self. The pushButton. Clicked. Connect (self. Button_clickked)
QtCore. QMetaObject. ConnectSlotsByName (mainWindow)
MainWindow. SetTabOrder (self. LineEdit, self lineEdit_2)
MainWindow. SetTabOrder (self. LineEdit_2, self pushButton)
MainWindow. SetTabOrder (self) pushButton, self textBrowser)

Def retranslateUi (self, the mainWindow) :
_translate=QtCore. QCoreApplication. Translate
MainWindow. SetWindowTitle (_translate (" mainWindow ", "the first GUI"))
The self. The pushButton. SetText (_translate (" mainWindow ", "confirm"))
Self. Label_3. SetText (_translate (" mainWindow ", "information bar:"))
The self. The label. The setText (_translate (" mainWindow ", "please enter the password:"))
Self. LineEdit_2. SetPlaceholderText (_translate (" mainWindow ", "password"))
Self. Label_2. SetText (_translate (" mainWindow ", "please enter the user name:"))
The self. The lineEdit. SetPlaceholderText (_translate (" mainWindow ", "user name"))
Self. Menugui. SetTitle (_translate (" mainWindow ", "file"))
The self. The menu. The setTitle (_translate (" mainWindow ", "about"))
Self. Actioncaidan. SetText (_translate (" mainWindow ", "caidan))



After has created a GUI1. Py program, realizes the interface separation, but after the operation, interface while reality is normal, but after the interface input user name and password can't access to

The following is a executable program code
 
The import sys
The from untitled import Ui_mainWindow
The from PyQt5. QtWidgets import QApplication QMainWindow, QFileDialog

The class MainCode (QMainWindow Ui_mainWindow) :

Def __init__ (self) :
QMainWindow. __init__ (self)
Ui_mainWindow. __init__ (self)
Self. SetupUi (self)
# super (). SetupUi (mainWindow)
The self. The pushButton. Clicked. Connect (self. On_save) click on the button # for
# signal channel
nullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related