Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

CUSTOMGUI_PROGRESSBAR

Author
Message Reverse Sort Order
  Topic Search Topic Search
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 817
Direct Link To This Post Topic: CUSTOMGUI_PROGRESSBAR
    Posted: 2016 Feb 05 at 5:36am
Great, thank you.

-Pim
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1143
Direct Link To This Post Posted: 2016 Feb 03 at 2:45am
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.)




Edited by Yannick Puech - 2016 Feb 03 at 2:45am
MAXON
Developer Support
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2016 Feb 02 at 12:21pm
Is there a speecial reason you use SubDialog as the parent class? Just interested.

Edited by NiklasR - 2016 Feb 02 at 12:23pm
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1143
Direct Link To This Post Posted: 2016 Feb 02 at 9:36am
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().




Edited by Yannick Puech - 2016 Feb 03 at 2:43am
MAXON
Developer Support
Back to Top
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 817
Direct Link To This Post Posted: 2016 Feb 02 at 7:30am
How do I use the CUSTOMGUI_PROGRESSBAR.
I cannot find any examples?

-Pim
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.