Created
April 20, 2020 14:39
-
-
Save okay-type/38d270d047abcdadd46072fcff2d28b4 to your computer and use it in GitHub Desktop.
Refireable Tiny Script Window
This file contains hidden or 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
# menuTitle : Tiny Script Window | |
from vanilla import Window | |
from lib.scripting.scriptingWindow import PyTextEditor, OutPutEditor | |
from mojo.events import addObserver, removeObserver | |
class tinyScriptWin(object): | |
def __init__(self): | |
self.w = Window((640, 480), minSize=(200, 200)) | |
self.w.editor = PyTextEditor((0, 0, 0, -200), "print('test')") | |
self.w.output = OutPutEditor((0, -200, -0, -0), readOnly=True) | |
self.w.editor.setOutputView_(self.w.output) | |
self.w.bind("close", self.windowClose) | |
self.w.open() | |
addObserver(self, 'trigger', 'tinyScriptWindow') | |
def windowClose(self, sender): | |
removeObserver(self, 'tinyScriptWindow') | |
def trigger(self, notification): | |
if notification['trigger'] == 'fire': | |
self.w.editor.run() | |
tinyScriptWin() |
This file contains hidden or 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
# menuTitle : Tiny Script Fire | |
# shortCut : command+p | |
from mojo.events import postEvent | |
postEvent('tinyScriptWindow', trigger='fire') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment