Looks like on 2021 accessing QtWidgets this way won't work so python.import "PySide2.QtWidgets" has to be used instead.
@denisT.MaxDoctor wrote:
@Swordslayer wrote:
local pySide2 = python.import "PySide2"
I'm so happy to see that! Is there any documentation? ... but anyway, I'm glad to just know that it exists, everything else is at least "SAPIENTI SAT".
Which part? The python.import to get python modules exposed to mxs directly was already documented five years ago when pymxs was introduced, so you can do fun stuff like this for quite a while:
builtin = python.import "builtins" #"__builtin__" for python 2.6
itertools = python.import "itertools"
builtin.list(itertools.repeat 10 5) as array
builtin.all #{1..5,7}
I usually only use the Qt portions (for new parts of UI) and ctypes (since I'm too lazy to write verbose C# only to get some user32 methods and they're pretty conveniently exposed via ctypes.windll.user32).
ctypes = python.import "ctypes"
ctypes.windll.user32.SendMessageW ...
As for PySide2 usage from MAXScript, querying/modifying existing parts of the UI is pretty straightforward but I don't think you could for example use it to create a Qt dialog from mxs that would do something - but I would certainly like to be proven wrong 🙂