code: def __init__(
      self,
      text="Enter object label",
      parent=None,
      labels=None,
      sort_labels=True,
      show_text_field=True,
      completion="startswith",
      fit_to_content=None,
      flags=None,
  ):
      if fit_to_content is None:
          fit_to_content = {"row": False, "column": True}
      self._fit_to_content = fit_to_content
  
      super(KeyDialog, self).__init__(parent)
      self.edit = KeyQLineEdit()
      self.edit.setPlaceholderText(text)
      self.edit.setValidator(labelValidator())
      self.edit.editingFinished.connect(self.postProcess)
      if flags:
          self.edit.textChanged.connect(self.updateFlags)
  
      layout = QtWidgets.QVBoxLayout()
      if show_text_field:
          layout_edit = QtWidgets.QHBoxLayout()
          layout_edit.addWidget(self.edit, 6)
          layout.addLayout(layout_edit)
      # buttons
      self.buttonBox = bb = QtWidgets.QDialogButtonBox(
          QtWidgets.QDialogButtonBox.Ok
          | QtWidgets.QDialogButtonBox.Cancel,
          QtCore.Qt.Horizontal,
          self,
      )
      bb.button(bb.Ok).setIcon(newIcon("done"))
      bb.button(bb.Cancel).setIcon(newIcon("undo"))
      bb.accepted.connect(self.validate)
      bb.rejected.connect(self.reject)
      layout.addWidget(bb)
      # label_list
      self.labelList = QtWidgets.QListWidget()
      if self._fit_to_content["row"]:
          self.labelList.setHorizontalScrollBarPolicy(
              QtCore.Qt.ScrollBarAlwaysOff
          )
      if self._fit_to_content["column"]:
          self.labelList.setVerticalScrollBarPolicy(
              QtCore.Qt.ScrollBarAlwaysOff
          )
      self._sort_labels = sort_labels
      if labels:
          self.labelList.addItems(labels)
      if self._sort_labels:
          self.labelList.sortItems()
      else:
          self.labelList.setDragDropMode(
              QtWidgets.QAbstractItemView.InternalMove
          )
      self.labelList.currentItemChanged.connect(self.labelSelected)
      self.labelList.itemDoubleClicked.connect(self.labelDoubleClicked)
      self.edit.setListWidget(self.labelList)
      layout.addWidget(self.labelList)
      # label_flags
      if flags is None:
          flags = {}
      self._flags = flags
      self.flagsLayout = QtWidgets.QVBoxLayout()
      self.resetFlags()
      layout.addItem(self.flagsLayout)
      self.edit.textChanged.connect(self.updateFlags)
      self.setLayout(layout)
      # completion
      completer = QtWidgets.QCompleter()
      if not QT5 and completion != "startswith":
          completion = "startswith"
      if completion == "startswith":
          completer.setCompletionMode(
              QtWidgets.QCompleter.InlineCompletion
          )
          # Default settings.
          # completer.setFilterMode(QtCore.Qt.MatchStartsWith)
      elif completion == "contains":
          completer.setCompletionMode(
              QtWidgets.QCompleter.PopupCompletion
          )
          completer.setFilterMode(QtCore.Qt.MatchContains)
      else:
          raise ValueError(
              "Unsupported completion: {}".format(completion)
          )
      completer.setModel(self.labelList.model())
      self.edit.setCompleter(completer)
  
imports: import re
  from PyQt5 import QtCore
  from PyQt5 import QtGui
  from PyQt5 import QtWidgets
  from PyQt5.Qt import QT_VERSION_STR
  from libs.utils import newIcon, labelValidator
label_desc: Use image node_id 1 to create a new KeyDialog object from inherited base classes: QtWidgets with example: obj = KeyDialog(text, parent, labels, sort_labels, show_text_field, completion, fit_to_content, flags)