Repository: spyder-ide/spyder

Issue:
Don't restart automatically Spyder when a monitor scale change is detected
Ask the user if he wants to restart instead.

Improves the changes done at PR #11322 

As discussed with @ccordoba12 


Discussion:

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -1446,17 +1446,30 @@ def show_DPI_change_message(self):
         screen = self.window().windowHandle().screen()
         screen.logicalDotsPerInchChanged.disconnect(
             self.show_DPI_change_message)
-        QMessageBox.warning(
+        answer = QMessageBox.warning(
             self, _("Warning"),
             _("A monitor scale change was detected. <br><br>"
-              "Spyder will be restarted to be properly displayed."),
-            QMessageBox.Ok)
-        # Activate HDPI auto-scaling option since is needed for a proper
-        # display when using OS scaling
-        CONF.set('main', 'normal_screen_resolution', False)
-        CONF.set('main', 'high_dpi_scaling', True)
-        CONF.set('main', 'high_dpi_custom_scale_factor', False)
-        self.restart()
+              "We recommend restarting Spyder to ensure that it's properly "
+              "displayed. If you don't want to do that, please be sure to "
+              "activate the option<br><br><tt>Enable auto high DPI scaling"
+              "</tt><br><br>in <tt>Preferences > General > Interface</tt>, "
+              "in case Spyder is not displayed correctly.<br><br>"
+              "Do you want to restart Spyder?"),
+            QMessageBox.Yes | QMessageBox.No)
+
+        if answer == QMessageBox.Yes:
+            # Activate HDPI auto-scaling option since is needed for a proper
+            # display when using OS scaling
+            CONF.set('main', 'normal_screen_resolution', False)
+            CONF.set('main', 'high_dpi_scaling', True)
+            CONF.set('main', 'high_dpi_custom_scale_factor', False)
+            self.restart()
+        else:
+            # Reconnect DPI scale changes to show a restart message
+            screen = self.window().windowHandle().screen()
+            screen.logicalDotsPerInchChanged.connect(
+                self.show_DPI_change_message)
+
 
     def set_window_title(self):
         """Set window title."""


Test patch:
diff --git a/spyder/plugins/onlinehelp/tests/test_pydocgui.py b/spyder/plugins/onlinehelp/tests/test_pydocgui.py
--- a/spyder/plugins/onlinehelp/tests/test_pydocgui.py
+++ b/spyder/plugins/onlinehelp/tests/test_pydocgui.py
@@ -8,7 +8,7 @@
 Tests for pydocgui.py
 """
 # Standard library imports
-import sys
+import os
 
 # Test library imports
 import pytest
@@ -16,7 +16,6 @@
 
 # Local imports
 from spyder.plugins.onlinehelp.widgets import PydocBrowser
-from spyder.py3compat import PY3
 
 
 @pytest.fixture
@@ -38,8 +37,7 @@ def test_pydocbrowser(pydocbrowser):
     "lib", [('str', 'class str', 1),
             ('numpy.compat', 'numpy.compat', 2)
             ])
-@pytest.mark.skipif(sys.platform == 'darwin' and PY3,
-                    reason="Times out on macOS with Python 3")
+@pytest.mark.skipif(not os.name == 'nt', reason="Only works on Windows")
 def test_get_pydoc(pydocbrowser, lib):
     """
     Go to the documentation by url.