apt.progress.gtk2 — Progress reporting for GTK+ interfaces

The apt.progress.gtk2 module provides classes with GObject signals and a class with a GTK+ widget for progress handling.

GObject progress classes

class apt.progress.gtk2.GInstallProgress

An implementation of apt.progress.base.InstallProgress supporting GObject signals. The class emits the following signals:

status-changed(status: str, percent: int)

Emitted when the status of an operation changed.

status-started()

Emitted when the installation started.

status-finished()

Emitted when the installation finished.

status-timeout()

Emitted when a timeout happens

status-error()

Emitted in case of an error.

status-conffile()

Emitted when a conffile update is happening.

class apt.progress.gtk2.GAcquireProgress

An implementation of apt.progress.base.AcquireProgress supporting GObject signals. The class emits the following signals:

status-changed(description: str, percent: int)

Emitted when the status of the fetcher changed, e.g. when the percentage increased.

status-started()

Emitted when the fetcher starts to fetch.

status-finished()

Emitted when the fetcher finished.

class apt.progress.gtk2.GDpkgInstallProgress

An implementation of apt.progress.base.InstallProgress supporting GObject signals. This is the same as GInstallProgress and is thus completely deprecated.

class apt.progress.gtk2.GOpProgress

An implementation of apt.progress.old.FetchProgress supporting GObject signals. The class emits the following signals:

status-changed(operation: str, percent: int)

Emitted when the status of an operation changed.

status-started()

Emitted when it starts - Not implemented yet.

status-finished()

Emitted when all operations have finished.

GTK+ Widget

class apt.progress.gtk2.GtkAptProgress

Graphical progress for installation/fetch/operations, providing a progress bar, a terminal and a status bar for showing the progress of package manipulation tasks.

cancel_download()

Cancel a currently running download.

clear()

Reset all status information.

dpkg_install

Return the install progress handler for dpkg.

fetch

Return the fetch progress handler.

hide_terminal()

Hide the expander with the terminal widget.

install

Return the install progress handler.

open

Return the cache opening progress handler.

show()

Show the Box

show_terminal(expanded=False)

Show an expander with a terminal widget which provides a way to interact with dpkg.

Example

#!/usr/bin/python
"""Example for gtk widgets"""
import pygtk
pygtk.require("2.0")
import gtk

import apt.progress.gtk2


def main():
    """Main function."""
    win = gtk.Window()
    win.connect("destroy", gtk.main_quit)
    progress = apt.progress.gtk2.GtkAptProgress()
    win.set_title("GtkAptProgress Demo")
    win.add(progress)
    progress.show()
    win.show()
    cache = apt.cache.Cache(progress.open)
    if cache["xterm"].is_installed:
        cache["xterm"].mark_delete()
    else:
        cache["xterm"].mark_install()
    progress.show_terminal(expanded=True)
    cache.commit(progress.fetch, progress.install)
    gtk.main()

if __name__ == "__main__":
    main()