1- import os , sys , re
1+ import importlib , os , sys , re
2+
23main = __import__ ('__main__' )
34hou = main .__dict__ ['hou' ]
45import hqt
5- reload (hqt )
6+
7+ importlib .reload (hqt )
68from managers .completeWidget import contextCompleterClass
79
810path = os .path .join (os .path .dirname (__file__ ), 'houdini' )
1113for mod in [os .path .splitext (x )[0 ] for x in os .listdir (path )]:
1214 if not mod in ns :
1315 try :
14- exec 'import ' + mod in ns
16+ exec
17+ 'import ' + mod in ns
1518 except :
1619 pass
1720
1821if not path in sys .path :
1922 sys .path .insert (0 , path )
2023
2124from multi_script_editor import scriptEditor
22- reload (scriptEditor )
25+
26+ importlib .reload (scriptEditor )
2327
2428
2529def show (* args , ** kwargs ):
2630 hqt .show (scriptEditor .scriptEditorClass , * args , ** kwargs )
2731
32+
2833def get_widget ():
2934 widget = scriptEditor .scriptEditorClass ()
30- widget .setStyleSheet ('' )
31- widget .setStyleSheet ( hqt .get_h14_style () )
35+ widget .setStyleSheet ('' )
36+ widget .setStyleSheet (hqt .get_h14_style ())
3237 return widget
3338
3439
@@ -43,7 +48,7 @@ def get_widget():
4348# multi_script_editor.showHoudini(ontop=1)
4449
4550# H14
46- #import sys
51+ # import sys
4752# path = 'path/to/MultiScriptEditor_module'
4853# # example c:/houdini/python/lib
4954# if not path in sys.path:
@@ -53,8 +58,6 @@ def get_widget():
5358# multi_script_editor.showHoudini(name='Multi Script Editor',replacePyPanel=1, hideTitleMenu=0)
5459
5560
56-
57-
5861###################### CONTEXT FUNCTIONS
5962
6063# def saveToNode(code, node):
@@ -69,9 +72,11 @@ def getAllDifinitions():
6972 names = list (set (names ))
7073 return names
7174
75+
7276roots = ['obj' , 'shop' , 'ch' , 'vex' , 'img' , 'out' ]
7377nodes = list (set (getAllDifinitions ()))
7478
79+
7580def completer (line , ns ):
7681 # node types
7782 func = ['createNode' , 'createInputNode' , 'createOutputNode' ]
@@ -96,9 +101,10 @@ def completer(line, ns):
96101 return auto , add
97102 return None , None
98103
104+
99105def getChildrenFromPath (path ):
100106 sp = path .rsplit ('/' , 1 )
101- if not sp [0 ]: # rootOnly
107+ if not sp [0 ]: # rootOnly
102108 if sp [1 ]:
103109 nodes = [contextCompleterClass (x , x [len (sp [1 ]):]) for x in roots if x .startswith (sp [1 ])]
104110 return nodes , None
@@ -116,10 +122,12 @@ def getChildrenFromPath(path):
116122 return nodes , channels
117123 return None , None
118124
125+
119126def contextMenu (parent ):
120127 m = houdiniMenuClass (parent )
121128 return m
122129
130+
123131class houdiniMenuClass (hqt .QMenu ):
124132 def __init__ (self , parent ):
125133 super (houdiniMenuClass , self ).__init__ ('Houdini' , parent )
@@ -132,8 +140,6 @@ def __init__(self, parent):
132140 self .addAction (hqt .QAction ('Read from hou.session Sourse' , parent , triggered = self .readFromSession ))
133141 self .addAction (hqt .QAction ('Save to hou.session' , parent , triggered = self .saveToSession ))
134142
135-
136-
137143 def readFromNode (self ):
138144 sel = hou .selectedNodes ()
139145 if sel :
@@ -150,7 +156,7 @@ def readFromNode(self):
150156 text = source .eval ()
151157 elif isinstance (source , hou .HDASection ):
152158 text = source .contents ()
153- self .par .tab .addNewTab (sel [0 ].name ()+ '|' + source .name (), text )
159+ self .par .tab .addNewTab (sel [0 ].name () + '|' + source .name (), text )
154160 else :
155161 hou .ui .displayMessage ('Select One Node' )
156162
@@ -167,7 +173,7 @@ def saveToNode(self):
167173 d = (keys .index (section ),)
168174 else :
169175 d = ()
170- s = hou .ui .selectFromList (keys , default_choices = d ,exclusive = 1 )
176+ s = hou .ui .selectFromList (keys , default_choices = d , exclusive = 1 )
171177 if s :
172178 source = res [keys [s [0 ]]]
173179 if isinstance (source , hou .Parm ):
@@ -181,7 +187,8 @@ def saveToNode(self):
181187 hou .ui .displayMessage ('Select One Node' )
182188
183189 def getSectionsFromNode (self , node ):
184- default = ['Help' , 'TypePropertiesOptions' , 'ExtraFileOptions' , 'Tools.shelf' , 'InternalFileOptions' , 'Contents.gz' , 'CreateScript' , 'DialogScript' ]
190+ default = ['Help' , 'TypePropertiesOptions' , 'ExtraFileOptions' , 'Tools.shelf' , 'InternalFileOptions' ,
191+ 'Contents.gz' , 'CreateScript' , 'DialogScript' ]
185192 res = {}
186193 Def = node .type ().definition ()
187194 if Def :
@@ -203,17 +210,16 @@ def saveToSession(self):
203210 hou .setSessionModuleSource (text )
204211
205212
206-
207213def wrapDroppedText (namespace , text , event ):
208214 if event .keyboardModifiers () == hqt .Qt .AltModifier :
209215 syntax = []
210- #node
216+ # node
211217 for node_parm in text .split (',' ):
212218 node = hou .node (node_parm )
213219 if node :
214220 syntax .append ('hou.node("%s")' % node_parm )
215221
216- #parmTuple
222+ # parmTuple
217223 spl = text .split (',' )
218224 if len (list (set ([x [:- 1 ] for x in spl ]))) == 1 :
219225 parmTuple = hou .parmTuple (spl [0 ][:- 1 ])
@@ -229,4 +235,3 @@ def wrapDroppedText(namespace, text, event):
229235 return '\n ' .join (syntax )
230236
231237 return text
232-
0 commit comments