xdev.interactive_iter module¶
A simple way to interactively control the iteratin of a loop. Useful for viewing multiple things sequentially.
- class xdev.interactive_iter.InteractiveIter(iterable=None, enabled=True, startx=0, default_action='next', custom_actions=[], wraparound=False, display_item=False, verbose=True)[source]¶
Bases:
object
Choose next value interactively
iterable should be a list, not a generator. sorry
CommandLine
xdoctest -m xdev.interactive_iter InteractiveIter:0 --interact xdoctest -m xdev.interactive_iter InteractiveIter:1 --interact
Example
>>> # xdoctest: +REQUIRES(--interact) >>> from xdev.interactive_iter import * # NOQA >>> iterable = [1, 2, 3] >>> enabled = True >>> startx = 0 >>> default_action = 'next' >>> custom_actions = [] >>> wraparound = False >>> display_item = True >>> verbose = True >>> iiter = InteractiveIter(iterable, enabled, startx, default_action, custom_actions, wraparound, display_item, verbose) >>> for _ in iiter: >>> pass
Example
>>> # xdoctest: +REQUIRES(--interact) >>> # Interactive matplotlib stuff >>> from xdev.interactive_iter import * # NOQA >>> import kwimage >>> import kwplot >>> plt = kwplot.autoplt(verbose=3, force='Qt5Agg') >>> plt.ion() >>> keys = list(kwimage.grab_test_image.keys()) >>> iterable = [kwimage.grab_test_image(key) for key in keys] >>> iiter = InteractiveIter(iterable) >>> for img in iiter: >>> kwplot.imshow(img) >>> InteractiveIter.draw()
- Parameters:
iterable (None) – (default = None)
enabled (bool) – (default = True)
startx (int) – (default = 0)
default_action (str) – (default = ‘next’)
custom_actions (list) – list of 4-tuple (name, actions, help, func) (default = [])
wraparound (bool) – (default = False)
display_item (bool) – (default = True)
verbose (bool) – verbosity flag(default = True)