You can download this code by clicking the button below.
This code is now available for download.
Create a simple Qt window with a button.
Technology Stack : PyQt5
Code Type : Function
Code Difficulty : Intermediate
import random
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
def create_random_widget():
app = QApplication([])
widget = QWidget()
layout = QVBoxLayout()
button = QPushButton("Click Me")
layout.addWidget(button)
widget.setLayout(layout)
widget.show()
return widget