Helper functions for updating the Python Qt5 repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python | |
import pyblish.api | |
pyblish.api.register_plugin_path(r"C:\plugins") | |
import pyblish.main | |
pyblish.main.publish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
class Point(object): | |
def __init__(self, point=[0.0, 0.0, 0.0]): | |
self.x, self.y, self.z = point | |
def __str__(self): | |
return '(%0.4f, %0.4f, %0.4f)' % (self.x, self.y, self.z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5 import QtWidgets | |
from PyQt5 import QtCore | |
class Handler(QtCore.QObject): | |
def eventFilter(self, obj, event): | |
if event.type() == QtCore.QEvent.MouseButtonPress: | |
print "Clicked: %s" % obj.text() | |
return super(Handler, self).eventFilter(obj, event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import inspect | |
class MyStdout: | |
def write(self, text): | |
# Gather information about the program | |
# at it's location during printing. | |
frame = inspect.currentframe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This gist registers a custom context property to call upon arbitrary | |
* Javascript functions from Python. Note that this particular example | |
* does NOT work. | |
* | |
* See here for an alternative (that DOES work) | |
* https://gist.github.com/mottosso/2b6ae87454fb911414b0 | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This gist registers a custom QObject from Python into QML. | |
* The QObject is called from QML, whereby Python performs an | |
* expensive operation which, upon completion, emits a signal | |
* which is then again handled from QML. | |
* | |
* See here for an alternative (that doesn't work) | |
* https://gist.github.com/mottosso/aee134d71864bc8425e0 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This gist registers a custom context property to call upon arbitrary | |
* Javascript functions from Python. | |
* | |
* As opposed to example #1, this wraps the callback in a QJSValue | |
* prior to storing it. Without it, Python would crash. Why? | |
* | |
* Example #1: https://gist.github.com/mottosso/aee134d71864bc8425e0 | |
* Example #3: https://gist.github.com/mottosso/2b6ae87454fb911414b0 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// Build System for Sublime Text 3 to compile C using Clang. | |
// | |
// Usage: | |
// Compile and run via CTRL-b or F7 | |
// Compile with CTRL-SHIFT-b | |
// | |
// Pre-requisities: | |
// - A Unix-like OS (for bash) | |
// - clang must be available on your PATH | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Observer pattern in C | |
#include <stdio.h> | |
// To pass and store functions, we need to define a function pointer | |
typedef void (*Signal)(); | |
// We can the use this Signal as type for the contents of the `subscribers` array. | |
// We also keep track of how many subscribers there are currently, so as to | |
// not overwrite previously added signals. |