def initUI(self): in_class = "menu" self.sidebar = sidebar.Sidebar(self) self.sidebar.window.connect(self.getvalue) self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar) header = AppName(in_class) footer = Footer() add_and_search = AddSearchFrame(in_class) add_and_search.add_button.clicked.connect(lambda: self.add_menu(in_class)) add_and_search.search_button.clicked.connect( lambda: self.search_menu(add_and_search.search_box)) self.table = QTableWidget() self.table.setColumnCount(5) # self.table.setStyleSheet("border: none") # self.table.setStyleSheet( # "background-color: rgb(255, 255, 255);\n" # 'font: 10pt "MS Shell Dlg 2";\n' # "color: rgb(30, 45, 66);" # ) # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID")) self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Food")) self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Category")) self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Price")) # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Bonus")) # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Joining Date")) # self.table.setHorizontalHeaderItem(6, QTableWidgetItem("Total Salary")) self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Edit")) self.table.setHorizontalHeaderItem(4, QTableWidgetItem("Delete")) data = self.load_menu_data() print(data) for x in data: print(x) self.populate_table(data) self.table.resizeColumnsToContents() layout = QVBoxLayout() layout.addWidget(header) layout.addWidget(add_and_search) layout.addWidget(self.table) # layout.addStretch() layout.addWidget(footer) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) centralWidget = QWidget() centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.setContentsMargins(0, 0, 0, 0) # self.resize(800, 600) self.setWindowTitle("Employee") self.resize(1160, 605) self.show() self.center()
def initUI(self): in_class = "tables" self.sidebar = sidebar.Sidebar(self) self.sidebar.window.connect(self.getvalue) self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar) header = AppName(in_class) footer = Footer() add_and_search = AddSearchFrame(in_class) add_and_search.add_button.clicked.connect( lambda: self.add_tables(in_class)) add_and_search.search_button.clicked.connect( lambda: self.search_tables(add_and_search.search_box)) self.table = QTableWidget() self.table.setColumnCount(4) # self.table.setStyleSheet("border: none") # self.table.setStyleSheet( # "background-color: rgb(255, 255, 255);\n" # 'font: 10pt "MS Shell Dlg 2";\n' # "color: rgb(30, 45, 66);" # ) # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID")) self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Table Name")) self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Covers")) self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Edit")) self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Delete")) # self.table.insertRow(self.table.rowCount()) # # self.table.setItem(self.table.rowCount() - 1, 0, QTableWidgetItem("ID1")) # self.table.setItem(self.table.rowCount() - 1, 1, QTableWidgetItem("Name1")) # self.table.setItem(self.table.rowCount() - 1, 2, QTableWidgetItem("Job1")) # self.table.setItem(self.table.rowCount() - 1, 3, QTableWidgetItem("Joining Date1")) # self.table.setItem(self.table.rowCount() - 1, 4, QTableWidgetItem("Salary1")) # self.table.setItem(self.table.rowCount() - 1, 5, QTableWidgetItem("Bonus1")) # self.table.setItem(self.table.rowCount() - 1, 6, QTableWidgetItem("Total Salary1")) # self.table.setItem(self.table.rowCount() - 1, 7, QTableWidgetItem("Edit1")) # self.table.setItem(self.table.rowCount() - 1, 8, QTableWidgetItem("Delete1")) data = self.load_tables_data() print(data) for x in data: print(x) self.populate_table(data) layout = QVBoxLayout() layout.addWidget(header) layout.addWidget(add_and_search) layout.addWidget(self.table) # layout.addStretch() layout.addWidget(footer) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) centralWidget = QWidget() centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.setContentsMargins(0, 0, 0, 0) # self.resize(800, 600) self.setWindowTitle("Login") self.resize(1160, 605) self.show() self.center()