def show_manu_search(self): # checks database for stock items if self.View5.rowCount() > 1: for i in range(1, self.View5.rowCount()): self.View5.removeRow(1) x_act = mp.show_stock() x = [] if self.conf_text5.text() != '': for i in range(0, len(x_act)): a = list(x_act[i]) if self.conf_text5.text().lower() in a[0].lower(): x.append(a) else: x = mp.show_stock() if len(x) != 0: for i in range(1, len(x) + 1): self.View5.insertRow(i) a = list(x[i - 1]) self.View5.setItem( i, 0, QTableWidgetItem(a[0].replace('_', ' ').upper())) self.View5.setItem(i, 1, QTableWidgetItem(str(a[1]))) self.View5.setItem(i, 2, QTableWidgetItem(str(a[2]))) self.View5.setRowHeight(i, 50) self.lbl5.setText('Viewing Manufacturer Stock Database.') else: self.lbl5.setText('No valid information in database.')
def stack3UI(self): table = mp.show_stock() print('show') print(table) layout = QVBoxLayout() self.srb = QPushButton() self.srb.setText("Get Search Result.") self.View = QTableWidget() self.lbl3 = QLabel() self.lbl_conf_text = QLabel() self.lbl_conf_text.setText("Enter the search keyword:") self.conf_text = QLineEdit() self.View.setColumnCount(3) self.View.setColumnWidth(0, 250) self.View.setColumnWidth(1, 250) self.View.setColumnWidth(2, 200) self.View.insertRow(0) self.View.setItem(0, 0, QTableWidgetItem('Stock Name')) self.View.setItem(0, 1, QTableWidgetItem('Quantity')) self.View.setItem(0, 2, QTableWidgetItem('Cost(Per Unit)')) layout.addWidget(self.View) layout.addWidget(self.lbl_conf_text) layout.addWidget(self.conf_text) layout.addWidget(self.srb) layout.addWidget(self.lbl3) self.srb.clicked.connect(self.show_search) self.stack3.setLayout(layout)