from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * import sys # Creating the main window class App(QMainWindow): def __init__(self): super().__init__() self.title = 'PyQt5 - QTabWidget' self.left = 400 self.top = 400 self.width = 400 self.height = 400 self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) self.tab_widget = Program(self) self.setCentralWidget(self.tab_widget) self.show() class Program(QTabWidget): def __init__(self, parent=None): super(Program, self).__init__(parent) self.left = 300 self.top = 300 self.width = 300 self.height = 300 self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.addTab(self.tab1, "Araba Kredisi") self.addTab(self.tab2, "Tab 2") self.addTab(self.tab3, "Tab 3") self.tab1UI() self.setWindowTitle("Hesaplama") self.setTabShape(QTabWidget.Triangular) self.setMovable(True) self.setTabIcon(0,QIcon('download.png')) def tab1UI(self): form = QFormLayout() self.lineedit = QLineEdit() self.lineedit.setPlaceholderText("Almak istediğiniz Arabanın Fiyatını Giriniz") self.lineedit.setEnabled(True) form.addRow(self.lineedit) self.tableWidget = QTableWidget() self.tableWidget.setRowCount(8) self.tableWidget.setColumnCount(4) self.tableWidget.setItem(0, 0, QTableWidgetItem("Name")) self.tableWidget.setItem(0, 1, QTableWidgetItem("City")) self.tableWidget.setItem(1, 0, QTableWidgetItem("Aloysius")) self.tableWidget.setItem(1, 1, QTableWidgetItem("Indore")) self.tableWidget.setItem(2, 0, QTableWidgetItem("Alan")) self.tableWidget.setItem(2, 1, QTableWidgetItem("Bhopal")) self.tableWidget.setItem(3, 0, QTableWidgetItem("Arnavi")) self.tableWidget.setItem(3, 1, QTableWidgetItem("Mandsaur")) self.tableWidget.horizontalHeader().setStretchLastSection(True) self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) form.addRow(self.tableWidget) self.tab1.setLayout(form) if __name__ == '__main__': app = QApplication(sys.argv) ex = App() sys.exit(app.exec_())