もうちょっとスッキリさせるプロンプト考えなば
import maya.cmds as cmds
class MyToolUI(object):
def __init__(self):
self.window = "myToolUIWindow"
self.title = "My Tool"
self.size = (400, 700)
if cmds.window(self.window, exists=True):
cmds.deleteUI(self.window, window=True)
self.window = cmds.window(self.window, title=self.title, widthHeight=self.size)
self.main_layout = cmds.columnLayout(adjustableColumn=True)
# メイングループボックス
self.main_groupbox = self.create_main_groupbox()
# TextEdit ウィジェット
cmds.text(label="TextEdit:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.textedit = cmds.scrollField(editable=True, wordWrap=True, height=100)
# タブウィジェット
cmds.text(label="TabWidget:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.tabwidget = self.create_tabwidget()
# 追加のグループボックス
self.groupbox1 = self.create_groupbox("Group Box 1", "Group1Button", self.on_groupbox1_button_click)
self.groupbox2 = self.create_groupbox("Group Box 2", "Group2Button", self.on_groupbox2_button_click)
cmds.showWindow(self.window)
def create_main_groupbox(self):
cmds.frameLayout(label="Main Controls", collapsable=True, borderStyle="etchedIn", width=self.size[0])
cmds.columnLayout(adjustableColumn=True)
self.checkbox = cmds.checkBox(label="Enable Option", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
cmds.text(label="Radio Buttons:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.radio_collection = cmds.radioCollection()
self.radio1 = cmds.radioButton(label="Option 1")
self.radio2 = cmds.radioButton(label="Option 2")
cmds.text(label="Combobox:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.combobox = cmds.optionMenu()
for item in ["Item 1", "Item 2", "Item 3"]:
cmds.menuItem(label=item)
cmds.text(label="LineEdit:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.lineedit = cmds.textField()
cmds.text(label="SpinBox:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.spinbox = cmds.intField()
cmds.text(label="Slider:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.slider = cmds.intSlider(min=0, max=100, value=50)
cmds.text(label="FloatSlider:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.fslider = cmds.floatSlider(min=0.0, max=1.0, value=0.5)
cmds.text(label="ColorSlider:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.color_slider = cmds.colorSliderGrp(label="")
cmds.text(label="CheckBoxGroup:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.checkbox_group = [cmds.checkBox(label=f"CheckBox {i}") for i in range(1, 4)]
cmds.text(label="RadioButtonGroup:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.radio_group = cmds.radioCollection()
self.radio_button1 = cmds.radioButton(label="Radio 1")
self.radio_button2 = cmds.radioButton(label="Radio 2")
cmds.text(label="OptionMenuGrp:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.option_menu_grp = cmds.optionMenuGrp(label="Options")
for item in ["Option 1", "Option 2", "Option 3"]:
cmds.menuItem(label=item)
cmds.text(label="TextScrollList:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.text_scroll_list = cmds.textScrollList(append=["Item 1", "Item 2", "Item 3"], allowMultiSelection=True)
cmds.text(label="Separator:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
cmds.separator(height=20, style="in")
cmds.text(label="IconTextButton:", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
self.icon_text_button = cmds.iconTextButton(style="iconOnly", image1="commandButton.png", label="Icon")
cmds.setParent('..')
cmds.setParent('..')
def create_tabwidget(self):
tab_layout = cmds.tabLayout()
# Tab 1
tab1_layout = cmds.columnLayout(adjustableColumn=True)
cmds.button(label="Click Me", command=self.on_tab1_button_click, bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
cmds.setParent('..')
cmds.tabLayout(tab_layout, edit=True, tabLabel=(tab1_layout, "Tab 1"))
# Tab 2
tab2_layout = cmds.columnLayout(adjustableColumn=True)
cmds.checkBox(label="Tab 2 Option", bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
cmds.setParent('..')
cmds.tabLayout(tab_layout, edit=True, tabLabel=(tab2_layout, "Tab 2"))
cmds.setParent('..')
return tab_layout
def create_groupbox(self, title, button_name, button_command):
cmds.frameLayout(label=title, collapsable=True, borderStyle="etchedIn", width=self.size[0])
cmds.columnLayout(adjustableColumn=True)
cmds.button(label=button_name, command=button_command, bgc=(0.149, 0.427, 0.482)) # 背景色を #256d7b に設定
cmds.setParent('..')
cmds.setParent('..')
def on_tab1_button_click(self, *args):
cmds.warning("Tab 1 Button clicked!")
def on_groupbox1_button_click(self, *args):
cmds.warning("Group Box 1 Button clicked!")
def on_groupbox2_button_click(self, *args):
cmds.warning("Group Box 2 Button clicked!")
# UIを表示
if __name__ == "__main__":
MyToolUI()