Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

Commit 538ba46

Browse files
authored
Merge pull request #12 from takavfx/cache-manager-for-H16
Add PySide2 improt for use on Houdini 16.
2 parents 68f1a55 + 9e374c5 commit 538ba46

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

python2.7libs/CacheManager/cacheWidget.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88

99
import sys
1010
sys.dont_write_bytecode = True
11-
1211
import os
1312
import re
1413
import platform
1514
from 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

1926
import hou
2027

@@ -30,11 +37,11 @@
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):

python2.7libs/CacheManager/gui.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
"""
77
#-------------------------------------------------------------------------------
88

9-
import os, sys
9+
import sys
1010
sys.dont_write_bytecode = True
11-
11+
import os
1212
import webbrowser
13-
from PySide import QtCore, QtGui
14-
from PySide import QtUiTools
13+
14+
import imp
15+
try:
16+
imp.find_module('PySide2')
17+
from PySide2.QtWidgets import *
18+
from PySide2.QtGui import *
19+
from PySide2.QtCore import *
20+
except ImportError:
21+
from PySide.QtGui import *
22+
from PySide.QtCore import *
1523

1624
import hou
1725

@@ -28,7 +36,7 @@
2836
pass
2937

3038

31-
class CacheManager(QtGui.QWidget):
39+
class CacheManager(QWidget):
3240
"""docstring for CacheManager"""
3341

3442

@@ -44,7 +52,7 @@ def initSettings(self):
4452

4553
def initGUI(self):
4654

47-
layout = QtGui.QVBoxLayout()
55+
layout = QVBoxLayout()
4856

4957
## Create Menu Bar
5058
self._createMenuBar()
@@ -75,10 +83,10 @@ def _createMenuBar(self):
7583
7684
Create the menu bar.
7785
"""
78-
self.menuBar = QtGui.QMenuBar()
86+
self.menuBar = QMenuBar()
7987
self.menuBar.setFixedHeight(25)
8088

81-
# help_button = QtGui.QToolButton()
89+
# help_button = QToolButton()
8290
# help_button.setFixedWidth(25)
8391
# help_button.setFixedHeight(25)
8492
# help_button.clicked.connect(self.showHelp)
@@ -89,12 +97,12 @@ def _createMenuBar(self):
8997
# help_button.setProperty("transparent", True);
9098
#
9199
# self.menuBar.setCornerWidget(help_button)
92-
# self.menuBar.cornerWidget(QtCore.Qt.TopRightCorner)
100+
# self.menuBar.cornerWidget(Qt.TopRightCorner)
93101

94102

95103
def _createEditMenu(self):
96104

97-
edit_menu = QtGui.QMenu(self)
105+
edit_menu = QMenu(self)
98106

99107
reloadAction = edit_menu.addAction("Reload")
100108
reloadAction.setShortcuts(("Ctrl+R", "F5"))
@@ -107,9 +115,9 @@ def _createEditMenu(self):
107115

108116
def _createViewMenu(self):
109117

110-
view_menu = QtGui.QMenu(self)
118+
view_menu = QMenu(self)
111119

112-
self.viewActionGroup = QtGui.QActionGroup(self)
120+
self.viewActionGroup = QActionGroup(self)
113121

114122
showRWaction = view_menu.addAction("Toggle R/W")
115123
showRWaction.setShortcut("Ctrl+E")
@@ -140,9 +148,9 @@ def _createViewMenu(self):
140148

141149
def _createAboutMenu(self):
142150

143-
about_menu = QtGui.QMenu(self)
151+
about_menu = QMenu(self)
144152

145-
openGitHubAction = QtGui.QAction("Bento on GitHub", self)
153+
openGitHubAction = QAction("Bento on GitHub", self)
146154
openGitHubAction.triggered.connect(self._gitHubButtonTriggered)
147155

148156
about_menu.addAction(openGitHubAction)

0 commit comments

Comments
 (0)