Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / file_model_filters.py
Created November 8, 2016 10:07
Using proxy model to apply custom file extension filtering to a QFileSystemModel
"""
Example of using a proxy model to apply custom
filtering to a QFileSystemModel
RE: https://groups.google.com/d/topic/python_inside_maya/a2QM_KvgfeI/discussion
Justin Israel
justinisrael@gmail.com
"""
from PySide import QtCore, QtGui
@justinfx
justinfx / repeat.py
Created May 25, 2015 10:40
Example of a repeatable command decorate, for Maya (maya.cmds)
"""
Original example reformatted from:
http://blog.3dkris.com/2011/08/python-in-maya-how-to-make-commands.html
python_inside_maya discussion:
https://groups.google.com/d/topic/python_inside_maya/xfuCYBO6aLg/discussion
"""
import maya.cmds as cmds
@justinfx
justinfx / cache_generics.py
Created July 12, 2012 02:17
forwards generic relations
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
'''
def cache_generics(queryset):
// Preferences.sublime-settings
{
// ...
"auto_complete_triggers": [{"selector": "source.python", "characters": "."}],
"auto_complete_selector": "-"
}
@justinfx
justinfx / cix_to_py.py
Created June 1, 2014 05:39
A small script to convert a .cix (codeintel schema) file into a python stub module, for use in auto-completion
#!/usr/bin/env python
'''
A small script to convert a .cix (codeintel schema) file into
a python stub module, for use in auto-completion.
https://community.activestate.com/faq/codeintel-cix-schema
Requires jinja2 for the output template format
'''
@justinfx
justinfx / shells.py
Created September 17, 2012 17:06
function for returning the selectable shells of a poly
def getShellFaces(poly, asString=False):
shells = set()
faces = set()
total = cmds.polyEvaluate(poly, s=True)
for f in xrange(cmds.polyEvaluate(poly, f=True)):
if len(shells) >= total:
break
if f in faces:
@justinfx
justinfx / maya_qt_error_decorator.py
Created January 12, 2017 20:57
A decorator to wrap Qt slots, in Maya, so that exceptions are reported to Script Editor
"""
A decorator to wrap Qt slots, in Maya, so that exceptions are reported to Script Editor
Ref: https://groups.google.com/d/topic/python_inside_maya/xv7DCiocDZA/discussion
justinisrael@gmail.com
"""
#...
import sys
@justinfx
justinfx / tree_widget_drag.py
Created February 20, 2020 04:45
Capturing the start and end item/index information in a PySide2 QTreeWidget internal drag and drop
"""
https://groups.google.com/d/msg/python_inside_maya/1EzNG_i9Xes/Au-18UaXAwAJ
Capturing the start and end item/index information in a
PySide2 QTreeWidget internal drag and drop
"""
from __future__ import print_function
from PySide2 import QtCore, QtGui, QtWidgets
@justinfx
justinfx / py3_asyncore_server.py
Created October 24, 2017 11:15
python3 asyncore + threading socket server
import asyncore
import socket
import threading
class ChatServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
@justinfx
justinfx / read_qt_process.py
Last active July 11, 2019 11:02
2 different examples of reading the progressive output of a process in PyQt. 1) Using a QProcess 2) Using subprocess [https://groups.google.com/d/msg/python_inside_maya/x9COZGNPGEU/gD4xpbs3S08J]
from functools import partial
from subprocess import Popen, PIPE
from PyQt4 import QtCore, QtGui
## testProgram.sh
"""
#!/bin/bash