code: def place_center(window, width=None, height=None):
      
      screenGeometry = QApplication.desktop().screenGeometry()
  
      w, h = window.width(), window.height()
  
      if width is not None or height is not None:
          w = width if width is not None else w
          h = height if height is not None else h
          window.setGeometry(0, 0, w, h)
  
      x = (screenGeometry.width() - w) / 2
      y = (screenGeometry.height() - h) / 2
      window.move(x, y)
docs: Places window in the center of the screen.