You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maya中tabLayout控件的closeTab标志无法实际关闭标签页的问题求助

Maya中tabLayout控件的closeTab标志无法实际关闭标签页的问题求助

各位好,我最近在Maya 2025里用Python开发带标签页的工具时遇到了个头疼的问题,想请教下大家。

简单说就是:我没法让Maya tabLayout 的closeTab标志真正关闭指定的标签页。因为我需要在标签关闭时执行自定义函数(把关闭的标签从存储状态的节点中移除,这样工具重启后能记住之前打开的标签),所以不能用默认的关闭方式。

详细情况是这样的:我用closeTabCommand绑定了自定义的关闭函数,这部分我之前用过类似的Maya命令标志,本来以为没问题。结果现在点击标签的关闭按钮时,只会运行我写的脚本,标签本身并不会关闭。于是我试着在自定义函数里加上closeTab命令,但它完全没起作用。

下面是我当前的关闭标签的函数代码:

def close_tab(self, layout):
    """ Closes the current tab. """
    #List all tabs, get the selected tab, get the selected tab's index.
    allTabs = mc.tabLayout(layout, q=True, childArray=True)
    selectedTab = mc.tabLayout(layout, q=True, selectTab=True)
    tabIndex = allTabs.index(selectedTab)
    print(f"{allTabs=}, {selectedTab=}, {tabIndex=}")
    mc.tabLayout(layout, e=True, closeTab=tabIndex)

我已经确认print输出的索引是正确的,但调用closeTab后标签就是纹丝不动。有没有朋友遇到过类似的情况?或者知道我哪里写错了吗?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 06:39:50