I am trying to create tabs each time that i press a button that i added to a toolbar. For this i create a windows in Pyqt, and call the class NewTab, which has the QWidget that i want to add in the QTabWidget.
This is my code:
class Window(QMainWindow):
def __init__(self):
self.tabWidget = QTabWidget()
self.tabWidget.setTabsClosable(True)
self.setCentraWidget(self.tabWidget)
self.setLayout(NewTab().newTab.tab_layout)
class NewTab(QWidget):
list_1 = [] #These lists are for another method that i will use later
list_2 = []
def __init__(self):
QWidget.__init__(self)
self.newTab()
def newTab(self):
self.new_tab = QWidget()
Window.tabWidget.addTab(self.new_tab)
plot = MatPlotLibFigure() #This is another class that i add
#in the splitter as a widget
self.splitter = QSplitter(Qt.Vertical)
self.splitter.addWidget(plot)
self.splitter2 = QSplitter(Qt.Horizontal)
self.splitter2.addWidget(self.splitter)
self.tab_layout = QHBoxLayout(Window.tabWidget)
self.tab_layout.addWidget(self.splitter2)
print "New Tab created"
def Close(self):
pass
app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec_())
I do not know what happens. It does not work. What am i doing wrong? Hope you can help me