Widgets not updating when docked using workspaceControl PySide2/Maya2017

1,051 views
Skip to first unread message

Erik Johansson-Evegård

unread,
Mar 7, 2017, 7:03:29 AM3/7/17
to Python Programming for Autodesk Maya
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

ksn...@gmail.com

unread,
May 17, 2017, 6:34:09 PM5/17/17
to Python Programming for Autodesk Maya
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.

Erik Johansson-Evegård

unread,
May 18, 2017, 7:30:00 AM5/18/17
to python_in...@googlegroups.com
Never solved it. Kinda giving up on maya and autodesk lately overall. Just one of many things not working that should just work.

On Thu, May 18, 2017 at 12:28 AM, <ksn...@gmail.com> wrote:
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 python_inside_maya+unsub...@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.

ksn...@gmail.com

unread,
May 18, 2017, 9:05:17 AM5/18/17
to Python Programming for Autodesk Maya
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().

ksn...@gmail.com

unread,
May 18, 2017, 10:06:01 AM5/18/17
to Python Programming for Autodesk Maya
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.

obrien...@gmail.com

unread,
Aug 7, 2017, 1:36:53 PM8/7/17
to Python Programming for Autodesk Maya
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()

Justin Israel

unread,
Aug 7, 2017, 2:16:06 PM8/7/17
to Python Programming for Autodesk Maya

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


--
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_m...@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.

obrien...@gmail.com

unread,
Aug 7, 2017, 3:34:03 PM8/7/17
to Python Programming for Autodesk Maya
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.

Michael Boon

unread,
Aug 7, 2017, 10:13:24 PM8/7/17
to Python Programming for Autodesk Maya
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!

Erik Johansson-Evegård

unread,
Aug 15, 2017, 4:53:52 AM8/15/17
to python_in...@googlegroups.com
Seems to still work like shit in maya 2018. Seriously.....

--
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 python_inside_maya+unsub...@googlegroups.com.

Erik Johansson-Evegård

unread,
Aug 15, 2017, 5:08:48 AM8/15/17
to python_in...@googlegroups.com
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 <erik.johans...@gmail.com> wrote:
Seems to still work like shit in maya 2018. Seriously.....
On Tue, Aug 8, 2017 at 4:13 AM, Michael Boon <boon...@gmail.com> wrote:
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!

On Tuesday, 8 August 2017 05:34:03 UTC+10, Cole O'Brien wrote:
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 python_inside_maya+unsubscribe@googlegroups.com.

Erik Johansson-Evegård

unread,
Aug 15, 2017, 5:16:08 AM8/15/17
to python_in...@googlegroups.com
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 <erik.johans...@gmail.com> wrote:
Whole interface goes crazy when running the code and sometimes selection do not work.

cga...@rainmaker.com

unread,
Sep 28, 2017, 4:10:06 PM9/28/17
to Python Programming for Autodesk Maya
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,

kiteh

unread,
Nov 8, 2018, 3:11:28 PM11/8/18
to Python Programming for Autodesk Maya
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?)
Reply all
Reply to author
Forward
0 new messages