Discussion:
[Maya-Python] Widgets not updating when docked using workspaceControl PySide2/Maya2017
Erik Johansson-Evegård
2017-03-07 12:03:29 UTC
Permalink
Hi

I got this strange problem that QTableWidget and QTreeWidget do not update
until resized when docked over the attrbute editor.

There is probably more that don't work as expected but these are what I
have noticed so far.

Have anyone noticed anything similar?

If I tear it off from the right dock and then dock it again it works as it
should/expected so I think the error it somewhere at the end with the
show, workspaceControl and raise_

Anyone got some ideas?

This is the code I am trying to use to dock our import asset panel.

from ftrackplugin import ftrackDialogs
from fido import common

from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
from PySide2 import QtWidgets, QtCore

controlName = 'foobar'

class FooWidget(MayaQWidgetDockableMixin, QtWidgets.QWidget):
def __init__(self, parent=None):
super(FooWidget, self).__init__(parent=parent)
global controlName
self.setObjectName(controlName)
self.setWindowTitle(controlName)
vlayout = QtWidgets.QVBoxLayout(self)
# ftrackImportDialog just becomes a QWidget
ftrackImportDialog = ftrackDialogs.ftrackImportAssetQt()
vlayout.addWidget(ftrackImportDialog)
self.setLayout(vlayout)

# getMainWindow is just a wrapper function around the regular ways
mw = common.getMainWindow()
bar = FooWidget(mw)

workspaceControlName = bar.objectName() + 'WorkspaceControl'

mayaPanelName = "AttributeEditor"
mc.setParent(mayaPanelName)

if mc.workspaceControl(workspaceControlName, q=True, exists=True):
mc.workspaceControl(workspaceControlName, e=True, close=True)
mc.deleteUI(workspaceControlName, control=True)


bar.show(dockable=True, area='right', floating=False)
mc.workspaceControl(workspaceControlName, edit=True,
tabToControl=[mayaPanelName, -1], widthProperty="preferred",
minimumWidth=620)
bar.raise_()


Cheers,
Erik
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/73556f3e-358b-482c-a50b-675b782c6f35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
k***@gmail.com
2017-05-17 22:28:14 UTC
Permalink
I'm noticing a similar defect myself and was scouring the interwebs to hopefully find an resolution. Did you solve this yet?

The closest I've gotten is adding .update() and .repaint() in various locations, but I shouldn't have to and it is difficult to catch everything.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/51ea3878-db26-4cb0-8fe6-7c5b4e80dd2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Erik Johansson-Evegård
2017-05-18 11:29:55 UTC
Permalink
Never solved it. Kinda giving up on maya and autodesk lately overall. Just
one of many things not working that should just work.
Post by k***@gmail.com
I'm noticing a similar defect myself and was scouring the interwebs to
hopefully find an resolution. Did you solve this yet?
The closest I've gotten is adding .update() and .repaint() in various
locations, but I shouldn't have to and it is difficult to catch everything.
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/python_inside_maya/LDRrxw9pJyo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/51ea3878-db26-4cb0-8fe6-
7c5b4e80dd2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM5A7-5M67OFUTmG9YC04UM5Qyn1V-vfVi4MQKYL7Lcxkr4Dpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
k***@gmail.com
2017-05-18 13:05:13 UTC
Permalink
Bummer. OK. I'll keep and eye out and repost if I find a proper solution.

For now, I have a workaround that is okay with my tool. Basically I have a queue running in the background that collects callback messages from Maya. It processes the queue when Maya is idle. This stuff like 'selection change', 'attr changed', 'file open', etc. Anyways, once the queue is emptied I fire off a .update() on my top widget. Seems to be working mostly, but there are likely a few glitches...e.g. I've noticed that the docked widget isn't drawn correctly when first docked unless the splitter for the frame it is in is resized. So, I'll try to come up with something for that too.

To be clear, I don't need any special .update() when the widget is floating. Also, this tool is a port from a version that runs fine in MotionBuilder floating or docked without the need for the .update().
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ce773aa8-6d2a-4118-9bc3-aa50ff2243b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
k***@gmail.com
2017-05-18 14:05:58 UTC
Permalink
Actually, with a little more iteration I'm getting decent results by updating the layout, and only that, on my main widget...

self.layout().update()

... via my event_queue that I mentioned earlier.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3b2fdc7d-d69f-4269-b2dc-c93c9fe5c0c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
o***@gmail.com
2017-08-07 17:09:17 UTC
Permalink
For those googling this. I was able to solve this by connecting all signals on my widget to a call to `QApplication.processEvents()`. Its not exactly elegant but it got the job done.
Here's the basic code:

from Qt import QtWidgets
from Qt.QtCore import Signal, Slot

def connectToReload(MyWindow):
cls = MyWindow if isinstance(MyWindow, type) else type(MyWindow)
signal = type(Signal())
signals = [name for name in dir(MyWindow) if isinstance(getattr(cls, name), signal)]

for signal in signals:
getattr(MyWindow, signal).connect(reloadApp)

@Slot()
def reloadApp(*args, **kwargs):
app = QtWidgets.QApplication.instance()
app.processEvents()
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/08e3e66a-2124-4d5e-b122-474cd7b4b45d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2017-08-07 18:15:48 UTC
Permalink
Be very careful with your calls to processEvents(). In my experience it can
be a source of bugs if you do it without being aware of the effects. I have
seen situations where it happens in an event call stack which then causes
the event loop to run again and create a deeper stack. Then bugs can either
happen in that deeper stack from new events being triggered or during the
unwind when, say, a model has been invalidated but you go to work with it
in the original stack frames. I have also seen recursion bugs happening
when processEvents is hit in the nested stack frame and continue to
trigger.

Justin
Post by o***@gmail.com
For those googling this. I was able to solve this by connecting all
signals on my widget to a call to `QApplication.processEvents()`. Its not
exactly elegant but it got the job done.
from Qt import QtWidgets
from Qt.QtCore import Signal, Slot
cls = MyWindow if isinstance(MyWindow, type) else type(MyWindow)
signal = type(Signal())
signals = [name for name in dir(MyWindow) if isinstance(getattr(cls, name), signal)]
getattr(MyWindow, signal).connect(reloadApp)
@Slot()
app = QtWidgets.QApplication.instance()
app.processEvents()
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/08e3e66a-2124-4d5e-b122-474cd7b4b45d%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA09UQxfptD_mmR1MUR7%3Dbg6%2BmMGJYkwvBodEbK9W8_V_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
o***@gmail.com
2017-08-07 19:33:58 UTC
Permalink
Gotcha, yeah totally not a great solution in the long run. I had yet to find a simple solution to this online, so I figured this would be helpful for those that need something quick.

Thanks for the info though, I'll keep an eye out for bugs down the line.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c41d69a4-107c-47f5-bfbe-88c84d12fcb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Boon
2017-08-08 02:13:24 UTC
Permalink
I few days ago I ran a script from the Script Editor, which ran a robocopy
from a network location, and contained a call to processEvents. It created
an infinite loop of robocopy calls. I had to restart my PC to stop it!
Post by o***@gmail.com
Gotcha, yeah totally not a great solution in the long run. I had yet to
find a simple solution to this online, so I figured this would be helpful
for those that need something quick.
Thanks for the info though, I'll keep an eye out for bugs down the line.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Erik Johansson-Evegård
2017-08-15 08:53:45 UTC
Permalink
Seems to still work like shit in maya 2018. Seriously.....
Post by Michael Boon
I few days ago I ran a script from the Script Editor, which ran a robocopy
from a network location, and contained a call to processEvents. It created
an infinite loop of robocopy calls. I had to restart my PC to stop it!
Post by o***@gmail.com
Gotcha, yeah totally not a great solution in the long run. I had yet to
find a simple solution to this online, so I figured this would be helpful
for those that need something quick.
Thanks for the info though, I'll keep an eye out for bugs down the line.
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/python_inside_maya/LDRrxw9pJyo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-
d641e51e2c67%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM5A7-4ytHgPvRkKXRW8kE2ZxWMRcyzOEvJsZqbRa3Vw_uG07w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Erik Johansson-Evegård
2017-08-15 09:08:42 UTC
Permalink
Whole interface goes crazy when running the code and sometimes selection do
not work.

On Tue, Aug 15, 2017 at 10:53 AM, Erik Johansson-Evegård <
Post by Erik Johansson-Evegård
Seems to still work like shit in maya 2018. Seriously.....
Post by Michael Boon
I few days ago I ran a script from the Script Editor, which ran a
robocopy from a network location, and contained a call to processEvents. It
created an infinite loop of robocopy calls. I had to restart my PC to stop
it!
Post by o***@gmail.com
Gotcha, yeah totally not a great solution in the long run. I had yet to
find a simple solution to this online, so I figured this would be helpful
for those that need something quick.
Thanks for the info though, I'll keep an eye out for bugs down the line.
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/python_inside_maya/LDRrxw9pJyo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit https://groups.google.com/d/ms
gid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%
40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM5A7-6PEH-TJ7Edf1CSvnwKTpCzC4A5bWHDO8pOCXMjRFeX3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Erik Johansson-Evegård
2017-08-15 09:16:03 UTC
Permalink
Can't get it to show on top anymore either. Always docks below the other
tabs

On Tue, Aug 15, 2017 at 11:08 AM, Erik Johansson-Evegård <
Post by Erik Johansson-Evegård
Whole interface goes crazy when running the code and sometimes selection
do not work.
On Tue, Aug 15, 2017 at 10:53 AM, Erik Johansson-Evegård <
Post by Erik Johansson-Evegård
Seems to still work like shit in maya 2018. Seriously.....
Post by Michael Boon
I few days ago I ran a script from the Script Editor, which ran a
robocopy from a network location, and contained a call to processEvents. It
created an infinite loop of robocopy calls. I had to restart my PC to stop
it!
Post by o***@gmail.com
Gotcha, yeah totally not a great solution in the long run. I had yet to
find a simple solution to this online, so I figured this would be helpful
for those that need something quick.
Thanks for the info though, I'll keep an eye out for bugs down the line.
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/python_inside_maya/LDRrxw9pJyo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit https://groups.google.com/d/ms
gid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%
40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/89c6cc4b-3854-4c33-a4c5-d641e51e2c67%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM5A7-60kJFgWwEjv10QStTYJkb%3Dtag42gewH-kndDy7B0n5SQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
c***@rainmaker.com
2017-09-28 19:05:54 UTC
Permalink
Hi,

I got the same error, but I found a way to get it to work...

What I do is before I create the widget that is going into the Workspace I create a dummy one. I'm guessing that the bug is due to some initialization that is not been done on the first Workspace created, here is the dummy dialog...
main_window_ptr = omui.MQtUtil.mainWindow()
mayaWid = QtCompat.wrapInstance(long(main_window_ptr), QtWidgets.QWidget)

class dummyClass(MayaQWidgetDockableMixin, QtWidgets.QDialog):
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)

_dummyUI = dummyClass(mayaWid)

_dummyUI.setObjectName("DockingDummyWindow")
workspaceControlName = _dummyUI.objectName() + 'WorkspaceControl'

_dummyUI.show(dockable=True, area='right', floating=False)
cmds.workspaceControl(workspaceControlName, e=True,
ttc=["AttributeEditor", -1], wp="preferred",
mw=420)

cmds.workspaceControl(workspaceControlName, e=True, close=True)
cmds.deleteUI(workspaceControlName, control=True)

Once this is deleted, you add the code that creates the real UI.

It works for me, so maybe try it out.

Cheers,
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a0c45475-217e-46a0-94c2-29c1fa0b257a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
kiteh
2018-11-08 20:11:28 UTC
Permalink
Hi all, sorry that I am jumping towards this old thread.

I did get this weird issue in Maya 2018, where the
`dockCloseEventTriggered` is not called unless it is docked.
Tried using the 'dummy' method in the above post, but still, that signal is
not being called when undocked.

Wondering if anyone has any other insights for this?

(P.S: I do not have the Qt installed and was using `shiboken2` that
replaces the use of 'QtCompat' instead. Maybe I should not have done that?)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ff857529-a27b-4c90-89df-e35b702e1b85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...