def reset_namespace(self, warning=False, message=False): """Reset the namespace by removing all names defined by the user.""" # Don't show the warning when running our tests. if running_under_pytest(): warning = False if warning: reset_str = _("Remove all variables") warn_str = _("All user-defined variables will be removed. " "Are you sure you want to proceed?") box = MessageCheckBox(icon=QMessageBox.Warning, parent=self) box.setWindowTitle(reset_str) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setDefaultButton(QMessageBox.Yes) box.set_checkbox_text(_("Don't show again.")) box.set_checked(False) box.set_check_visible(True) box.setText(warn_str) box.buttonClicked.connect( lambda button: self.handle_reset_message_answer( box, button, message)) box.show() else: self._perform_reset(message)
def _check_updates_ready(self): """Show results of the Spyder update checking process.""" # `feedback` = False is used on startup, so only positive feedback is # given. `feedback` = True is used when after startup (when using the # menu action, and gives feeback if updates are, or are not found. feedback = self.give_updates_feedback # Get results from worker update_available = self.worker_updates.update_available latest_release = self.worker_updates.latest_release error_msg = self.worker_updates.error # Release url if sys.platform == 'darwin': url_r = ('https://github.com/spyder-ide/spyder/releases/latest/' 'download/Spyder.dmg') else: url_r = ('https://github.com/spyder-ide/spyder/releases/latest/' 'download/Spyder_64bit_full.exe') url_i = 'https://docs.spyder-ide.org/installation.html' # Define the custom QMessageBox box = MessageCheckBox(icon=QMessageBox.Information, parent=self) box.setWindowTitle(_("New Spyder version")) box.setAttribute(Qt.WA_ShowWithoutActivating) box.set_checkbox_text(_("Check for updates at startup")) box.setStandardButtons(QMessageBox.Ok) box.setDefaultButton(QMessageBox.Ok) # Adjust the checkbox depending on the stored configuration option = 'check_updates_on_startup' check_updates = self.get_conf(option) box.set_checked(check_updates) if error_msg is not None: msg = error_msg box.setText(msg) box.set_check_visible(False) box.exec_() check_updates = box.is_checked() else: if update_available: header = _("<b>Spyder {} is available!</b><br><br>").format( latest_release) footer = _( "For more information visit our " "<a href=\"{}\">installation guide</a>.").format(url_i) if is_anaconda(): content = _( "<b>Important note:</b> Since you installed " "Spyder with Anaconda, please <b>don't</b> use " "<code>pip</code> to update it as that will break " "your installation.<br><br>" "Instead, run the following commands in a " "terminal:<br>" "<code>conda update anaconda</code><br>" "<code>conda install spyder={}</code><br><br>").format( latest_release) else: content = _("Click <a href=\"{}\">this link</a> to " "download it.<br><br>").format(url_r) msg = header + content + footer box.setText(msg) box.set_check_visible(True) box.show() check_updates = box.is_checked() elif feedback: msg = _("Spyder is up to date.") box.setText(msg) box.set_check_visible(False) box.exec_() check_updates = box.is_checked() # Update checkbox based on user interaction self.set_conf(option, check_updates) # Enable check_updates_action after the thread has finished self.check_updates_action.setDisabled(False) # Provide feeback when clicking menu if check on startup is on self.give_updates_feedback = True
def reset_namespace(self, warning=False, message=False): """Reset the namespace by removing all names defined by the user.""" reset_str = _("Remove all variables") warn_str = _("All user-defined variables will be removed. " "Are you sure you want to proceed?") # Don't show the warning when running our tests. if running_under_pytest(): warning = False # This is necessary to make resetting variables work in external # kernels. # See spyder-ide/spyder#9505. try: kernel_env = self.kernel_manager._kernel_spec.env except AttributeError: kernel_env = {} if warning: box = MessageCheckBox(icon=QMessageBox.Warning, parent=self) box.setWindowTitle(reset_str) box.set_checkbox_text(_("Don't show again.")) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setDefaultButton(QMessageBox.Yes) box.set_checked(False) box.set_check_visible(True) box.setText(warn_str) answer = box.show() # Update checkbox based on user interaction self.set_conf( 'show_reset_namespace_warning', not box.is_checked()) self.ipyclient.reset_warning = not box.is_checked() if answer != QMessageBox.Yes: return try: if self.is_waiting_pdb_input(): self.execute('%reset -f') else: if message: self.reset() self._append_html( _("<br><br>Removing all variables...<br>"), before_prompt=False ) self.insert_horizontal_ruler() self.silent_execute("%reset -f") if kernel_env.get('SPY_AUTOLOAD_PYLAB_O') == 'True': self.silent_execute("from pylab import *") if kernel_env.get('SPY_SYMPY_O') == 'True': sympy_init = """ from __future__ import division from sympy import * x, y, z, t = symbols('x y z t') k, m, n = symbols('k m n', integer=True) f, g, h = symbols('f g h', cls=Function) init_printing()""" self.silent_execute(dedent(sympy_init)) if kernel_env.get('SPY_RUN_CYTHON') == 'True': self.silent_execute("%reload_ext Cython") # This doesn't need to interrupt the kernel because # "%reset -f" is being executed before it. # Fixes spyder-ide/spyder#12689 self.refresh_namespacebrowser(interrupt=False) if not self.external_kernel: self.call_kernel().close_all_mpl_figures() except AttributeError: pass