In this example, we create a simple window with a single button labeled "Click Me". We then call the button's adjustSize function to resize it to fit its contents. When we run this code, the button will be resized to fit the text "Click Me". Example 2:python from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QIcon from PyQt5.QtGui import QPixmap app = QApplication([]) window = QWidget() icon = QIcon() icon.addPixmap(QPixmap('my_icon.png')) button = QPushButton('Click Me', window) button.setIcon(icon) button.adjustSize() window.show() app.exec_() ``` In this example, we create a button with an icon. We first create an instance of QIcon and add a QPixmap object to it. We then set the button's icon to the QIcon object we just created, and call the button's adjustSize function. This will resize the button to fit both the text and the icon. This function is part of the PyQt5.QtWidgets package library.