This file contains hidden or 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
""" | |
Reworked code based on | |
http://trevorius.com/scrapbook/uncategorized/pyqt-custom-abstractitemmodel/ | |
Adapted to Qt5 and fixed column/row bug. | |
TODO: handle changing data. | |
""" | |
import sys |
This file contains hidden or 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.QtWidgets import QSlider | |
class DoubleSlider(QSlider): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.decimals = 5 | |
self._max_int = 10 ** self.decimals | |
super().setMinimum(0) |
This file contains hidden or 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 math | |
import sys | |
import asyncio | |
from functools import partial, wraps | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QGridLayout, QProgressBar, QErrorMessage | |
from PyQt5.QtCore import Qt | |
from quamash import QEventLoop | |
import traceback |
This file contains hidden or 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 threading import Thread, Event, Timer | |
import time | |
def TimerReset(*args, **kwargs): | |
""" Global function for Timer """ | |
return _TimerReset(*args, **kwargs) | |
class _TimerReset(Thread): | |
"""Call a function after a specified number of seconds: |
This file contains hidden or 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 tables import * | |
# Isolated the copying logic | |
def append_column(table, group, name, column): | |
"""Returns a copy of `table` with an empty `column` appended named `name`.""" | |
description = table.description._v_colObjects.copy() | |
description[name] = column | |
copy = Table(group, table.name+"_copy", description) | |
This file contains hidden or 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
NSPoint ConstrainPointInsideRect(CGPoint freePoint, NSRect boundaryRect) | |
{ | |
//NSPoint constrainedViewPoint = DFConstrainPointToRect(viewPoint, boundaryRect); | |
// Make sure the handle cannot be dragged outside of the plot range | |
if (NSPointInRect(freePoint, boundaryRect)) { | |
return freePoint; | |
} | |
NSPoint cp = freePoint; |
This file contains hidden or 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
# http://matforge.org/wd15/blog | |
from __future__ import division | |
from fipy import * | |
# Grid things | |
N = 1000 | |
D = 1 | |
dx = D / N | |
m = Grid1D(nx=N+1, dx=dx) + [[-dx/2.]] | |
I_right = CellVariable(mesh=m, value=1., name='I_right') # Intensity along the positive direction |