I’ve had a look at this just now, and it looks like they’ve gone from using
a QToolBox to simply appending arbitrary widgets to a QLayout.

I don’t blame them, think it should probably have been made that way from
the start, but what it means for us is that there is no adapting this
script to work. It’ll need a rewrite.

It’s possible the alternative approach could work on 2017 *and* lower,
which would be ideal.

I would start looking into grabbing hold of the layout, and adding your
widget (not action) to it.

Here’s a start.

import os
try:
    from PySide import QtGui
    QtWidgets = QtGuiexcept ImportError:
    from PySide2 import QtWidgets, QtGui
# Use this to locate your widget; it will return the# widget currently
under your cursor.# parent =
QtWidgets.qApp.widgetAt(QtGui.QCursor.pos()).objectName()#
parent.objectName()
# Use this once you know the name of it, in this case "toolBar1"# We
can find it as a child of the main window.
window = {o.objectName(): o for o in
QtWidgets.qApp.topLevelWidgets()}["MayaWindow"]
toolbar = window.findChild(QtWidgets.QToolBar, "toolBar1")
if toolbar:
    layout = toolbar.layout()else:
    layout = window.findChild(QtWidgets.QLayout, "flowLayout1")
assert layout, "Sorry, couldn't find the toolbar."
# Create a random action# NOTE: Not including an icon
action = QtWidgets.QPushButton("Hello")
# Add to the end..# NOTE: Not adding to start
layout.addWidget(action)
# If you need to replace/update it, you can remove it like so.#
action.deleteLater()
# Enjoy!

​

On 12 October 2016 at 12:43, Michał Frątczak <f.mic...@gmail.com> wrote:

> Sorry for bringing this up from the past.
> We move to maya 2017 and obviously this isn't working anymore.
> I updated code to PySide2 (after reading Fredrik's blog) but I get notging
> (even error messages).
> Where in 2015 used to be toolBar object, now is 'flowLayout1' widget...
> Is anybody willing to update this example for maya2017?
>
> thanks!
>
> On Tuesday, March 22, 2016 at 1:55:38 PM UTC+1, Michał Frątczak wrote:
>>
>> Hello !
>> Does anybody have example code adding anything to statusline (that one
>> with open,save icons) ?
>> I will take any suggestions :)
>>
>> thanks
>> -michal
>>
>> PS. maya2015
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/5bc42682-b2ca-45e8-b617-
> 360dd2b3b07e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/5bc42682-b2ca-45e8-b617-360dd2b3b07e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
konstrukt...@gmail.com

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCsBJERjGxGo%2BusF3jWAef9yYHG1NBVSiRc-eYEnS1-YA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to