Skip to content

Instantly share code, notes, and snippets.

@Orizzu
Orizzu / QRadioButton.py
Last active August 15, 2021 07:25
QRadioButton PyQt5
# you can copy paste and run this code for test
# By default QRadioButtons can be selected at a time
import sys
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QWidget, QMainWindow, QRadioButton
class Radiodemo(QWidget):
def __init__(self, parent=None):
super(Radiodemo, self).__init__(parent)
layout = QHBoxLayout()
@Orizzu
Orizzu / itemClicked.py
Last active November 25, 2023 18:48
qlistwidget item clicked event pyqt
# you can copy paste and run this code for test
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
class window(QMainWindow):
def __init__(self):
super(window, self).__init__()
listWidget = QListWidget()
listWidget.resize(300,120)
@Orizzu
Orizzu / QThread.py
Last active April 22, 2022 18:43
how to create a QThread in PyQt5
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication, QLabel, QPushButton, QVBoxLayout, QWidget
from PyQt5.QtCore import Qt, QObject, QRunnable, pyqtSlot, QThreadPool, QTimer
import traceback, sys
import datetime
# this may be a long sample but you can copy and pase it for test
# the different parts of code are commented so it can be clear what it does
class WorkerSignals(QObject):