Skip to content

Instantly share code, notes, and snippets.

@jason-s
jason-s / tweedle.py
Last active August 29, 2015 14:11
possible circular import problem
from tweedledum import Model, ModelAdapter, Thingy
if __name__ == '__main__':
model = Model()
model.thingy = Thingy(dee_count = 42, dum_count = 24)
import enaml
import enaml.qt.qt_application
app = enaml.qt.qt_application.QtApplication()
@jason-s
jason-s / jit2.py
Last active August 29, 2015 14:12
jit test
import numba
def foo(x):
return 1 < x < 7
def bar(x):
_x_0 = x
_x_1 = 1 < _x_0
if not _x_1:
_x_2 = False
import numba
import numba.types
src = '''
from __future__ import division
import numba.types
def f(x):
j = numba.types.int32(0)
return j+x
from enaml.layout.api import (
hbox, vbox, align, spacer,
)
from enaml.widgets.api import (
MainWindow, PushButton, ImageView, Container
)
import enaml
import os
def openResource(path, mode='r'):
from PySide import QtCore
from enaml.qt.qt_application import QtApplication
class UI(QtCore.QObject):
def __init__(self, **kwargs):
super(UI, self).__init__()
print "got here"
self.app = QtApplication()
print "didn't get here"
import yaml
import jsonschema
raw_schema = r'''
"$schema": "http://json-schema.org/draft-04/schema#"
type: object
properties:
debug: {$ref: "#/definitions/debug"}
required:
import numpy as np
import tables as pt
import subprocess
import random
import re
import os
import zlib
class H5fileContext(object):
def __init__(self, filename, groupname):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jason-s
jason-s / popup_view_mod.enaml
Created January 20, 2015 20:45
enaml popups
import os
os.environ['QT_API'] = 'pyside'
from PySide.QtCore import QTimer, QObject
from atom.api import Atom, Event, Bool
from enaml.core.api import Include
from enaml.widgets.api import (
Window, Container, PopupView, Form, Label, PushButton
)
class Model(Atom):
@jason-s
jason-s / timer_example.enaml
Last active October 15, 2018 08:27
timer example using a view controller
from enaml.widgets.api import Window, Container, PushButton, Timer
class StateMachine(object):
# normally handles some complicated view controller process
# but here we just want to listen for the timer timeout
def __init__(self, view):
self.view = view
self.timer = Timer()
self.timer.interval = 350
self.timer.single_shot = True