(self)
| 1671 | self.activate_gui_function = enable_gui |
| 1672 | |
| 1673 | def _activate_gui_if_needed(self): |
| 1674 | if self.gui_in_use: |
| 1675 | return |
| 1676 | |
| 1677 | if len(self.mpl_modules_for_patching) > 0: |
| 1678 | if is_current_thread_main_thread(): # Note that we call only in the main thread. |
| 1679 | for module in list(self.mpl_modules_for_patching): |
| 1680 | if module in sys.modules: |
| 1681 | activate_function = self.mpl_modules_for_patching.pop(module, None) |
| 1682 | if activate_function is not None: |
| 1683 | activate_function() |
| 1684 | self.gui_in_use = True |
| 1685 | |
| 1686 | if self.activate_gui_function: |
| 1687 | if is_current_thread_main_thread(): # Only call enable_gui in the main thread. |
| 1688 | try: |
| 1689 | # First try to activate builtin GUI event loops. |
| 1690 | self.activate_gui_function(self._gui_event_loop) |
| 1691 | self.activate_gui_function = None |
| 1692 | self.gui_in_use = True |
| 1693 | except ValueError: |
| 1694 | # The user requested a custom GUI event loop, try to import it. |
| 1695 | from pydev_ipython.inputhook import set_inputhook |
| 1696 | |
| 1697 | try: |
| 1698 | inputhook_function = import_attr_from_module(self._gui_event_loop) |
| 1699 | set_inputhook(inputhook_function) |
| 1700 | self.gui_in_use = True |
| 1701 | except Exception as e: |
| 1702 | pydev_log.debug("Cannot activate custom GUI event loop {}: {}".format(self._gui_event_loop, e)) |
| 1703 | finally: |
| 1704 | self.activate_gui_function = None |
| 1705 | |
| 1706 | def _call_input_hook(self): |
| 1707 | try: |
no test coverage detected