swingutils.binding

This module lets you automatically synchronize properties between two objects.

Some UI components require special handling to get them to behave as expected, and this is provided by a collection of adapters. Adapters are used automatically when a matching object is encountered.

class swingutils.binding.Binding(source, sourceExpression, target, targetExpression, **options)

Holds two expressions – target and source, and manages synchronization between them.

bind()

Causes event listeners to be added in source and target expression as dictated by the current synchronization mode. Releases any existing event listeners first to ensure that they aren’t added twice.

dump(indent=0, outfile=None)

Prints the source code of source and target expressions plus their binding chains to the standard output or outfile if one was provided.

sync(reverse=False)

Evalutes the source expression and copies the result to the location pointed the target expression. Synchronizing in either direction will not trigger any further automatic synchronizations within the same binding.

unbind()

Releases all event listeners from both source and target expressions.

class swingutils.binding.BindingGroup(**options)

Binding groups are containers for a number of Bindings. Each group provides default options for any bindings created through it, and allow synchronizing all bindings in them at once.

bind(source, source_expr, target, target_expr, **options)

Binds the source object to the target object using binding expressions.

Return type:Binding
dump(indent=0, outfile=None)

Prints the source code of source and target expressions plus their binding chains for every binding in this group to the standard output, or outfile if one was provided.

sync(reverse=False)

Synchronizes all bindings in this group.

Parameters:reverseTrue to synchronize targets to sources, False to synchronize sources to targets
unbind()

Releases all event listeners from all bindings in this group.