I need to add a lot of images(iconTextButton) to a gridLayout.
At this time it takes to long for the user to wait till all images are loaded.
I want to add them while the user can interact with the layout.
How to achieve this kind of dynamic loading?
import maya.cmds as mc
import time
class dynamicLoad():
def __init__(self):
#-- Window
self.window_name = 'win'
if (mc.window(self.window_name, exists=True)):
mc.deleteUI(self.window_name)
self.window = mc.window(self.window_name)
#-- Layout
layout = mc.formLayout(w=200)
self.gridview = mc.gridLayout(
numberOfColumns=4,
cellWidthHeight=(50, 50),
allowEmptyCells=False,
autoGrow=True,
)
mc.showWindow( self.window_name )
#-- Load buttons
self.create_buttons()
def create_buttons(self):
for i in range(5):
self.load_button()
def load_button(self):
time.sleep(1) #-- Fake loading time
mc.setParent( self.gridview )
mc.iconTextButton( style='iconAndTextVertical', label='test')
dynamicLoad()