.. deprecated:: 1.10.0
The p3d packaging system has been replaced with the new setuptools-based
system. See the :ref:`distribution` manual section.
__all__ = ["DWBPackageInstaller"]
from direct.p3d.PackageInstaller import PackageInstaller
from direct.gui.DirectWaitBar import DirectWaitBar
from direct.gui import DirectGuiGlobals as DGG
[docs]class DWBPackageInstaller(DirectWaitBar, PackageInstaller):
""" This class presents a PackageInstaller that also inherits from
DirectWaitBar, so it updates its own GUI as it downloads.
Specify perPackage = True to make the progress bar reset for each
package, or False (the default) to show one continuous progress
bar for all packages.
Specify updateText = True (the default) to update the text label
with the name of the package or False to leave it up to you to set
You can specify a callback function with finished = func; this
function will be called, with one boolean parameter, when the
download has completed. The parameter will be true on success, or
false on failure.
[docs] def __init__(self, appRunner, parent = None, **kw):
optiondefs = (
('borderWidth', (0.01, 0.01), None),
('relief', DGG.SUNKEN, self.setRelief),
('range', 1, self.setRange),
('barBorderWidth', (0.01, 0.01), self.setBarBorderWidth),
('barColor', (0.424, 0.647, 0.878, 1), self.setBarColor),
('barRelief', DGG.RAISED, self.setBarRelief),
('text', 'Starting', self.setText),
('text_pos', (0, -0.025), None),
('text_scale', 0.1, None),
('perPackage', False, None),
('updateText', True, None),
('finished', None, None),
DirectWaitBar.__init__(self, parent, **kw)
# Hidden by default until the download begins.
[docs] def cleanup(self):
[docs] def destroy(self):
[docs] def packageStarted(self, package):
""" This callback is made for each package between
downloadStarted() and downloadFinished() to indicate the start
of a new package. """
self['text'] = 'Installing %s' % (package.getFormattedName())
[docs] def packageProgress(self, package, progress):
""" This callback is made repeatedly between packageStarted()
and packageFinished() to update the current progress on the
indicated package only. The progress value ranges from 0
(beginning) to 1 (complete). """
self['value'] = progress * self['range']
[docs] def downloadProgress(self, overallProgress):
""" This callback is made repeatedly between downloadStarted()
and downloadFinished() to update the current progress through
all packages. The progress value ranges from 0 (beginning) to
1 (complete). """
if not self['perPackage']:
self['value'] = overallProgress * self['range']
[docs] def downloadFinished(self, success):
""" This callback is made when all of the packages have been
downloaded and installed (or there has been some failure). If
all packages where successfully installed, success is True.
If there were no packages that required downloading, this
callback will be made immediately, *without* a corresponding
call to downloadStarted(). """