I ziped because it contains 2 images in the folder 'res' of the plugin location:
*I think that just finding a way to update the interface like when the console prints each print in a While loop like it behaves in R18 it can be the same solution for this problem
Link:
https://www.sendspace.com/file/6g8hwt
import c4d, os
from c4d import gui, documents
from c4d import utils
from c4d import plugins
PLUGIN_ID=1029596
#Welcome to the world of Python
class MiDialogo(c4d.gui.GeDialog):
dir, file = os.path.split(__file__) # Gets the plugin's directory
images_Path = os.path.join(dir, 'res') # Adds the res folder to the path
image1 = os.path.join(images_Path, 'image1.jpg')
image2 = os.path.join(images_Path, 'image2.jpg')
def CreateLayout(self):
bc = c4d.BaseContainer() # Create a new container to store the button image
bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
self.AddStaticText(241798101, c4d.BFH_CENTER, 0, 0, name='Change bitmap first, run more code, then change again')
self.btnImage = self.AddCustomGui(241798100, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_CENTER, 60, 70, bc)
self.AddButton(241798102, c4d.BFH_CENTER, initw=150, inith=20, name="Test")
self.btnImage.SetImage(self.image1, True)
return True
def testCode(self):
i = 1
while i < 6000:
print(i)
c4d.EventAdd()
i += 1
def Command(self, id, msg):
if id == 241798102:
#Change bitmap first, then run code, then change bitmap again
self.btnImage.SetImage(self.image2, True) #Change image first
self.testCode() # Sample test code
#gui.MessageDialog('Here a code instead of a popup', c4d.GEMB_OK)
self.btnImage.SetImage(self.image1, True) #Change image again
return True
class MyMenuPlugin(c4d.plugins.CommandData):
dialog = None
def Execute(self, doc):
# create the dialog
if self.dialog is None:
self.dialog = MiDialogo()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
def RestoreLayout(self, sec_ref):
# manage the dialog
if self.dialog is None:
self.dialog = MiDialogo()
return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
if __name__=='__main__':
okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Change bitmap test",0,None, "Change bitmap test", MyMenuPlugin())
if (okyn):
print "Change bitmap test"