This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from PyQt5 import QtCore, QtGui, QtWidgets | |
class FlowLayout(QtWidgets.QLayout): | |
def __init__(self, parent=None, margin=-1, hspacing=-1, vspacing=-1): | |
super(FlowLayout, self).__init__(parent) | |
self._hspacing = hspacing | |
self._vspacing = vspacing | |
self._items = [] | |
self.setContentsMargins(margin, margin, margin, margin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5 import QtCore, QtWidgets | |
import queue | |
import threading | |
import pyqtgraph as pg | |
import numpy as np | |
class App(QtWidgets.QMainWindow): | |
def __init__(self): | |
super(App, self).__init__() | |
self.initUI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4 import QtCore, QtGui, QtWebKit | |
class Widget(QtGui.QWidget): | |
def __init__(self, parent=None): | |
super(Widget, self).__init__(parent) | |
vlay = QtGui.QVBoxLayout(self) | |
self.le = QtGui.QLineEdit() | |
self.browser = QtWebKit.QWebView() | |
self.le.returnPressed.connect(self._return_pressed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import logging | |
import multiprocessing | |
import threading | |
from PySide2 import QtCore, QtWidgets | |
def long_task(): | |
logging.info('Starting long task') | |
time.sleep(3) # this would be replaced with a real task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5 import QtWidgets | |
class Dialog(QtWidgets.QDialog): | |
def __init__(self, parent=None): | |
super(Dialog, self).__init__(parent=None) | |
self.user_le = QtWidgets.QLineEdit() | |
self.pass_le = QtWidgets.QLineEdit(echoMode=QtWidgets.QLineEdit.Password) | |
buttonBox = QtWidgets.QDialogButtonBox() | |
buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5 import QtCore, QtGui, QtWidgets | |
class PixmapItem(QtWidgets.QGraphicsPixmapItem): | |
def __init__(self, parent=None): | |
super().__init__(parent) | |
self.setAcceptDrops(True) | |
self.setPixmap(QtGui.QPixmap('hold.png')) | |
self.setCursor(QtCore.Qt.OpenHandCursor) | |
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QApplication> | |
#include <QTableView> | |
#include <QDebug> | |
#include <QStandardItemModel> | |
class MyEventReceiver: public QObject{ | |
public: | |
using QObject::QObject; | |
public slots: | |
void onClick(const QModelIndex & index){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtCore import Property, QObject, Signal, QCoreApplication, QTimer | |
class QtProperty(Property): | |
def __init__(self, value, name='', type_=None, notify=None): | |
if type_ and notify: | |
super().__init__(type_, self.getter, self.setter, notify=notify) | |
self.value = value | |
self.name = name | |
def getter(self, inst=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtCore import * | |
class PicButton(QAbstractButton): | |
def __init__(self, pixmap, parent=None): | |
super(PicButton, self).__init__(parent) | |
self.pixmap = pixmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from random import randint | |
from PyQt5 import QtCore, QtGui, QtWidgets, QtChart | |
class Widget(QtWidgets.QMainWindow): | |
def __init__(self, parent=None): | |
super(Widget, self).__init__(parent) |