from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QRegularExpression
class Ui_MainWindow(QtWidgets.QMainWindow):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1920, 1000)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(10, 40, 131, 20))
self.lineEdit.setStyleSheet(" QLineEdit {\n"
"\n"
" border-radius: 10px;\n"
" padding: 0 8px;\n"
"\n"
" selection-background-color: darkgray;\n"
" }\n"
" QLineEdit[echoMode=\"2\"] {\n"
" lineedit-password-character: 9679;\n"
" }")
self.lineEdit.setInputMask("")
self.lineEdit.setText("")
self.lineEdit.setPlaceholderText("поиск...")
self.lineEdit.textChanged.connect(self.search)
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(10, 100, 131, 20))
self.lineEdit_2.setStyleSheet(" QLineEdit {\n"
"\n"
" border-radius: 10px;\n"
" padding: 0 8px;\n"
"\n"
" selection-background-color: darkgray;\n"
" }\n"
" QLineEdit[echoMode=\"2\"] {\n"
" lineedit-password-character: 9679;\n"
" }")
self.lineEdit_2.setInputMask("")
self.lineEdit_2.setText("")
self.lineEdit_2.setPlaceholderText("поиск...")
self.lineEdit_2.textChanged.connect(self.search)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 310, 84, 23))
self.pushButton.setStyleSheet("QPushButton {\n"
" font: 14pt \"Segoe UI\";\n"
"\n"
" border-radius: 6px;\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #f6f7fa, stop: 1 #dadbde);\n"
" min-width: 80px;\n"
" }\n"
"\n"
" QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
" }\n"
"\n"
" QPushButton:flat {\n"
" border: none; /* для плоской кнопки границы нет */\n"
" }\n"
"\n"
" QPushButton:default {\n"
" border-color: navy; /* делаем кнопку по умолчанию выпуклой */\n"
" }\n"
" QPushButton:open { /* когда собственное меню кнопки раскрыто */\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #dadbde, stop: 1 #f6f7fa);\n"
" }\n"
"\n"
" QPushButton::menu-indicator {\n"
" image: url(menu_indicator.png);\n"
" subcontrol-origin: padding;\n"
" subcontrol-position: bottom right;\n"
" }\n"
"\n"
" QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open {\n"
" position: relative;\n"
" top: 2px; left: 2px; /* сдвигаем стрелку на 2 px */\n"
" }")
self.pushButton.setObjectName("pushButton")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(200, 0, 1720, 1000))
Row = 10000
Col = 7
self.tableWidget.setRowCount(Row)
self.tableWidget.setColumnCount(Col)
self.tableWidget.setObjectName("tableWidget")
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(6, item)
self.tableWidget.horizontalHeader().setDefaultSectionSize(237)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1920, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
for c in range(0, Col):
for r in range(0, Row):
s = self.lineEdit.setText("")
i = QtWidgets.QTableWidgetItem(s )
self.tableWidget.setItem(c, r, i)
def search(self, s):
items = self.tableWidget.findItems(s, QtCore.Qt.MatchContains)
if items:
self.tableWidget.setCurrentItem(items[0])
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Старт"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Регион"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Адрес"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Предприятие"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Ассортимент"))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Количество"))
item = self.tableWidget.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "Результат"))
item = self.tableWidget.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "Примечание"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())