lundi 13 juin 2016

Maya UI - A master in every Tab

I have created a UI in python for Maya, and I'm using tabLayout to have many rowColumnLayout (Tabs) in my user interface. In each Tab I want the top part to have a Master that will be the same for every Tab, but without having duplicate instances for each tab because it won't update properly. By that I mean that when I change something in one Tab it won't update in the other tabs.

Here is a simplified example of my problem, I'm using a function MasterTab in each Tab :

import maya.cmds as cmds

def ChangeText(*arg) : cmds.text('thatText', edit=True, label='Bye')
def MasterTab(*arg) : 
    cmds.button(label='Press Me', command = ChangeText)
    cmds.text('thatText', label='Hello')

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)
# Part I want in every tab
MasterTab()
# Tab One
cmds.text(label='text of tab One', h=50, align='left')
cmds.setParent( '..' )

child2 = cmds.rowColumnLayout(numberOfColumns=2)
# Part I want in every tab
MasterTab()
# Tab Two
cmds.text(label='text of tab Two', h=50, align='left')
cmds.setParent( '..' )

cmds.tabLayout( tabs, edit=True, tabLabel=((child1, 'One'), (child2, 'Two')) )

cmds.showWindow()

When I press the button the text showing 'Hello' will only change to 'Bye' in the second Tab for some reason. So if I can't just call my MasterTab function in every Tab, would there be a way to call it only once and it would attach in every tab ? Or if there is another way I'm open to suggestions.

Thank you for your help !

Aucun commentaire:

Enregistrer un commentaire