Skip to content

Instantly share code, notes, and snippets.

@estan
estan / possible_fix.diff
Last active November 4, 2015 15:43
Application won't quit on last window closed with qtreactor
diff --git a/qtreactor/qt4base.py b/qtreactor/qt4base.py
index 076599e..88af08c 100644
--- a/qtreactor/qt4base.py
+++ b/qtreactor/qt4base.py
@@ -273,7 +273,8 @@ class QtReactor(posixbase.PosixReactorBase):
else:
self._blockApp = QtCore.QEventLoop()
self.runReturn()
- self._blockApp.exec_()
+ #self._blockApp.exec_()
@estan
estan / out.html
Last active November 7, 2015 10:30
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ELECTION/MUNICIPALITY/CONSTITUENCY_MUNICIPALITY/ELECTORAL">
<p><xsl:value-of select="@NAME"/></p>
</xsl:template>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/ELECTION/MUNICIPALITY/CONSTITUENCY_MUNICIPALITY/ELECTORAL">
<p><xsl:value-of select="@NAME"/></p>
</xsl:template>
<!-- Suppress unmatched input -->
<xsl:template match="text()"/>
</xsl:stylesheet>
@estan
estan / test.py
Last active February 11, 2016 20:49
Fixed experimentation with custom delegate + editor
from functools import partial
from sys import argv, exit
from PyQt5.QtCore import (Qt, QAbstractTableModel, QModelIndex, pyqtProperty,
pyqtSignal, QVariant)
from PyQt5.QtWidgets import (QApplication, QFrame, QStyledItemDelegate, QTableView,
QFormLayout, QSlider)
class MyAbstractItem(object):
from functools import partial
from PyQt5.QtCore import pyqtProperty, Qt, QVariant
from PyQt5.QtWidgets import QFormLayout, QSlider, QStyledItemDelegate, QFrame
class MineralLevelsEditor(QFrame):
def __init__(self, parent=None):
super(MineralLevelsEditor, self).__init__(parent)
@estan
estan / rock_type.py
Last active February 18, 2016 10:27
Custom delegate with completions from file
from PyQt5.QtCore import QFile, QIODevice, Qt
from PyQt5.QtWidgets import QStyledItemDelegate, QComboBox
# noinspection PyUnresolvedReferences
from orexplore.gui.ui import rock_types_rc # noqa
class RockTypeDelegate(QStyledItemDelegate):
def __init__(self, parent=None):
transitions: [
Transition {
RotationAnimation {
// Animate all rotation changes.
duration: 1000
easing.type: Easing.InOutQuad
direction: {
// Take the shortest direction.
if (from < to)
if (Math.abs(from - to) < 180)
from time import sleep
import zmq
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:9001")
while True:
socket.send_json(('vidar', {'foo': 'bar'}))
def save(self, destination=None):
"""Save the project to a destination.
Args:
destination (Archive or str): An archive open for writing or an archive
file name.
"""
if isinstance(destination, Archive):
destination.saveFile('project.json', dumps({
'name': self.name