def toggle_flag_pixel():
    """Adds the image and the current mouse position to a map of
    image-to-pixel. Indicates this with the set_point_overlay-function.

    If the mouse position is already flagged for the image, the flag
    is removed instead.

    The flagging can be used for to re-anchor images with anchor_flagged.

    """
    image = ifaint.get_active_image()
    pos = ifaint.get_mouse_pos()
    if image in _flagged and _flagged[image] == pos:
        del _flagged[image]
        image.clear_point_overlay()
    else:
        _flagged[image] = pos
        image.set_point_overlay(*pos)
def _pick_pattern_fg():
    pattern = ifaint.Pattern(ifaint.get_mouse_pos(),
                             ifaint.get_active_image().get_bitmap())
    pattern.set_object_aligned(True)
    ifaint.set_fg(pattern)
def pick_color_fg():
    try:
        ifaint.set_fg(ifaint.get_paint(*ifaint.get_mouse_pos()))
    finally:
        return