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 re | |
from PyQt5.QtWidgets import (QApplication, QVBoxLayout, QWidget, QLabel, QTextEdit) | |
''' | |
Inspired by https://xkcd.com/2637/ | |
Based on the Python code of tools/roman.py | |
''' | |
RomanNumbers = 'ivxlcdmIVXLCDM' |
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 | |
from random import randrange, choice | |
from string import ascii_lowercase as letters | |
class HighlightTextEdit(QtWidgets.QTextEdit): | |
_highlightColor = QtGui.QColor('#FFFF00') | |
_highlightUnderline = False | |
highlightPos = -1, -1 | |
def __init__(self, *args, **kwargs): |
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 | |
import sys | |
app = QtWidgets.QApplication(sys.argv) | |
window = QtWidgets.QWidget() | |
mainLayout = QtWidgets.QGridLayout(window) | |
labels = [] | |
for r in range(3): | |
for c in range(4): | |
button = QtWidgets.QPushButton() |
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
try: | |
from PySide2 import QtCore, QtWidgets | |
print(QtCore.__version__) | |
except: | |
from PyQt5 import QtCore, QtWidgets | |
print(QtCore.QT_VERSION_STR) | |
class Model(QtCore.QAbstractTableModel): | |
def __init__(self,): | |
super().__init__() |
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 SimpleDial(QtWidgets.QDial): | |
def paintEvent(self, event): | |
# create a QStyleOption for the dial, and initialize it with the basic properties | |
# that will be used for the configuration of the painter | |
opt = QtWidgets.QStyleOptionSlider() | |
self.initStyleOption(opt) | |
# construct a QRectF that uses the minimum between width and height, |
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
{ | |
"be": { | |
"basic": { | |
"name": "Belgian", | |
"include": ["latin","level3.ralt_switch"], | |
"keys": { | |
"0": { | |
"0": "w", | |
"6": ",", | |
"7": ";", |
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 FakeCursor(QtWidgets.QWidget): | |
def __init__(self): | |
super().__init__() | |
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.ToolTip) | |
self.setFixedSize(16, 16) | |
path = QtGui.QPainterPath() | |
path.moveTo(0, 8) |
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
def getSlices(l, step): | |
# stepCount, rest = divmod(len(l) - 1, step) | |
rest = (len(l) - 1) % step | |
if not rest: | |
return l[::step] | |
stepCount = len(l) // (rest + 1) | |
indexes = [0] | |
maxIndex = len(l) | |
i = 0 | |
# maybe done = step for short/odd lists? |
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
''' | |
Different ways to doSomething(row, column) based on the clicked button | |
''' | |
class GuiBase(QtWidgets.QWidget): | |
def doSomething(self, row, column): | |
print(row, column) | |
''' |
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
#!/usr/bin/env python2.7 | |
import sys | |
import midi | |
def getTempoMap(pattern, maxTick=None): | |
#create a first tempo (default to 120, if there is no tempo event) | |
tempoMap = [[0, .5 / pattern.resolution]] | |
lastTick = 0 | |
for track in pattern: |
NewerOlder