Set interactive to True for interactive backends. enable_gui_function - Function which enables gui, should be run in the main thread.
(enable_gui_function)
| 126 | |
| 127 | |
| 128 | def activate_matplotlib(enable_gui_function): |
| 129 | """Set interactive to True for interactive backends. |
| 130 | enable_gui_function - Function which enables gui, should be run in the main thread. |
| 131 | """ |
| 132 | matplotlib = sys.modules["matplotlib"] |
| 133 | gui, backend = find_gui_and_backend() |
| 134 | is_interactive = is_interactive_backend(backend) |
| 135 | if is_interactive: |
| 136 | enable_gui_function(gui) |
| 137 | if not matplotlib.is_interactive(): |
| 138 | sys.stdout.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) |
| 139 | matplotlib.interactive(True) |
| 140 | else: |
| 141 | if matplotlib.is_interactive(): |
| 142 | sys.stdout.write("Backend %s is non-interactive backend. Turning interactive mode off.\n" % backend) |
| 143 | matplotlib.interactive(False) |
| 144 | patch_use(enable_gui_function) |
| 145 | patch_is_interactive() |
| 146 | |
| 147 | |
| 148 | def flag_calls(func): |
no test coverage detected