Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import sys
- from PyQt5.QtCore import *
- from PyQt5.QtGui import *
- from PyQt5.QtWidgets import *
- class Window(QWidget):
- def __init__(self):
- super().__init__(self)
- self.shortcut = QShortcut(QKeySequence("Ctrl+W"), self, self.on_close_tab)
- self.tabs = QTabWidget(self)
- self.tabs.resize(600, 300)
- self.show()
- # add few tabs
- for i in range(1, 11):
- e = QTextEdit(self.tabs)
- e.append("Hello World number {} !".format(i))
- self.tabs.addTab(e, "#{}".format(i))
- @pyqtSlot()
- def on_close_tab(self):
- print("DEBUG: tabs count:", self.tabs.count())
- if self.tabs.count():
- print("DEBUG: tabs current index:", self.tabs.currentIndex())
- self.tabs.removeTab(self.tabs.currentIndex())
- app = QApplication(sys.argv)
- win = Window()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement