code: def QCapsulate(self, widget, name, blocking = False, nude = False):
          
  
          class QuickWindow(QtWidgets.QMainWindow):
  
              class Signals(QtCore.QObject):
                  close = QtCore.Signal()
                  show  = QtCore.Signal()
  
              def __init__(self, blocking = False, parent = None, nude = False):
                  super().__init__(parent)
                  self.propagate = True # send signals or not
                  self.setStyleSheet(style.main_gui)
                  if (blocking):
                      self.setWindowModality(QtCore.Qt.ApplicationModal)
                  if (nude):
                      # http://doc.qt.io/qt-5/qt.html#WindowType-enum
                      # TODO: create a widget for a proper splashscreen (omitting X11 and centering manually)
                      # self.setWindowFlags(QtCore.Qt.Popup) # Qt 5.9+ : setFlags()
                      # self.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
                      self.setWindowFlags(QtCore.Qt.Dialog)
                  self.signals = self.Signals()
                  
  
              def closeEvent(self, e):
                  if (self.propagate):
                      self.signals.close.emit()
                  e.accept()
                  
              def showEvent(self, e):
                  if (self.propagate):
                      self.signals.show.emit()
                  e.accept()
                  
              def setPropagate(self):
                  self.propagate = True
                  
              def unSetPropagate(self):
                  self.propagate = False
                  
  
          win = QuickWindow(blocking = blocking, nude = nude)
          win.setCentralWidget(widget)
          win.setLayout(QtWidgets.QHBoxLayout())
          win.setWindowTitle(name)
          return win
docs: Helper function that encapsulates QWidget into a QMainWindow