Skip to content

Commit

Permalink
Added support for PySide6 in PyLuxCoreTools (Windows only)
Browse files Browse the repository at this point in the history
  • Loading branch information
acasta69 committed Dec 11, 2021
1 parent d8ef9e4 commit a8b309e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(NOT APPLE)
endif()
endif()

find_program(PYSIDE_UIC NAMES pyside-uic pyside2-uic
find_program(PYSIDE_UIC NAMES pyside-uic pyside2-uic pyside6-uic
HINTS "${PYTHON_INCLUDE_DIRS}/../Scripts"
PATHS "c:/Program Files/Python${PYTHON_V}/Scripts")

Expand Down
8 changes: 6 additions & 2 deletions samples/pyluxcoretool/pyluxcoretool.win.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ def pyside_imports():
import PySide.QtCore as QtCore
result = ['PySide.QtCore','PySide.QtGui']
except ImportError:
from PySide2 import QtCore
result = ['PySide2.QtCore','PySide2.QtGui', 'PySide2.QtWidgets']
try:
from PySide2 import QtCore
result = ['PySide2.QtCore','PySide2.QtGui', 'PySide2.QtWidgets']
except ImportError:
from PySide6 import QtCore
result = ['PySide6.QtCore','PySide6.QtGui', 'PySide6.QtWidgets']
return result

a = Analysis(['pyluxcoretool.py'],
Expand Down
12 changes: 8 additions & 4 deletions src/pyluxcoretools/pyluxcoretools/pyluxcoremenu/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
import PySide.QtCore as QtCore
import PySide.QtGui as QtGui
import PySide.QtGui as QtWidgets
PYSIDE2 = False
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE2 = True
try:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide6 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])

import pyluxcoretools.utils.loghandler as loghandler
import pyluxcoretools.pyluxcoremenu.menuwindow as menuwindow
Expand All @@ -43,7 +47,7 @@ def __init__(self, parent=None):

super(MenuApp, self).__init__(parent)
self.setupUi(self)
if not PYSIDE2:
if PYSIDE_V < 5:
self.move(QtWidgets.QApplication.desktop().screen().rect().center()- self.rect().center())

def clickedNetNode(self):
Expand Down
23 changes: 16 additions & 7 deletions src/pyluxcoretools/pyluxcoretools/pyluxcorenetconsole/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@
import PySide.QtCore as QtCore
import PySide.QtGui as QtGui
import PySide.QtGui as QtWidgets
PYSIDE2 = False
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE2 = True
try:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide6 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])

import pyluxcoretools.renderfarm.renderfarm as renderfarm
import pyluxcoretools.renderfarm.renderfarmjobsingleimage as jobsingleimage
Expand Down Expand Up @@ -154,12 +158,17 @@ def __init__(self, parent = None):
super(AddNodeDialog, self).__init__(parent)
self.setupUi(self)

ipRegExp = QtCore.QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
self.lineEditIPAddress.setValidator(QtGui.QRegExpValidator(ipRegExp))
if PYSIDE_V >= 6:
ipRegExp = QtCore.QRegularExpression("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
ipRegExpVal = QtGui.QRegularExpressionValidator(ipRegExp)
else:
ipRegExp = QtCore.QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
ipRegExpVal = QtGui.QRegExpValidator(ipRegExp)
self.lineEditIPAddress.setValidator(ipRegExpVal)
self.lineEditPort.setValidator(QtGui.QIntValidator(0, 65535))
self.lineEditPort.setText(str(renderfarm.DEFAULT_PORT))

if not PYSIDE2:
if PYSIDE_V < 5:
self.move(QtWidgets.QApplication.desktop().screen().rect().center()- self.rect().center())

def GetIPAddress(self):
Expand All @@ -174,7 +183,7 @@ def __init__(self, parent=None):
super(MainApp, self).__init__(parent)
self.setupUi(self)

if not PYSIDE2:
if PYSIDE_V < 5:
self.move(QtWidgets.QApplication.desktop().screen().rect().center()- self.rect().center())

uiloghandler.AddUILogHandler(loghandler.loggerName, self)
Expand Down
23 changes: 16 additions & 7 deletions src/pyluxcoretools/pyluxcoretools/pyluxcorenetnode/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
import PySide.QtCore as QtCore
import PySide.QtGui as QtGui
import PySide.QtGui as QtWidgets
PYSIDE2 = False
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE2 = True
try:
from PySide2 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])
except ImportError:
from PySide6 import QtGui, QtCore, QtWidgets
PYSIDE_V = int(QtCore.qVersion()[:1])

import pyluxcoretools.renderfarm.renderfarm as renderfarm
import pyluxcoretools.renderfarm.renderfarmnode as renderfarmnode
Expand All @@ -48,15 +52,20 @@ def __init__(self, parent=None):
super(MainApp, self).__init__(parent)
self.setupUi(self)

if not PYSIDE2:
if PYSIDE_V < 5:
self.move(QtWidgets.QApplication.desktop().screen().rect().center()- self.rect().center())

uiloghandler.AddUILogHandler(loghandler.loggerName, self)

ipRegExp = QtCore.QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
self.lineEditIPAddress.setValidator(QtGui.QRegExpValidator(ipRegExp))
if PYSIDE_V >= 6:
ipRegExp = QtCore.QRegularExpression("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
ipRegExpVal = QtGui.QRegularExpressionValidator(ipRegExp)
else:
ipRegExp = QtCore.QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
ipRegExpVal = QtGui.QRegExpValidator(ipRegExp)
self.lineEditIPAddress.setValidator(ipRegExpVal)
self.lineEditPort.setValidator(QtGui.QIntValidator(0, 65535))
self.lineEditBroadcastAddress.setValidator(QtGui.QRegExpValidator(ipRegExp))
self.lineEditBroadcastAddress.setValidator(ipRegExpVal)

self.__ResetConfigUI()

Expand Down
5 changes: 4 additions & 1 deletion src/pyluxcoretools/pyluxcoretools/utils/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import PySide.QtGui as QtGui
import PySide.QtGui as QtWidgets
except ImportError:
from PySide2 import QtGui, QtCore, QtWidgets
try:
from PySide2 import QtGui, QtCore, QtWidgets
except ImportError:
from PySide6 import QtGui, QtCore, QtWidgets

class LogEvent(QtCore.QEvent):
EVENT_TYPE = QtCore.QEvent.Type(QtCore.QEvent.registerEventType())
Expand Down
5 changes: 4 additions & 1 deletion src/pyluxcoretools/pyluxcoretools/utils/uiloghandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import PySide.QtGui as QtGui
import PySide.QtGui as QtWidgets
except ImportError:
from PySide2 import QtGui, QtCore, QtWidgets
try:
from PySide2 import QtGui, QtCore, QtWidgets
except ImportError:
from PySide6 import QtGui, QtCore, QtWidgets

class UILogHandler(logging.Handler):
def __init__(self, app):
Expand Down

0 comments on commit a8b309e

Please sign in to comment.