12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- # coding:utf8
- '''
- @Project :Scan
- @File :Dialogadd.py
- @Author :Leslie
- @Date :2023/5/8 11:08
- '''
- from PyQt5.QtWidgets import QDialogButtonBox, QDateTimeEdit, QDialog, QComboBox, QTableView, QAbstractItemView, \
- QHeaderView, QTableWidget, QTableWidgetItem, QMessageBox, QListWidget, QListWidgetItem, QStatusBar, QMenuBar, QMenu, \
- QAction, QLineEdit, QStyle, QFormLayout, QVBoxLayout, QWidget, QApplication, QHBoxLayout, QPushButton, QMainWindow, \
- QGridLayout, QLabel
- from PyQt5.QtGui import QIcon, QPixmap, QStandardItem, QStandardItemModel, QCursor, QFont, QBrush, QColor, QPainter, \
- QMouseEvent, QImage, QTransform
- from PyQt5.QtCore import QStringListModel, QAbstractListModel, QModelIndex, QSize, Qt, QObject, pyqtSignal, QTimer, \
- QEvent, QDateTime, QDate
- class Dialogadd(QDialog):
- # 自定义消息
- dialogSignel = pyqtSignal(int, str)
- def __init__(self, parent=None):
- super(Dialogadd, self).__init__(parent)
- layout = QVBoxLayout(self)
- self.label = QLabel(self)
- self.lineEdit = QLineEdit(self)
- self.label.setText("请输入物料类型")
- layout.addWidget(self.label)
- layout.addWidget(self.lineEdit)
- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
- buttons.accepted.connect(self.accept) # 点击ok
- buttons.rejected.connect(self.reject) # 点击cancel
- layout.addWidget(buttons)
- def accept(self): # 点击ok是发送内置信号
- material = self.lineEdit.text()
- if not material:
- return ;
- self.dialogSignel.emit(0, material)
- self.destroy()
- def reject(self): # 点击cancel时,发送自定义信号
- self.destroy()
- if __name__ == '__main__':
- import sys
- app = QApplication(sys.argv)
- Dialog = Dialogadd()
- Dialog.show()
- sys.exit(app.exec_())
|