如何在maya python的framelayout中添加scrolllayout

时间:2015-12-04 16:39:02

标签: python maya

我有一个frameLayout加载图片,如果我加载更多图片我无法看到所有图片, 因此我需要在frameLayout中添加scrollLayout,以便我可以滚动并查看图像。 在这里,我无法在frameLayout中添加scrollLayout。

这是我的代码......

import maya.cmds as cmds
import re,sys,os
class assetBrowseTool(object):
    def __init__(self):
        if (cmds.window('assetBrowseWindow', q=True, ex=True)):
            cmds.deleteUI('assetBrowseWindow')
        assetWindow = cmds.window('assetBrowseWindow', title="xxxxxxx V1.0",s = False,widthHeight=(930, 530) )
        form = cmds.formLayout(numberOfDivisions=100, width=215, height=175)
        frame = cmds.frameLayout('imageFrame', label='Assets', borderStyle='in',w = 200, h = 200 )
        cmds.setParent( '..' )
        tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        cmds.formLayout( form, edit=True, attachForm=[
        (tabs, 'top', 450), (tabs, 'left', 720), (tabs, 'bottom', 5), (tabs, 'right', 5),
        (tabs, 'right', 0),
        (frame,'left',5),(frame,'top',70),(frame,'bottom',5),(frame,'right',210)])
        child1 = cmds.rowColumnLayout(numberOfRows=1)
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.setParent( '..' )
        child2 = cmds.rowColumnLayout(numberOfColumns=1)
        cmds.setParent( '..' )
        child3 = cmds.rowColumnLayout(numberOfColumns=1)
        cmds.setParent( '..' )
        cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'IMPORT'), (child2, 'PUBLISH'),(child3, 'EXPORT')) )
        cmds.showWindow( 'assetBrowseWindow' )

assetBrowseTool()

for scrollLayout

scrollLayout = cmds.scrollLayout(horizontalScrollBarThickness=0, verticalScrollBarThickness=0 )        
value = cmds.scrollLayout(scrollLayout, query=True, scrollAreaValue=True)
top = value[0]
left = value[1]

如何将scrollLayout代码添加到上面的窗口中。 感谢。

1 个答案:

答案 0 :(得分:0)

如果我理解正确,那么你想在frameLayout中找到一个scrolLayout,如果那个案例就在这里工作,例如,这是对你的代码的一点修改。

import maya.cmds as cmds
import re,sys,os
class assetBrowseTool(object):
    def __init__(self):
        if (cmds.window('assetBrowseWindow', q=True, ex=True)):
            cmds.deleteUI('assetBrowseWindow')
        assetWindow = cmds.window('assetBrowseWindow', title="xxxxxxx V1.0",s = False,widthHeight=(930, 530) )
        form = cmds.formLayout(numberOfDivisions=100, width=215, height=175) 
        frame = cmds.frameLayout('imageFrame', label='Assets', borderStyle='in',w = 500, h = 500 )
        scrollLay = cmds.scrollLayout("blaaa", horizontalScrollBarThickness=0, verticalScrollBarThickness=0, p =frame )  
        cmds.setParent( '..' )
        cmds.setParent( '..' )    
        tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        cmds.formLayout( form, edit=True, attachForm=[
        (tabs, 'top', 450), (tabs, 'left', 720), (tabs, 'bottom', 5), (tabs, 'right', 5),
        (tabs, 'right', 0),
        (frame,'left',5),(frame,'top',70),(frame,'bottom',5),(frame,'right',210)])
        child1 = cmds.rowColumnLayout(numberOfRows=1)
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.iconTextButton(l = '',w = 60,h = 40,style='iconOnly')
        cmds.setParent( '..' )
        child2 = cmds.rowColumnLayout(numberOfColumns=1)
        cmds.setParent( '..' )
        child3 = cmds.rowColumnLayout(numberOfColumns=1)
        cmds.setParent( '..' )
        cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'IMPORT'), (child2, 'PUBLISH'),(child3, 'EXPORT')) )
        cmds.showWindow( 'assetBrowseWindow' )

assetBrowseTool()