Qt PySide2


some layouts
    vertical_layout = QtWidgets.QVBoxLayout()
    horizontal_layout = QtWidgets.QHBoxLayout()
    grid_layout = QtWidgets.QGridLayout()
    
    # Add a box around a layout
    name_box = QtWidgets.QGroupBox('Label')
    name_layout = QtWidgets.QVBoxLayout()
    name_box.setLayout(name_layout)
    
    main_layout.addWidget(name_box)
add widgets or layouts to a layout
    horizontal_layout.addWidget(widget)
    grid_layout.addWidget(widget, 0, 0) # row, column
    
    vertical_layout.addLayout(horizontal_layout)

some widgets
    name_label = QtWidgets.QLabel("label")
    name_checkbox = QtWidgets.QCheckBox("label")
    name_textfield = QtWidgets.QLineEdit("label")
    name_button = QtWidgets.QPushButton("label")
    
    # Option menu
    name_menu = QtWidgets.QComboBox()
    name_menu.insertItems(0, ["a", "b", "c"])
    
    # List view
    name_list = QtWidgets.QListWidget()
    name_list.addItems(["a", "b", "c"])
get and set widget values
    state = name_checkbox.checkState()  # Checked or Unchecked
    name_checkbox.setCheckState(QtCore.Qt.Checked)
    
    text = name_textfield.text()
    name_textfield.setText("text")
    
    item = name_menu.currentText()
    name_menu.setCurrentText("a")
    
    item = name_list.currentItem()
connect a function to a widget
    name_checkbox.stateChanged.connect(self.function)
    name_textfield.returnPressed.connect(self.function)
    name_button.clicked.connect(self.function)
    name_list.itemDoubleClicked.connect(self.definition)
customize widgets
    # Set tool tips
    widget.setToolTip("tool tip")
    
    # Prevent keyboard focus
    widget.setAutoDefault(False)
    
    # Hide/show a widget
    widget.hide()
    widget.show()
    
    # Disable/enable a widget
    widget.setEnabled(False)
    widget.setEnabled(True)
    
    # Delete a widget
    layout.removeWidget(widget)
    widget.setParent(none)