Re: [Maya-Python] Re: adding text to statusline

2016-10-13 Thread Michał Frątczak
All is working great now, thanks Marcus

On Wednesday, October 12, 2016 at 5:41:36 PM UTC+2, Marcus Ottosson wrote:
>
> Ah, that’s interesting.
>
> qApp  is the actively 
> running instance of a QApplication; you could alternatively call 
> QtWidgets.QApplication.instance() 
> . Maya is bound to 
> have just one, but it seems that, based on your description, userSetup.py 
> executes *before* Qt starts running (sometimes?).
>
> I would pass the entire thing, e.g. by wrapping it into a function, 
> through cmds.evalDeferred or Qt.QtCore.QTimer.singleShot, that should 
> give Qt enough time to catch up.
> ​
>

-- 
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/8ab1dc38-2297-4e38-b9cb-02062c376312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: adding text to statusline

2016-10-12 Thread Marcus Ottosson
Ah, that’s interesting.

qApp  is the actively
running instance of a QApplication; you could alternatively call
QtWidgets.QApplication.instance()
. Maya is bound to
have just one, but it seems that, based on your description, userSetup.py
executes *before* Qt starts running (sometimes?).

I would pass the entire thing, e.g. by wrapping it into a function, through
cmds.evalDeferred or Qt.QtCore.QTimer.singleShot, that should give Qt
enough time to catch up.
​

-- 
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/CAFRtmOAJCwQ%2B1MRtcYZyGLEfL4z%2BGRxMY7W0p8yNNBftW-MRtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: adding text to statusline

2016-10-12 Thread Marcus Ottosson
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  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
> 
> .
>
> 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.