Skip to content

Instantly share code, notes, and snippets.

@nicelifeBS
nicelifeBS / meshSelListener.py
Created February 27, 2016 06:32 — forked from boredstiff/meshSelListener.py
meshSelListener.py
#python
import lx
import lxu.object
import lxu.command
import lxifc
class AwSelListener(lxifc.SelectionListener):
running = False
@nicelifeBS
nicelifeBS / non-blocking_stdout_stream.py
Created April 15, 2016 00:41
Run a subprocess and output stdout in a non-blocking fasion
import subprocess
import threading
def _print_stdout(process):
'''
Print out the stream line by line. If line is empty we know that the process has finished and we exit
'''
while True:
try:
line = process.stdout.readline()
@nicelifeBS
nicelifeBS / sel_renderpass_channels.py
Created July 20, 2016 09:58
Selecting channels of an item in a render pass
import modo
import lx
scene = modo.scene.current()
selected = scene.selected[0]
list = []
rp = scene.renderPassGroups[0]
for ch in rp.groupChannels:
g=ch.item.itemGraph('xfrmCore')
@nicelifeBS
nicelifeBS / channelRead.py
Created July 28, 2016 17:23
modo channel reading API
# @author David Ballesteros
#
# @brief Helper classes to deal with the read and write of Item Channels.
# Based on a ChannelRead class sample code provided by Matt Cox
import lx
class ChannelRead:
def __init__(self, item):
"""
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class TableModel(QtCore.QAbstractTableModel):
"""
A simple 5x4 table model to demonstrate the delegates
@nicelifeBS
nicelifeBS / QItemDelegate.py
Created September 5, 2016 09:53
QItemDelegate and QAbstractListModel
import sip
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class SpinBoxDelegate(QtGui.QItemDelegate):
def createEditor(self, parent, option, index):
editor = QtGui.QSpinBox(parent)
editor.setMinimumHeight(100)
@nicelifeBS
nicelifeBS / teleparam.py
Created February 25, 2017 02:14
Katana: Create a teleparameter
def CreateTeleParam(parentParam, targetParam):
teleParam = parentParam.createChildString(
'%sTeleParam' % targetParam.getName(), '')
teleParam.setExpression('getParam("%s").param.getFullName()'
% targetParam.getFullName())
teleParam.setHintString(repr({'widget': 'teleparam'}))
@nicelifeBS
nicelifeBS / db_upload.py
Created June 25, 2017 10:06
dropbox: upload large files
f = open(file_path)
file_size = os.path.getsize(file_path)
CHUNK_SIZE = 4 * 1024 * 1024
if file_size <= CHUNK_SIZE:
print dbx.files_upload(f, dest_path)
else:
@nicelifeBS
nicelifeBS / README.md
Created December 19, 2017 20:11 — forked from mottosso/README.md
Minimal QML SceneGraph

untitled

Usage

python main.py --amount 100
  • Panning by left-click + drag
  • Scale by rotating the mouse wheel
@nicelifeBS
nicelifeBS / double2single.py
Created March 12, 2018 09:13
Replace double quotes with single quotes in string
import re
def replace(obj):
print(obj.groups())
if obj.group(0) == '\'':
return '"'
if obj.group(0) == '"':
return '\''
if obj.group(0) == '"""':