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
相关产品推荐
相关产品推荐

