I am trying to populate a scroll layout after I click a button.

216 views
Skip to first unread message

I73

unread,
Sep 23, 2016, 1:11:32 PM9/23/16
to Python Programming for Autodesk Maya
Is it possible to populate a scroll list after the user preforms an action? 


             cmds.button('Fill Scroll layout', someFunctionToFillLayout)
             cmds.scrollLayout(...)
        #Want to fill the scroll layout with a list of verts after the user clicks a button
for vert in verts:
cmds.text(vert)
     cmds.setParent('..')

How can I achieve appending text inside the scroll layout once an 

Justin Israel

unread,
Sep 23, 2016, 5:28:06 PM9/23/16
to Python Programming for Autodesk Maya

Have a look at the "command" parameter as well as the usage example at the bottom of this link
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/button.html#flagcommand

The missing bit from this example however is how to modify your scroll layout from the callback. What you should do is same the same of the scroll control that is returned when you first create it. You need that reference to be able to either edit the scrollLayout later in the button callback or to set it as the parent when adding more child UI controls. If you are writing your code as a class, this should be trivial because you can store the same of the scrollLayout as a member variable and read it later in the callback. If you are only using functions then you may need to capture the name into a function closure, either by defining your callback function right there in the same function as your layout, or looking at lambda or functools.partial
Either way, I would recommend sticking to the approach of passing a callback function as opposed to the string form that Mel uses.

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/cd499b43-b31a-4ac2-bb75-4f179cab4a17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Israel

unread,
Sep 23, 2016, 5:29:52 PM9/23/16
to Python Programming for Autodesk Maya


On Sat, 24 Sep 2016, 9:27 AM Justin Israel <justin...@gmail.com> wrote:

What you should do is same the same of the scroll control that is returned when you first create it.

Mobile typo... 
Save the name. 

Wesley Keeling

unread,
Sep 23, 2016, 6:02:00 PM9/23/16
to python_in...@googlegroups.com
Sorry, the 'someFunctionToFillLayout' was the command for the button. 
I forgot the "command=" 
As for refrencing the scroll layout I have no problem doing that I will just make a 'partial' and include the reference to the layout. But I am not sure how I can edit a scroll layout, more specifically there is no flags in the scroll layout that I can use to edit what is inside a scroll layout:
At least what I can see, 

I cant use[cmds.scrollLayout('myScrollLayout', e=True, text/label/value = 'blah')]

Is it possible to edit the children elements? without having to instance them?

On Fri, Sep 23, 2016 at 2:27 PM, Justin Israel <justin...@gmail.com> wrote:

Have a look at the "command" parameter as well as the usage example at the bottom of this link
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/button.html#flagcommand

The missing bit from this example however is how to modify your scroll layout from the callback. What you should do is same the same of the scroll control that is returned when you first create it. You need that reference to be able to either edit the scrollLayout later in the button callback or to set it as the parent when adding more child UI controls. If you are writing your code as a class, this should be trivial because you can store the same of the scrollLayout as a member variable and read it later in the callback. If you are only using functions then you may need to capture the name into a function closure, either by defining your callback function right there in the same function as your layout, or looking at lambda or functools.partial
Either way, I would recommend sticking to the approach of passing a callback function as opposed to the string form that Mel uses.

Justin


On Sat, 24 Sep 2016, 5:11 AM I73 <wesley....@iugome.com> wrote:
Is it possible to populate a scroll list after the user preforms an action? 


             cmds.button('Fill Scroll layout', someFunctionToFillLayout)
             cmds.scrollLayout(...)
        #Want to fill the scroll layout with a list of verts after the user clicks a button
for vert in verts:
cmds.text(vert)
     cmds.setParent('..')

How can I achieve appending text inside the scroll layout once an 

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

--
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/lCO4QBhy2U4/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/CAPGFgA0ySWkHnvri6e4sJjuVn95xSufv2b-rQYgN_L4oTAf%2BSA%40mail.gmail.com.

Justin Israel

unread,
Sep 23, 2016, 6:12:14 PM9/23/16
to python_in...@googlegroups.com


On Sat, 24 Sep 2016, 10:01 AM Wesley Keeling <wesley....@iugome.com> wrote:
Sorry, the 'someFunctionToFillLayout' was the command for the button. 
I forgot the "command=" 
As for refrencing the scroll layout I have no problem doing that I will just make a 'partial' and include the reference to the layout. But I am not sure how I can edit a scroll layout, more specifically there is no flags in the scroll layout that I can use to edit what is inside a scroll layout:
At least what I can see, 

I cant use[cmds.scrollLayout('myScrollLayout', e=True, text/label/value = 'blah')]

Is it possible to edit the children elements? without having to instance them?

It is because the layout is just a layout and in Maya native UI terms you just create more controls which get attached to the current parent or the parent you explicitly pass in

Are you trying to get at the arbitrary children of the layout? Or to add more or clear the layout? You should be able to use the reference to the layout to list the children. 


On Fri, Sep 23, 2016 at 2:27 PM, Justin Israel <justin...@gmail.com> wrote:

Have a look at the "command" parameter as well as the usage example at the bottom of this link
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/button.html#flagcommand

The missing bit from this example however is how to modify your scroll layout from the callback. What you should do is same the same of the scroll control that is returned when you first create it. You need that reference to be able to either edit the scrollLayout later in the button callback or to set it as the parent when adding more child UI controls. If you are writing your code as a class, this should be trivial because you can store the same of the scrollLayout as a member variable and read it later in the callback. If you are only using functions then you may need to capture the name into a function closure, either by defining your callback function right there in the same function as your layout, or looking at lambda or functools.partial
Either way, I would recommend sticking to the approach of passing a callback function as opposed to the string form that Mel uses.

Justin


On Sat, 24 Sep 2016, 5:11 AM I73 <wesley....@iugome.com> wrote:
Is it possible to populate a scroll list after the user preforms an action? 


             cmds.button('Fill Scroll layout', someFunctionToFillLayout)
             cmds.scrollLayout(...)
        #Want to fill the scroll layout with a list of verts after the user clicks a button
for vert in verts:
cmds.text(vert)
     cmds.setParent('..')

How can I achieve appending text inside the scroll layout once an 

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

--
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/lCO4QBhy2U4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAD4CW7rv6msbKtMGYbHO0d_n%3DS9fn4o4xLxfr-%3DqiejTTMFYQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages