88
99import sys
1010sys .dont_write_bytecode = True
11-
1211import os
1312import re
1413import platform
1514from functools import partial
1615
17- from PySide import QtCore , QtGui
16+ import imp
17+ try :
18+ imp .find_module ('PySide2' )
19+ from PySide2 .QtWidgets import *
20+ from PySide2 .QtGui import *
21+ from PySide2 .QtCore import *
22+ except ImportError :
23+ from PySide .QtGui import *
24+ from PySide .QtCore import *
1825
1926import hou
2027
3037#-------------------------------------------------------------------------------
3138# QTreeWidget for displaying Cache List
3239#-------------------------------------------------------------------------------
33- class cacheTreeWidget (QtGui . QTreeWidget ):
40+ class cacheTreeWidget (QTreeWidget ):
3441 """docstring for cacheTableView"""
3542
3643 mouseReleased = QtCore .Signal (QtCore .QPoint )
37- keyPressed = QtCore .Signal (QtGui . QKeyEvent )
44+ keyPressed = QtCore .Signal (QKeyEvent )
3845
3946 HEADER_SETTING = Define .HEADER_SETTING
4047
@@ -54,7 +61,7 @@ def _initUI(self):
5461 self .setHeaderLabels (headerLabels )
5562 self .setSortingEnabled (True )
5663 self .setAlternatingRowColors (True )
57- self .setSelectionMode (QtGui . QAbstractItemView .ExtendedSelection )
64+ self .setSelectionMode (QAbstractItemView .ExtendedSelection )
5865 self ._setHeaderWidth ()
5966 self ._setHeaderVisible ()
6067 self .setData ()
@@ -102,14 +109,14 @@ def showCellMenu(self, pos):
102109 :param pos: <QtCore.QPoint> mouse click position.
103110 """
104111
105- cellMenu = QtGui . QMenu (self )
112+ cellMenu = QMenu (self )
106113 currentItem = self .itemAt (pos .x (), pos .y ())
107114
108115 if currentItem is None :
109116 return
110117
111118 ## Replace Cache File
112- actionReplaceCacheFile = QtGui . QAction ("Replace Cache File" , self )
119+ actionReplaceCacheFile = QAction ("Replace Cache File" , self )
113120 actionReplaceCacheFile .triggered .connect (partial (self ._replaceCacheFile , currentItem ))
114121
115122 actionReplaceCacheFile .setEnabled (False )
@@ -121,7 +128,7 @@ def showCellMenu(self, pos):
121128 cellMenu .addSeparator () ##----------------------------------------------
122129
123130 ## Forcus selected item
124- actionFocusThisNode = QtGui . QAction ("Focus this node" , self )
131+ actionFocusThisNode = QAction ("Focus this node" , self )
125132 actionFocusThisNode .triggered .connect (partial (self .focusThisNode , currentItem ))
126133
127134 actionFocusThisNode .setEnabled (False )
@@ -133,19 +140,19 @@ def showCellMenu(self, pos):
133140
134141 cellMenu .addSeparator () ##----------------------------------------------
135142
136- actionExpandAll = QtGui . QAction ("Expand all" , self )
143+ actionExpandAll = QAction ("Expand all" , self )
137144 actionExpandAll .triggered .connect (self .expandAll )
138145 cellMenu .addAction (actionExpandAll )
139146
140- actionCollapseAll = QtGui . QAction ("Collapse all" , self )
147+ actionCollapseAll = QAction ("Collapse all" , self )
141148 actionCollapseAll .triggered .connect (self .collapseAll )
142149 cellMenu .addAction (actionCollapseAll )
143150
144151 cellMenu .addSeparator () ##----------------------------------------------
145152
146153 # Debug
147154 if Define .DEBUG_MODE :
148- debug = QtGui . QAction ("Debug" , self )
155+ debug = QAction ("Debug" , self )
149156 debug .triggered .connect (self .debugfunc )
150157
151158 cellMenu .addAction (debug )
@@ -180,7 +187,7 @@ def setData(self):
180187 topItem = self .findChild (rootItem , topToken )
181188
182189 if topItem is None :
183- topItem = QtGui . QTreeWidgetItem (rootItem , [topToken ])
190+ topItem = QTreeWidgetItem (rootItem , [topToken ])
184191
185192 if len (pathTokens ) > 0 :
186193 self ._setChildItem (topItem , pathTokens , path , cache_path , rwtype , editable , status )
@@ -212,7 +219,7 @@ def _setChildItem(self, parentItem, restTokens, nodePathItem, cachePathItem, rwt
212219 childItem = self .findChild (parentItem , nextToken )
213220
214221 if childItem is None :
215- childItem = QtGui . QTreeWidgetItem (parentItem , [nextToken ])
222+ childItem = QTreeWidgetItem (parentItem , [nextToken ])
216223 self .setStatus (childItem , cachePathItem , editable , status )
217224
218225 if len (restTokens ) > 0 :
@@ -231,23 +238,23 @@ def setStatus(self, treeItem, cachePathItem, editable, status):
231238 treeItem .setHidden (True )
232239 if status == "bypassed" :
233240 # treeItem.setForeground(self.section("node"),
234- # QtGui. QBrush(QtGui. QColor(Define.BYPASSED_COLOR)))
241+ # QBrush(QColor(Define.BYPASSED_COLOR)))
235242 treeItem .setForeground (self .section ("cache_path" ),
236- QtGui . QBrush (QtGui . QColor (Define .BYPASSED_COLOR )))
243+ QBrush (QColor (Define .BYPASSED_COLOR )))
237244 treeItem .setForeground (self .section ("rwtype" ),
238- QtGui . QBrush (QtGui . QColor (Define .BYPASSED_COLOR )))
245+ QBrush (QColor (Define .BYPASSED_COLOR )))
239246 treeItem .setForeground (self .section ("status" ),
240- QtGui . QBrush (QtGui . QColor (Define .BYPASSED_COLOR )))
247+ QBrush (QColor (Define .BYPASSED_COLOR )))
241248
242249 if status == "error" :
243250 # treeItem.setForeground(self.section("node"),
244- # QtGui. QBrush(QtGui. QColor(Define.ERRORS_COLOR)))
251+ # QBrush(QColor(Define.ERRORS_COLOR)))
245252 treeItem .setForeground (self .section ("cache_path" ),
246- QtGui . QBrush (QtGui . QColor (Define .ERRORS_COLOR )))
253+ QBrush (QColor (Define .ERRORS_COLOR )))
247254 treeItem .setForeground (self .section ("rwtype" ),
248- QtGui . QBrush (QtGui . QColor (Define .ERRORS_COLOR )))
255+ QBrush (QColor (Define .ERRORS_COLOR )))
249256 treeItem .setForeground (self .section ("status" ),
250- QtGui . QBrush (QtGui . QColor (Define .ERRORS_COLOR )))
257+ QBrush (QColor (Define .ERRORS_COLOR )))
251258
252259
253260 def _replaceCacheFile (self , treeItem ):
0 commit comments