def updateProgressGui(blocknum, blocksize, size, prog):
    """
    Callback function for the FTP progress dialog.
    Usage: updateProgressGui(blocknum, blocksize, size, prog)
    <blocknum> is the 0-origin block number
    just read. <blocksize> is in bytes. <size> is the file size in bytes.
    <prog> is the progress dialog.

    Return: 0 to signal that a cancel has been received, 1 to continue reading.
    """
    sizekb = size / 1024
    percent = min(100, int(100.0 * float(blocknum * blocksize) / float(size)))
    if percent < 100:
        noInterrupt = prog.Update(
            percent, "Read: %3d%% of %dK" %
            (percent, sizekb))
    else:
        noInterrupt = 1                    # Don't interrupt - finish up cleanly
        prog.Destroy()
    if noInterrupt == 0:
        prog.Destroy()
    return noInterrupt