44hero-01
5/15/2020 - 7:14 AM

-cmds- <maya UI> paneLayout の基本

# -*- coding: utf-8 -*-

import maya.cmds as cmds
import maya.mel as mel
import maya.OpenMaya as om
from functools import partial
from maya.common.ui import LayoutManager


class UI(object):
    @classmethod
    def showUI(cls):
        """A function to instantiate the YO direct Connection  UI window
        :return: win
        """
        win = cls()
        win.createUI()
        # print(win)
        return win
 
    def classNameOutput(self):
        """
        :rtype: str
        :return: self.__class__.__name__
        """
        return self.__class__.__name__
 
    def __init__(self):
        """Initialize data attributes"""
        self.win = 'test_ui'
        self.title = 'test'
        self.bgcRed = [0.9, 0.5, 0.5]  # list of float
        self.bgcGreen = [0.5, 0.9, 0.5]  # list of float
        self.bgcBlue = [0.5, 0.5, 0.9]  # list of float
        self.bgcGray2 = [0.5, 0.5, 0.5]  # list of float
        self.srcNode = ''  # string
        self.tgtNode = ''  # string
        self.tXYZ = [0, 0, 0]  # list of bool
        self.rXYZ = [0, 0, 0]  # list of bool
        self.sXYZ = [0, 0, 0]  # list of bool
        self.shXYZ = [0, 0, 0]  # list of bool
        self.v = 0  # bool
        self.exeList = [0, 0, 0, 0, 0]  # list of bool
        self.resultMessageCommon = u' が互いに接続されています。'
        
    def createUI(self):
        u""" <UI の構築>
        """
        if cmds.window(self.win, ex = True):
            cmds.deleteUI(self.win)
        cmds.window(self.win, title = self.title
                    , widthHeight = (145, 60)
                    , menuBar = True
                    , sizeable = True
                    )
        
        self.cM_commonMenu()
        form = cmds.formLayout()
        tabs = cmds.tabLayout('mainTabGrp'
                            #, scrollable = True
                            , tabsVisible = False
                            , h = 1
                            , childResizable = True
                            )
        cmds.formLayout(form, edit=True
            , attachForm=((tabs, 'top', 0)
                        , (tabs, 'left', 0)
                        , (tabs, 'bottom', 0)
                        , (tabs, 'right', 0)
                        ) 
            )
        
        # child2
        with LayoutManager(cmds.paneLayout('panLyot_cP'
                                    , configuration = 'top3'  # top3 モード
                                    #, bgc = self.bgcRed
                                    , separatorThickness = 15
                                    # , activeFrameThickness = 100
                                    , highlightColor = [0.9, 0.5, 0.5]
                                    #, activePaneIndex = 0
                                    # , h = 10
                                    , staticHeightPane = 3  # pane3 の高さキープモード
                                    )
                                        ) as child2:
            # pane1
            cmds.textScrollList('panLyot_txtScll_L')
            # pane2
            cmds.textScrollList('panLyot_txtScll_R', w = 10)
            # pane3
            cmds.button('C')
            
                       
        #cmds.paneLayout('panLyot_cP', edit = True, activePane = 'panLyot_txtScll_R')
        
        cmds.evalDeferred(lambda *args: cmds.showWindow(self.win))
        
    # ######################################################################################
    # 0. 最上段の UI common menu ###################################################### start
    # 最上段の UI menu 作成に利用
    def cM_commonMenu(self):
        u""" <最上段の UI menu 作成に利用>
        """
        editMenu = cmds.menu(l = 'Edit')
        editMenuReload = cmds.menuItem(l = 'Reset Settings'
                                       , c = self.cB_uiReload_command, enable = True
                                       )
        editMenuClose = cmds.menuItem(l = 'Close This UI'
                                      , c = self.cB_uiClose_command, enable = True
                                      )
        helpMenu = cmds.menu(l = 'Help')
        helpMenuItem = cmds.menuItem(l = 'Help on %s' % self.title
                                     # , c = self.helpMenuCmd
                                     )

    # Reload 実行 関数
    def cB_uiReload_command(self, *args):
        u""" <Reload 実行 関数>
        """
        cmds.evalDeferred(lambda *args: self.showUI())  # refresh UI <---- ここ重要!!
        print('reload done')

    # Close 実行 関数
    def cB_uiClose_command(self, *args):
        u""" <Close 実行 関数>
        """
        cmds.evalDeferred(lambda *args: cmds.deleteUI(self.win))
        print('close done')
    # 0. 最上段の UI common menu ######################################################## end
    # ######################################################################################


if __name__ == '__main__':
    print(u'{}.py: loaded as script file'.format(__name__))
    UI.showUI()  # ui
else:
    print(u'{}.py: loaded as module file'.format(__name__))
 
print(u'モジュール名:{}'.format(__name__))  # 実行したモジュール名を表示する
# -*- coding: utf-8 -*-

import maya.cmds as cmds
import maya.mel as mel
import maya.OpenMaya as om
from functools import partial
from maya.common.ui import LayoutManager


class UI(object):
    @classmethod
    def showUI(cls):
        """A function to instantiate the YO direct Connection  UI window
        :return: win
        """
        win = cls()
        win.createUI()
        # print(win)
        return win
 
    def classNameOutput(self):
        """
        :rtype: str
        :return: self.__class__.__name__
        """
        return self.__class__.__name__
 
    def __init__(self):
        """Initialize data attributes"""
        self.win = 'test_ui'
        self.title = 'test'
        self.bgcRed = [0.9, 0.5, 0.5]  # list of float
        self.bgcGreen = [0.5, 0.9, 0.5]  # list of float
        self.bgcBlue = [0.5, 0.5, 0.9]  # list of float
        self.srcNode = ''  # string
        self.tgtNode = ''  # string
        self.tXYZ = [0, 0, 0]  # list of bool
        self.rXYZ = [0, 0, 0]  # list of bool
        self.sXYZ = [0, 0, 0]  # list of bool
        self.shXYZ = [0, 0, 0]  # list of bool
        self.v = 0  # bool
        self.exeList = [0, 0, 0, 0, 0]  # list of bool
        self.resultMessageCommon = u' が互いに接続されています。'
        
    def createUI(self):
        u""" <UI の構築>
        """
        if cmds.window(self.win, ex = True):
            cmds.deleteUI(self.win)
        cmds.window(self.win, title = self.title
                    , widthHeight = (145, 60)
                    , menuBar = True
                    , sizeable = True
                    )
        
        self.cM_commonMenu()
        form = cmds.formLayout()
        tabs = cmds.tabLayout('mainTabGrp'
                            #, scrollable = True
                            , tabsVisible = True
                            , h = 1
                            , childResizable = True
                            )
        cmds.formLayout(form, edit=True
            , attachForm=((tabs, 'top', 0)
                        , (tabs, 'left', 0)
                        , (tabs, 'bottom', 0)
                        , (tabs, 'right', 0)
                        ) 
            )
        
        # child1
        child1 = cmds.rowColumnLayout(numberOfColumns = 2)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        # child2
        with LayoutManager(cmds.columnLayout(
                                    adjustableColumn = True
                                    , bgc = self.bgcRed
                                    )
                                        ) as child2:
            with LayoutManager(cmds.columnLayout(
                                        adjustableColumn = True
                                        , bgc = self.bgcBlue
                                        )
                                            ):
                cmds.button()
            with LayoutManager(cmds.columnLayout(
                                        adjustableColumn = True
                                        , bgc = self.bgcGreen
                                        )
                                            ):
                cmds.button()
                with LayoutManager(cmds.columnLayout(adjustableColumn = True)):
                    with LayoutManager(cmds.paneLayout('panLyot_cP'
                                                , configuration = 'top3'  # top3 モード
                                                , bgc = self.bgcBlue
                                                # , activeFrameThickness = 100
                                                , highlightColor = [0.9, 0.5, 0.5]
                                                #, activePaneIndex = 0
                                                # , h = 10
                                                , staticHeightPane = 3  # pane3 の高さキープモード
                                                )
                                                    ):
                        # pane1
                        cmds.textScrollList('panLyot_txtScll_L')
                        # pane2
                        cmds.textScrollList('panLyot_txtScll_R', w = 10)
                        # pane3
                        cmds.button('C')
            
        # child3
        child3 = cmds.columnLayout(adjustableColumn = True, w= 10)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        cmds.tabLayout(tabs, edit = True
                , tabLabel =([child1, 'One'], [child2, 'Two'], [child3, 'Three'])
                , selectTabIndex = 2
               )
                       
        #cmds.paneLayout('panLyot_cP', edit = True, activePane = 'panLyot_txtScll_R')
        
        cmds.evalDeferred(lambda *args: cmds.showWindow(self.win))
        
    # ######################################################################################
    # 0. 最上段の UI common menu ###################################################### start
    # 最上段の UI menu 作成に利用
    def cM_commonMenu(self):
        u""" <最上段の UI menu 作成に利用>
        """
        editMenu = cmds.menu(l = 'Edit')
        editMenuReload = cmds.menuItem(l = 'Reset Settings'
                                       , c = self.cB_uiReload_command, enable = True
                                       )
        editMenuClose = cmds.menuItem(l = 'Close This UI'
                                      , c = self.cB_uiClose_command, enable = True
                                      )
        helpMenu = cmds.menu(l = 'Help')
        helpMenuItem = cmds.menuItem(l = 'Help on %s' % self.title
                                     # , c = self.helpMenuCmd
                                     )

    # Reload 実行 関数
    def cB_uiReload_command(self, *args):
        u""" <Reload 実行 関数>
        """
        cmds.evalDeferred(lambda *args: self.showUI())  # refresh UI <---- ここ重要!!
        print('reload done')

    # Close 実行 関数
    def cB_uiClose_command(self, *args):
        u""" <Close 実行 関数>
        """
        cmds.evalDeferred(lambda *args: cmds.deleteUI(self.win))
        print('close done')
    # 0. 最上段の UI common menu ######################################################## end
    # ######################################################################################


if __name__ == '__main__':
    print(u'{}.py: loaded as script file'.format(__name__))
    UI.showUI()  # ui
else:
    print(u'{}.py: loaded as module file'.format(__name__))
 
print(u'モジュール名:{}'.format(__name__))  # 実行したモジュール名を表示する
# -*- coding: utf-8 -*-

import maya.cmds as cmds
import maya.mel as mel
import maya.OpenMaya as om
from functools import partial
from maya.common.ui import LayoutManager


class UI(object):
    @classmethod
    def showUI(cls):
        """A function to instantiate the YO direct Connection  UI window
        :return: win
        """
        win = cls()
        win.createUI()
        # print(win)
        return win
 
    def classNameOutput(self):
        """
        :rtype: str
        :return: self.__class__.__name__
        """
        return self.__class__.__name__
 
    def __init__(self):
        """Initialize data attributes"""
        self.win = 'test_ui'
        self.title = 'test'
        self.bgcRed = [0.9, 0.5, 0.5]  # list of float
        self.bgcGreen = [0.5, 0.9, 0.5]  # list of float
        self.bgcBlue = [0.5, 0.5, 0.9]  # list of float
        self.srcNode = ''  # string
        self.tgtNode = ''  # string
        self.tXYZ = [0, 0, 0]  # list of bool
        self.rXYZ = [0, 0, 0]  # list of bool
        self.sXYZ = [0, 0, 0]  # list of bool
        self.shXYZ = [0, 0, 0]  # list of bool
        self.v = 0  # bool
        self.exeList = [0, 0, 0, 0, 0]  # list of bool
        self.resultMessageCommon = u' が互いに接続されています。'
        
    def createUI(self):
        u""" <UI の構築>
        """
        if cmds.window(self.win, ex = True):
            cmds.deleteUI(self.win)
        cmds.window(self.win, title = self.title
                    , widthHeight = (145, 60)
                    , menuBar = True
                    , sizeable = True
                    )
        
        self.cM_commonMenu()
        form = cmds.formLayout()
        tabs = cmds.tabLayout('mainTabGrp'
                            #, scrollable = True
                            , tabsVisible = True
                            , h = 1
                            , childResizable = True
                            )
        cmds.formLayout(form, edit=True
            , attachForm=((tabs, 'top', 0)
                        , (tabs, 'left', 0)
                        , (tabs, 'bottom', 0)
                        , (tabs, 'right', 0)
                        ) 
            )
        
        # child1
        child1 = cmds.rowColumnLayout(numberOfColumns = 2)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        # child2
        with LayoutManager(cmds.paneLayout('panLyot_cP'
                        , configuration = 'top3'  # top3 モード
                        # , activeFrameThickness = 100
                        , highlightColor = [0.9, 0.5, 0.5]
                        #, activePaneIndex = 0
                        # , h = 10
                        , staticHeightPane = 3  # pane3 の高さキープモード
                        )
                            ) as child2:
            # pane1
            with LayoutManager(cmds.columnLayout(
                                adjustableColumn = True
                                , columnAttach = ["both", 5]
                                #, columnAlign = "center"
                                # , columnWidth = 10
                                , w = 10
                                )
                                    ):

                # 1
                cmds.textScrollList('panLyot_txtScll_L'
                                # , h = 10
                                    )
                # 2
                with LayoutManager(cmds.columnLayout(
                                adjustableColumn = True
                                )
                                    ):
                    cmds.button('A')
                    cmds.button('B')
            # pane2
            with LayoutManager(cmds.columnLayout(
                                            adjustableColumn = True
                                            )
                                                ):
                cmds.textScrollList('panLyot_txtScll_R', w = 10)
            # pane3
            with LayoutManager(cmds.columnLayout(
                                adjustableColumn = True
                                )
                                    ):
                cmds.textScrollList('panLyot_txtScll_Z')
                cmds.button()
            
        # child3
        child3 = cmds.columnLayout(adjustableColumn = True, w= 10)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        cmds.tabLayout(tabs, edit = True
                        , tabLabel =([child1, 'One'], [child2, 'Two'], [child3, 'Three'])
                        , selectTabIndex = 2
                       )
                       
        cmds.textScrollList('panLyot_txtScll_R', e = True)
        #cmds.paneLayout('panLyot_cP', edit = True, activePane = 'panLyot_txtScll_R')
        
        cmds.evalDeferred(lambda *args: cmds.showWindow(self.win))
        
    # ######################################################################################
    # 0. 最上段の UI common menu ###################################################### start
    # 最上段の UI menu 作成に利用
    def cM_commonMenu(self):
        u""" <最上段の UI menu 作成に利用>
        """
        editMenu = cmds.menu(l = 'Edit')
        editMenuReload = cmds.menuItem(l = 'Reset Settings'
                                       , c = self.cB_uiReload_command, enable = True
                                       )
        editMenuClose = cmds.menuItem(l = 'Close This UI'
                                      , c = self.cB_uiClose_command, enable = True
                                      )
        helpMenu = cmds.menu(l = 'Help')
        helpMenuItem = cmds.menuItem(l = 'Help on %s' % self.title
                                     # , c = self.helpMenuCmd
                                     )

    # Reload 実行 関数
    def cB_uiReload_command(self, *args):
        u""" <Reload 実行 関数>
        """
        cmds.evalDeferred(lambda *args: self.showUI())  # refresh UI <---- ここ重要!!
        print('reload done')

    # Close 実行 関数
    def cB_uiClose_command(self, *args):
        u""" <Close 実行 関数>
        """
        cmds.evalDeferred(lambda *args: cmds.deleteUI(self.win))
        print('close done')
    # 0. 最上段の UI common menu ######################################################## end
    # ######################################################################################


if __name__ == '__main__':
    print(u'{}.py: loaded as script file'.format(__name__))
    UI.showUI()  # ui
else:
    print(u'{}.py: loaded as module file'.format(__name__))
 
print(u'モジュール名:{}'.format(__name__))  # 実行したモジュール名を表示する
# -*- coding: utf-8 -*-

import maya.cmds as cmds
import maya.mel as mel
import maya.OpenMaya as om
from functools import partial
from maya.common.ui import LayoutManager


class UI(object):
    @classmethod
    def showUI(cls):
        """A function to instantiate the YO direct Connection  UI window
        :return: win
        """
        win = cls()
        win.createUI()
        # print(win)
        return win
 
    def classNameOutput(self):
        """
        :rtype: str
        :return: self.__class__.__name__
        """
        return self.__class__.__name__
 
    def __init__(self):
        """Initialize data attributes"""
        self.win = 'test_ui'
        self.title = 'test'
        self.bgcRed = [0.9, 0.5, 0.5]  # list of float
        self.bgcGreen = [0.5, 0.9, 0.5]  # list of float
        self.bgcBlue = [0.5, 0.5, 0.9]  # list of float
        self.srcNode = ''  # string
        self.tgtNode = ''  # string
        self.tXYZ = [0, 0, 0]  # list of bool
        self.rXYZ = [0, 0, 0]  # list of bool
        self.sXYZ = [0, 0, 0]  # list of bool
        self.shXYZ = [0, 0, 0]  # list of bool
        self.v = 0  # bool
        self.exeList = [0, 0, 0, 0, 0]  # list of bool
        self.resultMessageCommon = u' が互いに接続されています。'
        
    def createUI(self):
        u""" <UI の構築>
        """
        if cmds.window(self.win, ex = True):
            cmds.deleteUI(self.win)
        cmds.window(self.win, title = self.title
                    , widthHeight = (145, 60)
                    , menuBar = True
                    , sizeable = True
                    )
        
        self.cM_commonMenu()
        form = cmds.formLayout()
        tabs = cmds.tabLayout('mainTabGrp'
                            #, scrollable = True
                            , tabsVisible = True
                            , h = 1
                            , childResizable = True
                            )
        cmds.formLayout(form, edit=True
            , attachForm=((tabs, 'top', 0)
                        , (tabs, 'left', 0)
                        , (tabs, 'bottom', 0)
                        , (tabs, 'right', 0)
                        ) 
            )
        
        # child1
        child1 = cmds.rowColumnLayout(numberOfColumns = 2)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        # child2
        with LayoutManager(cmds.columnLayout(
                                    adjustableColumn = True
                                    , bgc = self.bgcRed
                                    )
                                        ) as child2:
            with LayoutManager(cmds.columnLayout(
                                        adjustableColumn = True
                                        , bgc = self.bgcBlue
                                        )
                                            ):
                cmds.button()
            with LayoutManager(cmds.columnLayout(
                                        adjustableColumn = True
                                        , bgc = self.bgcGreen
                                        )
                                            ):
                cmds.button()
                with LayoutManager(cmds.columnLayout(adjustableColumn = True)):
                    with LayoutManager(cmds.paneLayout('panLyot_cP'
                                                , configuration = 'top3'  # top3 モード
                                                , bgc = self.bgcBlue
                                                # , activeFrameThickness = 100
                                                , highlightColor = [0.9, 0.5, 0.5]
                                                #, activePaneIndex = 0
                                                # , h = 10
                                                , staticHeightPane = 3  # pane3 の高さキープモード
                                                )
                                                    ):
                        # pane1
                        cmds.textScrollList('panLyot_txtScll_L')
                        # pane2
                        cmds.textScrollList('panLyot_txtScll_R', w = 10)
                        # pane3
                        cmds.button('C')
            
        # child3
        child3 = cmds.columnLayout(adjustableColumn = True, w= 10)
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.setParent( '..' )
        
        cmds.tabLayout(tabs, edit = True
                , tabLabel =([child1, 'One'], [child2, 'Two'], [child3, 'Three'])
                , selectTabIndex = 2
               )
                       
        #cmds.paneLayout('panLyot_cP', edit = True, activePane = 'panLyot_txtScll_R')
        
        cmds.evalDeferred(lambda *args: cmds.showWindow(self.win))
        
    # ######################################################################################
    # 0. 最上段の UI common menu ###################################################### start
    # 最上段の UI menu 作成に利用
    def cM_commonMenu(self):
        u""" <最上段の UI menu 作成に利用>
        """
        editMenu = cmds.menu(l = 'Edit')
        editMenuReload = cmds.menuItem(l = 'Reset Settings'
                                       , c = self.cB_uiReload_command, enable = True
                                       )
        editMenuClose = cmds.menuItem(l = 'Close This UI'
                                      , c = self.cB_uiClose_command, enable = True
                                      )
        helpMenu = cmds.menu(l = 'Help')
        helpMenuItem = cmds.menuItem(l = 'Help on %s' % self.title
                                     # , c = self.helpMenuCmd
                                     )

    # Reload 実行 関数
    def cB_uiReload_command(self, *args):
        u""" <Reload 実行 関数>
        """
        cmds.evalDeferred(lambda *args: self.showUI())  # refresh UI <---- ここ重要!!
        print('reload done')

    # Close 実行 関数
    def cB_uiClose_command(self, *args):
        u""" <Close 実行 関数>
        """
        cmds.evalDeferred(lambda *args: cmds.deleteUI(self.win))
        print('close done')
    # 0. 最上段の UI common menu ######################################################## end
    # ######################################################################################


if __name__ == '__main__':
    print(u'{}.py: loaded as script file'.format(__name__))
    UI.showUI()  # ui
else:
    print(u'{}.py: loaded as module file'.format(__name__))
 
print(u'モジュール名:{}'.format(__name__))  # 実行したモジュール名を表示する