44hero-01
11/14/2019 - 6:43 AM

<maya UI> easy win build

import maya.cmds as cmds
from functools import partial

def Cmd1( *args):
    print(args)

if cmds.window(win, exists=True):
    cmds.deleteUI(win, window=True)
    

win = cmds.window('test_Window', title='TEST WINDOW',widthHeight=(600,350))
mainForm = cmds.formLayout( numberOfDivisions=100 )

b1 = cmds.button( label='Command 1', height=26, command=partial(Cmd1, 'A', 'B', 'C') )
b2 = cmds.button( label='Command 2', height=26, command=partial(Cmd1, 'D', 'E', 'F') )
b3 = cmds.button( label='Command 3', height=26, command=partial(Cmd1, 'G', 'H', 'I') )

cmds.formLayout(
            mainForm, edit=True, 
            #フォームの境界にボタンのどのエッジを固定するかの指定。オフセット値を5としている。
            attachForm = ( [ b1, 'left', 5 ], 
                           [ b1, 'bottom', 5 ], 
                           [ b2, 'bottom', 5 ], 
                           [ b3, 'bottom', 5 ], 
                           [ b3, 'right', 5 ]), 
            #ボタンをフォームのどの位置に固定するかの指定。b1の右辺を33%の位置に、b3の左辺を67%の位置に。
            attachPosition = ( [ b1, 'right' , 0, 33], 
                               [ b3, 'left' , 0, 67] ), 
            #真ん中のボタンb2が左右のボタンの隣接する辺に固定ための設定。
            attachControl = ( [ b2, 'left', 4,  b1 ], 
                              [ b2, 'right', 4, b3 ] ),
            #すべてのボタンの上辺は固定しない。
            attachNone = ( [ b1, 'top' ], [ b2, 'top' ], [ b3, 'top' ] )
            )

cmds.showWindow(win)
import maya.cmds as cmds

win = 'import_warningWin'

def import_warningWin_create():
    global win
    # button label name 更新用 の新規 UI: textField 内で enter を押すと、自動で close する UI 作成
    if cmds.window(win, ex = True):
        cmds.deleteUI(win)
    win = cmds.window(win, title = 'import_warning_ui'
                      , sizeable = False
                      , widthHeight = [331, 116]
                      )
    mainForm = cmds.formLayout(nd = 100)  # メインのまとまり
    clmLyut = cmds.columnLayout(adjustableColumn = True)
    cmds.text(l = u'<注意>\n'
                  u'import するにあたり\n'
                  u'現在登録表示されている情報を、一旦空にして import します。\n'
                  u'よろしいですか?'
              , align = 'center'
              )
    cmds.setParent('..')
    b1 = cmds.button(l = u'はい'
                     #, c = import_fileDialog
                     )
    b3 = cmds.button(l = u'いいえ'
                     , c = 'cmds.deleteUI(\"' + win + '\", window = True)'
                     )
    cmds.formLayout(mainForm, e = True
                    # フォームの境界にボタンのどのエッジを固定するかの指定。オフセット値を5としている。
                    , attachForm = ([b1, 'left', 5], [b1, 'bottom', 5]
                                    , [b3, 'bottom', 5], [b3, 'right',5]
                                    )
                    # ボタンをフォームのどの位置に固定するかの指定。b1の右辺を49%の位置に、b3の左辺を51%の位置に。
                    , attachPosition = ([b1, 'right', 0, 49], [b3, 'left', 0, 51]
                                        , [clmLyut, 'right', 0, 100]
                                        , [clmLyut, 'left', 0, 0]
                                        , [clmLyut, 'top', 0, 5])
                    # すべてのボタンの上辺は固定しない。
                    , attachNone = ([b1, 'top'], [b3, 'top'])
                    # 第1引数コントロールの、第2引数エッジを、第4引数コントロールにアタッチする。
                    , attachControl = [clmLyut, 'bottom', 5, b3]
                    )
    cmds.showWindow(win)
import_warningWin_create()

########################################################
import maya.cmds as cmds
from maya.common.ui import LayoutManager

win = 'import_warningWin'

def import_warningWin_create():
    global win
    # button label name 更新用 の新規 UI: textField 内で enter を押すと、自動で close する UI 作成
    if cmds.window(win, ex = True):
        cmds.deleteUI(win)
    win = cmds.window(win, title = 'import_warning_ui'
                      , sizeable = True
                      , widthHeight = [331, 116]
                      )
    mainForm = cmds.formLayout(nd = 100)  # メインのまとまり
    with LayoutManager(cmds.columnLayout('clmLyut'
                , adjustableColumn = True
                , bgc = [10, 10., 10])
              ) as clmLyut:
        cmds.text(l = u'<注意>\n'
                      u'import するにあたり\n'
                      u'現在登録表示されている情報を、一旦空にして import します。\n'
                      u'よろしいですか?'
                  , align = 'center'
                  )
        cmds.button()
        cmds.button()
        cmds.button()
        cmds.button()
        b4 = cmds.button()
    b1 = cmds.button(l = u'はい'
                     #, c = import_fileDialog
                     )
    b3 = cmds.button(l = u'いいえ'
                     , c = 'cmds.deleteUI(\"' + win + '\", window = True)'
                     )
    cmds.formLayout(mainForm, e = True
                    # フォームの境界にボタンのどのエッジを固定するかの指定。オフセット値を5としている。
                    , attachForm = ([b1, 'left', 5], [b1, 'bottom', 5]
                                    , [b3, 'bottom', 5], [b3, 'right',5]
                                    )
                    # ボタンをフォームのどの位置に固定するかの指定。b1の右辺を49%の位置に、b3の左辺を51%の位置に。
                    , attachPosition = ([b1, 'right', 0, 49], [b3, 'left', 0, 51]
                                        , [clmLyut, 'right', 0, 100]
                                        , [clmLyut, 'left', 0, 0]
                                        , [clmLyut, 'top', 0, 5])
                    # すべてのボタンの上辺は固定しない。
                    , attachNone = ([b1, 'top'], [b3, 'top'])
                    # 第1引数コントロールの、第2引数エッジを、第4引数コントロールにアタッチする。
                    , attachControl = ([clmLyut, 'bottom', 5, b3]
                                       #, [clmLyut, 'bottom', 5, b4]
                                       )
                    )
    cmds.showWindow(win)
import_warningWin_create()
import maya.cmds as cmds
from functools import partial
 
def Cmd1( *args):
    print(args)
 
def createUI():
    win = 'test_Window'
    if cmds.window(win, exists=True):
        cmds.deleteUI(win, window=True)
        
     
    win = cmds.window('test_Window', title='TEST WINDOW',widthHeight=(600,350)
    #, resizeToFitChildren = True
    )
    
    cmds.columnLayout(adjustableColumn = True)
    cmds.text(l = u'************************************')
    cmds.setParent('..')
    
    cmds.columnLayout(adjustableColumn = True)
    cmds.text(l = u'************************************')
    cmds.setParent('..')
    
    mainForm = cmds.formLayout( numberOfDivisions=100 )
    
    b1 = cmds.button( label='Command 1', height=26, command=partial(Cmd1, 'A', 'B', 'C') )
    b2 = cmds.button( label='Command 2', height=26, command=partial(Cmd1, 'D', 'E', 'F') )
    b3 = cmds.button( label='Command 3', height=26, command=partial(Cmd1, 'G', 'H', 'I') )

    cmds.formLayout(
                mainForm, edit=True, \
                #フォームの境界にボタンのどのエッジを固定するかの指定。オフセット値を5としている。
                attachForm = ( [ b1, 'left', 5 ], 
                               [ b1, 'bottom', 5 ], 
                               [ b2, 'bottom', 5 ], 
                               [ b3, 'bottom', 5 ], 
                               [ b3, 'right', 5 ]), 
                #ボタンをフォームのどの位置に固定するかの指定。b1の右辺を33%の位置に、b3の左辺を67%の位置に。
                attachPosition = ( [ b1, 'right' , 0, 33], 
                                   [ b3, 'left' , 0, 67] ), 
                #真ん中のボタンb2が左右のボタンの隣接する辺に固定ための設定。
                attachControl = ( [ b2, 'left', 4,  b1 ], 
                                  [ b2, 'right', 4, b3 ] ),
                #すべてのボタンの上辺は固定しない。
                attachNone = ( [ b1, 'top' ], [ b2, 'top' ], [ b3, 'top' ] )
                )

    cmds.showWindow(win)
    
createUI()