Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / pyqt_attrFieldSliderGrp.py
Created March 9, 2012 15:50
Example of how to set up a widget that replicates a Maya attrFieldSliderGrp
class AttrFieldGroup(QtGui.QWidget):
"""
AttrFieldGroup
Resembles a attrFieldSliderGrp widget in the Maya UI.
This is a basic example. You could go further in setting
up a common setRange() to configure both the text input and
the slider together.
"""
import matplotlib.pyplot as plt
from random import randint
from time import time
DATA = [
(i, randint(5,30), randint(5,30), randint(30,35), randint(1,5)) \
for i in xrange(1, 401)
]
def mapValues(group):
#move vertices as rod goes over it
import maya.OpenMaya as om
import maya.cmds as cmds
import math as m
class vertexInfo(object):
def __init__(self):
self.verX = []
self.verY = []
self.verZ = []
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class ListOrderView(QListView):
itemMoved = pyqtSignal(int, int, QStandardItem)
def __init__(self, parent=None):
super(ListOrderView, self).__init__(parent)
@justinfx
justinfx / setup_maya_pyqt.py
Created October 12, 2012 00:00
py2app setup.py script for creating a PyQt4 semi-standalone application. PyQt4 is bundled, while Maya's installation location is referenced for the Python framework
"""
setup.py
py2app setup script for creating a semi-standalone .app
around a Maya API based PyQt4 application.
Only bundled PyQt4 with the app, and references the Maya install
location for the python environment.
Allows for a portable GUI application that does not require
@justinfx
justinfx / blocking.py
Created October 24, 2012 23:46
PyQt UI Development for Maya - Chapter 03 - blocking/non-blocking operations
#!/usr/bin/env python
"""
Copyright (c) 2012, Justin Israel (justinisrael@gmail.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
@justinfx
justinfx / trace_stack.py
Created April 17, 2013 22:00
python snippet for dumping a call stack at any point in code
import inspect
def trace():
frames = (str(f[1:4]) for f in inspect.getouterframes(inspect.currentframe())[1:])
print "\n".join(frames)
print '\n'
@justinfx
justinfx / plow_rebuild.sh
Created June 27, 2013 10:43
A helper shell script to completely rebuild Plow server / client, along with dropping the Postgres plow schema, and building it again. Run with the path to the root of the plow source location as the first argument. Adjust the psql host/port to suit
#!/bin/bash
if [ -z $1 ] || [ ! -d ${1}/server ]; then
echo "plow_rebuild.sh <path to plow source>"
exit 1
fi
realpath1() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
@justinfx
justinfx / child_window_test.py
Last active December 19, 2015 14:39
Showing a test, inside and outside of Maya, of child windows still remaining alive after being closed. Test can toggle the WA_DeleteOnClose attribute on each child widget:
#!/usr/bin/env python
"""
Showing a test, inside and outside of Maya,
of child windows still remaining alive after being closed.
Test can toggle the WA_DeleteOnClose attribute on each child widget:
# Command line (dont delete)
$ ./child_window_test.py
@justinfx
justinfx / weakmethod_callbacks_qt.py
Last active December 20, 2015 19:29
Example of having thread-safe callbacks from threads back to the main event loop, in PySide/PyQt4. Also adds support for weak method references to the callback, so as not to call something when the original object might have been deleted. Merges forked examples from both: http://code.activestate.com/recipes/81253/#c5 and http://code.activestate.…
"""
ActiveState:
http://code.activestate.com/recipes/578634-pyqt-pyside-thread-safe-callbacks-main-loop-integr/
ref and proxy classes are based on:
http://code.activestate.com/recipes/81253/#c5
Modified proxy to support a quiet concept for callbacks that can
simply pass if they were not valid, instead of raising an exception.