CUSTOMGUI_PROGRESSBAR
-
On 02/02/2016 at 07:30, xxxxxxxx wrote:
How do I use the CUSTOMGUI_PROGRESSBAR.
I cannot find any examples?-Pim
-
On 02/02/2016 at 09:36, xxxxxxxx wrote:
Hi Pim,
The CUSTOMGUI_PROGRESSBAR is setup and updated using BFM_SETSTATUSBAR GUI message and its related BFM_STATUSBAR container options.
Here's a simple example:import c4d from c4d import gui class TestDialog(gui.GeDialog) : PROGRESSBAR = 1001 def __init__(self) : self.progress = 0 def StopProgress(self) : self.SetTimer(0) progressMsg = c4d.BaseContainer(c4d.BFM_SETSTATUSBAR) progressMsg.SetBool(c4d.BFM_STATUSBAR_PROGRESSON, False) self.SendMessage(self.PROGRESSBAR, progressMsg) def CreateLayout(self) : self.SetTitle("ProgressBar Example") self.GroupBegin(id=1000, flags=c4d.BFH_SCALEFIT|c4d.BFV_TOP, cols=0, rows=1) self.AddCustomGui(self.PROGRESSBAR, c4d.CUSTOMGUI_PROGRESSBAR, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0) self.GroupEnd() return True def InitValues(self) : self.SetTimer(1000) return True def Timer(self, msg) : self.progress += 1 progressMsg = c4d.BaseContainer(c4d.BFM_SETSTATUSBAR) progressMsg[c4d.BFM_STATUSBAR_PROGRESSON] = True progressMsg[c4d.BFM_STATUSBAR_PROGRESS] = self.progress/10.0 self.SendMessage(self.PROGRESSBAR, progressMsg) def Message(self, msg, result) : if msg.GetId() == c4d.BFM_TIMER_MESSAGE: if self.progress==10: self.StopProgress() self.Close() return True return gui.GeDialog.Message(self, msg, result) def AskClose(self) : self.StopProgress() return False if __name__=='__main__': dialog = TestDialog() dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=0, defaulth=400, defaultw=400)
A progress bar can also be added to a dialog within a status bar with GeDialog.ScrollGroupBegin().
-
On 02/02/2016 at 12:21, xxxxxxxx wrote:
Is there a speecial reason you use SubDialog as the parent class? Just interested.
-
On 03/02/2016 at 02:45, xxxxxxxx wrote:
Hi Niklas,
Oooops, I had not seen the dialog was declared as a SubDialog and not as a normal GeDialog.
I updated the code I posted as it was missing the last progress step and other minor things have been fixed (call SetTimer() in InitValues(), StopProgress() etc.)
-
On 05/02/2016 at 05:36, xxxxxxxx wrote:
Great, thank you.
-Pim