Skip to content

Instantly share code, notes, and snippets.

Building Python 3 with PyQt5, QWebEngine, QScintilla, VTK on Windows 64bit
Install Visual C++ 2013 (I failed to get MingW working with PyQt5)
Install the vs2013 version of Qt5
Install Python 3.4 64bit
Get sip (4.17), PyQt5 (5.5.1), and QScintilla sources
Add path to qmake to PATH
@mottosso
mottosso / README.md
Last active September 5, 2016 06:46
Restore Script Editor focus

Problem

image

On Windows systems using Autodesk Maya, the text input field of the Script Editor doesn't regain focus after having restored focus to the main window. This event handler explicitly restores focus, if it turns out to have been the last active panel at the time of leaving the application.

Usage

Place the full contents of the script below into your userSetup.py and never again lose focus.

@ShadowKyogre
ShadowKyogre / batch_keys.sh
Last active April 22, 2017 20:09
Select multiple windows with slop. Needs slop, xwininfo, and xprop. Edit batch_keys.sh if you want to pass different params to the slop wrapper.
#!/bin/bash
happened=1
for window in $(recsel_windows.py -l -c 0,0.5,1,0.6)
do
happened=0
xdotool windowactivate --sync $window key "$1"
done
if [ $happened -a -n "$2" ];then
@manuelmacha
manuelmacha / gist:6cc29ec040734e21a768
Created February 3, 2015 10:05
QTextEdit extended with a signal 'lineNumbersChanged' which gets triggered when the line-numbers of the visible text change. Such functionality already exists for QPlainTextEdit via firstVisibleBlock().blockNumber() and lastVisibleBlock().blockNumber(). However these methods are not accessible using QTextEdit and PyQt. The signal can be used to …
from PyQt4 import QtGui, QtCore
class TextEdit(QtGui.QTextEdit):
'''
QTextEdit extended with a signal 'lineNumbersChanged' which gets triggered when the line-numbers of the visible text change.
Such functionality already exists for QPlainTextEdit via firstVisibleBlock().blockNumber() and lastVisibleBlock().blockNumber()
However these functions are not accessible using QTextEdit and PyQt.
The signal can be used to update custom widgets that compliment the QTextEdit such as lineNumberWidgets or miniMapWidgets.
'''
@KelSolaar
KelSolaar / mayaWidgetEmbeddingIntoPyQtWidget.py
Created November 3, 2011 17:33
Maya Widget Embedding Into PyQt Widget
import maya.OpenMayaUI
import maya.cmds as cmds
import sip
from PyQt4.QtGui import *
from PyQt4.QtCore import *
mainWindow = QMainWindow()
centralWidget = QListView()
mainWindow.setCentralWidget(centralWidget)
dockWidget = QDockWidget("DockWidget", mainWindow)
@eyllanesc
eyllanesc / 47091216.py
Last active November 25, 2020 09:38
47091216
from PyQt5.QtCore import *
from PyQt5.QtGui import QDrag
from PyQt5.QtWidgets import *
class TreeWidget(QTreeWidget):
customMimeType = "application/x-customTreeWidgetdata"
def mimeTypes(self):
mimetypes = QTreeWidget.mimeTypes(self)
@fpsunflower
fpsunflower / nanoexr.cpp
Last active December 9, 2021 14:42
Tiny OpenEXR output
// c++ -o nanoexr nanoexr.cpp && ./nanoexr /tmp/foo.exr
#include <cstdio>
// writes a tiled OpenEXR file from a float RGB buffer
struct Exr {
FILE* f; enum{TS=64}; ~Exr() { fclose(f); }
void B(unsigned char i) { fputc(i,f); }
void I(unsigned int i) { fwrite(&i,1,4,f); }
void L(unsigned long long i) { fwrite(&i,1,8,f); }
void F(float x) { fwrite(&x,1,4,f); }
@dferg
dferg / howto-tomato-install-extras.markdown
Last active December 30, 2021 07:57
HOWTO: Install extra kernel modules on Shibby TomatoUSB

Introduction

This howto describes installing the extra kernel modules for the Tomato open-source router firmware. We will install them in the /opt/extras area.

Requirements

  • Router running Shibby's fork of TomatoUSB
  • entware installed to a USB stick mounted at /opt

This Howto Was Tested With

@vivien
vivien / imgur
Last active January 27, 2022 19:46
Shell script to upload image(s) to imgur.com
#!/bin/sh
#
# Upload image(s) to imgur.com
# Copyright (C) 2014 Vivien Didelot <vivien@didelot.org>
# Licensed under GPL version 3, see http://www.gnu.org/licenses/gpl.txt
#
# Requires "jshon":
# http://kmkeen.com/jshon/
#
# Alternatives, which suck:
@schworer
schworer / undo_dec.py
Created February 22, 2012 17:57
quick and dirty Maya Python undo decorator
from functools import wraps
from maya import cmds
def undo(func):
""" Puts the wrapped `func` into a single Maya Undo action, then
undoes it when the function enters the finally: block """
@wraps(func)
def _undofunc(*args, **kwargs):
try:
# start an undo chunk