View in #3ds_max on Slack
@tool: Another question…When I do this
import os, MaxPlus
from PySide2 import QtCore, QtGui
UIPATH = os.path.join(os.getenv("CUSTOM_SCRIPTS"), "import/Tools/OurTool.ui")
print(UIPATH)
ui_type, base_type = MaxPlus.LoadUiType(UIPATH)
class Tool_UI(base_type, ui_type):
def __init__(self, parent = None):
base_type.__init__(self)
ui_type.__init__(self)
self.setupUi(self)
MaxPlus.AttachQWidgetToMax(self)
#show the window
def main():
main_window = Gravitize_UI()
main_window.show()
if __name__ == "__main__":
main()
my UI pops up for a split second then kills itself.
If I take the main_window lines out of the main function, it works fine. Is this expected in Max Python?
(also don’t mind the shitty naming, just doing the stuff I was talking about yesterday, trying to “replace” some old tooling, just changed the names for example)
@teessider: hey @tool Not sure about later versions of Max but I got this at the end of my gui script
(it came from one of Autodesk’s examples in the MaxPlus documentation i think xD), it works in 2015 + 2016:
if __name__ == '__main__':
app = QtGui.QApplication.instance()
if not app:
app = QtGui.QApplication('')
max_win = CustomMaxWindow()
max_win.show()
@dangrover: Yup, exactly what @teesi
woops
exactly what @teessider said!
@tool: Getting
AttributeError: 'module' object has no attribute 'QApplication'
@teessider: …did they move QApplication
in PySide2 then?
sorry…mine was from PySide 1 
@tool: not a clue, just starting to dip my feet in
they must have
cause
if __name__ == '__main__':
main_window = Gravitize_UI()
main_window.show()
works fine
wonk as fuck that I can’t do the other way
@teessider: Found the Doc:
https://doc.qt.io/qtforpython/PySide2/QtWidgets/QApplication.html?highlight=qapplication#PySide2.QtWidgets.QApplication
its in QtWidgets
now
They moved a bunch of stuff to QtWidgets
from QtGui
try replacing from PySide2 import QtCore, QtGui
with:
from PySide2 import QtCore, QtGui, QtWidgets
And change
app = QtGui.QApplication.instance()
if not app:
app = QtGui.QApplication('')
to
app = QtWidgets.QApplication.instance()
if not app:
app = QWidgets.QApplication('')
@tool: yeah seems to work