Skip to content

Instantly share code, notes, and snippets.

@CEZERT
Last active December 28, 2022 23:33
Show Gist options
  • Save CEZERT/fc986238b699e9cdfac5f9dd38697b5b to your computer and use it in GitHub Desktop.
Save CEZERT/fc986238b699e9cdfac5f9dd38697b5b to your computer and use it in GitHub Desktop.
import sys
from PyQt5.QtWidgets import QApplication, QCheckBox, QTabWidget, QVBoxLayout, QWidget
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('QTabWidget exemple')
self.resize(400, 150)
# Create top level layout
layout = QVBoxLayout()
self.setLayout(layout)
# Create tab wih two tabs
tabs = QTabWidget()
tabs.addTab(self.generalTabUI(), 'General')
tabs.addTab(self.networkTabUI(), 'Network')
layout.addWidget(tabs)
def generalTabUI(self):
"""Crate general page UI"""
generalTab = QWidget()
layout = QVBoxLayout()
layout.addWidget(QCheckBox('General option 1'))
layout.addWidget(QCheckBox('General option 2'))
generalTab.setLayout(layout)
return generalTab
def networkTabUI(self):
"""Crate network page UI"""
networkTab = QWidget()
layout = QVBoxLayout()
layout.addWidget(QCheckBox('Network option 1'))
layout.addWidget(QCheckBox('Network option 2'))
networkTab.setLayout(layout)
return networkTab
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment