code: def adjustSize(self):
          
          widget = self.centralWidget()
          if widget is None:
              super(XPopupWidget, self).adjustSize()
              return
          
          widget.adjustSize()
          hint = widget.minimumSizeHint()
          size = widget.minimumSize()
          
          width  = max(size.width(),  hint.width())
          height = max(size.height(), hint.height())
          
          width += 20
          height += 20
          
          if self._buttonBoxVisible:
              height += self.buttonBox().height() + 10
              
          if self._titleBarVisible:
              height += max(self._dialogButton.height(),
                            self._closeButton.height()) + 10
          
          curr_w = self.width()
          curr_h = self.height()
          
          # determine if we need to move based on our anchor
          anchor = self.anchor()
          if anchor & (self.Anchor.LeftBottom | self.Anchor.RightBottom | \
                         self.Anchor.BottomLeft | self.Anchor.BottomCenter | \
                         self.Anchor.BottomRight):
              delta_y = height - curr_h
          
          elif anchor & (self.Anchor.LeftCenter | self.Anchor.RightCenter):
              delta_y = (height - curr_h) / 2
          
          else:
              delta_y = 0
          
          if anchor & (self.Anchor.RightTop | self.Anchor.RightCenter | \
                         self.Anchor.RightTop | self.Anchor.TopRight):
              delta_x = width - curr_w
          
          elif anchor & (self.Anchor.TopCenter | self.Anchor.BottomCenter):
              delta_x = (width - curr_w) / 2
          
          else:
              delta_x = 0
          
          self.setMinimumSize(width, height)
          self.resize(width, height)
          
          pos = self.pos()
          pos.setX(pos.x() - delta_x)
          pos.setY(pos.y() - delta_y)
          
          self.move(pos)
docs: Adjusts the size of this popup to best fit the new widget size.