python - 在 Maya Python 中刷新选择选项卡
问题描述
我有一个tablayout
Maya Python。每次浏览选项卡时,我都会尝试显示一个随机数。在下面我没有得到如何刷新选项卡
import maya.cmds as cmds
cmds.window( widthHeight=(200, 150) )
form = cmds.formLayout()
tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
cmds.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)) )
child1 = cmds.rowColumnLayout(numberOfColumns=2)
num1 = random.randint(1,100001)
cmds.text(num1)
cmds.setParent( '..' )
child2 = cmds.rowColumnLayout(numberOfColumns=2)
num2 = random.randint(1,100001)
cmds.text(num2)
cmds.setParent( '..' )
cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'One'), (child2, 'Two')) )
cmds.showWindow()
解决方案
我已经修改了您的代码以使其正常工作:
import random
import maya.cmds as cmds
cmds.window(widthHeight=(200, 150))
form = cmds.formLayout()
tabs = cmds.tabLayout(
innerMarginWidth=5,
innerMarginHeight=5)
cmds.formLayout(
form,
edit=True,
attachForm=(
(tabs, 'top', 0),
(tabs, 'left', 0),
(tabs, 'bottom', 0),
(tabs, 'right', 0)))
child1 = cmds.rowColumnLayout(numberOfColumns=2)
num1 = random.randint(1, 100001)
# Save the full path name to the control
text1 = cmds.text(label=num1)
cmds.setParent('..')
child2 = cmds.rowColumnLayout(numberOfColumns=2)
num2 = random.randint(1, 100001)
# Save the full path name to the control
text2 = cmds.text(label=num2)
cmds.setParent('..')
cmds.tabLayout(
tabs,
edit=True,
tabLabel=(
(child1, 'One'),
(child2, 'Two')))
cmds.showWindow()
def changer():
cmds.text(text1, edit=True, label=random.randint(1,100001))
cmds.text(text2, edit=True, label=random.randint(1,100001))
cmds.tabLayout(
tabs,
edit=True,
changeCommand=changer)
推荐阅读
- jquery - jQuery在之后插入文本
- python - 在python中读取文本文件
- python - 使用 python 3.4 烧瓶应用程序的天蓝色部署错误
- vba - 在 VBScript 文件中集成 VBA
- java - Listview自定义适配器上的SetBackgroundResource出现错误
- c# - .NET 任务的性能指标/诊断
- data-visualization - 如何在敏锐的 IO 中创建具有多个 y 轴的图形
- python - 源代码是 Python 中的输出
- ms-access - 你如何让选项组单选按钮作为一个组工作(单击一个排除另一个)?
- filter - 过滤后的剑道网格过滤器编号格式