Repository: spyder-ide/spyder

Issue:
Display problems on systems that use 'display scaling'
## Description of your problem

**What steps will reproduce the problem?**
1. In the system settings of either Windows 7 or Windows 10, set display scaling to 150%. 
2. Launch Spyder 3.0

**What do you see?**
Many GUI elements look "off", as shown below.

Main screen: the text "Console" in the Help pane has its last character cut off. All text in the main box of the Help pane looks outsized. The icons in the toolbar look outsized with respect to the text labels. 
<img width="960" alt="spyder-3 0_150percent_display_scaling" src="https://cloud.githubusercontent.com/assets/20889585/19004782/c17421b4-8757-11e6-8412-e3f70b83309e.PNG">

Preferences screen: the text "WindowsVista" has its last character cut off. Half of the edges of the checkbox icons have been cut off.
<img width="746" alt="spyder-3 0_preferences_150percent_display_scaling" src="https://cloud.githubusercontent.com/assets/20889585/19004979/a02ff8e2-8758-11e6-824d-bd019060006e.PNG">

**Please provide any additional information below**
The Spyder GUI looks "proper" again on my system after I manually set the Qt.AA_EnableHighDpiScaling option to False in Spyder's code (in "spyder/app/mainwindow.py"). See below:
<img width="960" alt="spyder-3 0_150percent_display_scaling_qt_option_disabled" src="https://cloud.githubusercontent.com/assets/20889585/19006034/f738902c-875d-11e6-8ca6-7d65b077019d.PNG">

<img width="451" alt="spyder-3 0_preferences_150percent_display_scaling_qt_option_disabled" src="https://cloud.githubusercontent.com/assets/20889585/19006037/f9d03394-875d-11e6-80b2-595f2efd3434.PNG">
## Versions and main components
- Spyder Version: 3.0.0
- Python Version: 3.5
- Operating system: Windows 7 and Windows 10
## Dependencies

jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.3.1 (OK)
sympy >=0.7.3    :  1.0 (OK)



Discussion:
Thanks for reporting. This means we definitely need to add an option to enable/disable `HighDpiScaling` (although it'll be enabled by default).

We'll do that for Spyder **3.1** :-)

Just to confirm that editing the file `mainwindow.py` (in some path like `.../site-packages/spyder/app/mainwindow.py`) and comenting out the following lines:

``` python
#if hasattr(Qt, 'AA_EnableHighDpiScaling'):
#    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
```

fixes the issue. Thanks to @Ticonderoga for pointing this out in  #3417.

Also I would consider carefully whether to make dpi scaling the default. That setting is completely nonsensical on a modern 13 inch laptop, where really the number of pixels is what matters (and a scaling factor of 2 is too big, and on linux fractional scaling doesn't work so well). If I was a new user and saw this the first time I opened Spyder I would close it immediately and never look at it again, much less try to bother to see if there is a setting to fix it:

![screenshot from 2016-10-01 05-05-42](https://cloud.githubusercontent.com/assets/5675858/19011417/d2be74f0-8794-11e6-9475-18ab4bc60233.png)

This is one issue you can start to work on @malliwi88.

I believe that Zaharid raises a valid concern. New users might be scared off when faced with a 'broken'-looking GUI during the very time that they start the program. That would be a real shame of course, since Spyder is an absolutely awesome program. :-)

Perhaps you could let Spyder check during first run whether the OS is applying system-wide display scaling, and then set the Qt.AA_EnableHighDpiScaling default based upon the check outcome? Something along the lines of this:

``` python
if os_display_scaling_disabled and hasattr(Qt, 'AA_EnableHighDpiScaling'):
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
```

I don't know whether this is a workable solution, it's just some brainstorming. :-)

@zoquda, we're leaning towards disabling scaling by default :-)

@dalthviz or @mariacamilaremolinagutierrez, you could work on this one.


Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -94,10 +94,15 @@
 
 #==============================================================================
 # Proper high DPI scaling is available in Qt >= 5.6.0. This attibute must
-# be set before creating the application
+# be set before creating the application. 
 #==============================================================================
+from spyder.config.main import CONF
+if CONF.get('main', 'high_dpi_scaling'):
+    high_dpi_scaling = True
+else:
+    high_dpi_scaling = False
 if hasattr(Qt, 'AA_EnableHighDpiScaling'):
-    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
+    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, high_dpi_scaling)
 
 
 #==============================================================================
@@ -131,7 +136,7 @@
                                 debug_print, MAC_APP_NAME, get_home_dir,
                                 running_in_mac_app, get_module_path,
                                 reset_config_files)
-from spyder.config.main import CONF, OPEN_FILES_PORT
+from spyder.config.main import OPEN_FILES_PORT
 from spyder.config.utils import IMPORT_EXT, is_gtk_desktop
 from spyder.app.cli_options import get_options
 from spyder import dependencies
@@ -261,6 +266,7 @@ def __init__(self, options=None):
 
         qapp = QApplication.instance()
         if PYQT5:
+            # Enabling scaling for high dpi
             qapp.setAttribute(Qt.AA_UseHighDpiPixmaps)
         self.default_style = str(qapp.style().objectName())
 
diff --git a/spyder/config/main.py b/spyder/config/main.py
--- a/spyder/config/main.py
+++ b/spyder/config/main.py
@@ -65,6 +65,7 @@
               'single_instance': True,
               'open_files_port': OPEN_FILES_PORT,
               'tear_off_menus': False,
+              'high_dpi_scaling': False,
               'vertical_dockwidget_titlebars': False,
               'vertical_tabs': False,
               'animated_docks': True,
diff --git a/spyder/plugins/configdialog.py b/spyder/plugins/configdialog.py
--- a/spyder/plugins/configdialog.py
+++ b/spyder/plugins/configdialog.py
@@ -860,6 +860,9 @@ def setup_page(self):
         tear_off_box = newcb(_("Tear off menus"), 'tear_off_menus',
                              tip=_("Set this to detach any<br> "
                                    "menu from the main window"))
+        high_dpi_scaling_box = newcb(_("Enable high DPI scaling"), 
+                                     'high_dpi_scaling',
+                                     tip=_("Set this for high DPI displays"))
         margin_box = newcb(_("Custom margin for panes:"),
                            'use_custom_margin')
         margin_spin = self.create_spinbox("", _("pixels"), 'custom_margin',
@@ -886,6 +889,7 @@ def setup_page(self):
         interface_layout.addWidget(verttabs_box)
         interface_layout.addWidget(animated_box)
         interface_layout.addWidget(tear_off_box)
+        interface_layout.addWidget(high_dpi_scaling_box)
         interface_layout.addLayout(margins_layout)
         interface_group.setLayout(interface_layout)
 


Test patch: