Repository: spyder-ide/spyder

Issue:
Can not change font
## Description
![spyder_debug](https://user-images.githubusercontent.com/22970578/65386189-26983e80-dd73-11e9-9c2f-09e706c3e80e.gif)

The same error occurs even after deleting the .spyder-py3-dev folder.

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

1. open preferences
2. go to Appearance
3. change font size
4. push ok button

### Traceback
```python-traceback
  File "D:\CodePy\spyder\spyder\preferences\configdialog.py", line 217, in accept
    configpage.apply_changes()
  File "D:\CodePy\spyder\spyder\preferences\configdialog.py", line 97, in apply_changes
    self.save_to_conf()
  File "D:\CodePy\spyder\spyder\preferences\configdialog.py", line 471, in save_to_conf
    self.set_font(font, option, section=sec)
TypeError: set_font() got an unexpected keyword argument 'section'
```

## Versions

* Spyder version: 4.0.0.dev0 b3bc4b0c3
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.1 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.5.0 (OK)
sphinx >=0.6.6               :  2.1.2 (OK)
pylint >=0.25                :  2.3.1 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.5.7 (OK)
qtpy >=1.5.0                 :  1.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.0.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.5.0;<2.0.0:  1.6.0.dev0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.4 (OK)
cython >=0.21                :  0.29.12 (OK)
IPython >=4.0                :  7.6.1 (OK)
matplotlib >=2.0.0           :  3.1.0 (OK)
pandas >=0.13.1              :  0.24.2 (OK)
numpy >=1.7                  :  1.16.4 (OK)
scipy >=0.17.0               :  1.2.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
@goanpeca, please take a look at this one.

Resolving patch:
diff --git a/spyder/preferences/appearance.py b/spyder/preferences/appearance.py
--- a/spyder/preferences/appearance.py
+++ b/spyder/preferences/appearance.py
@@ -113,27 +113,27 @@ def setup_page(self):
         fonts_group = QGroupBox(_("Fonts"))
 
         # Fonts widgets
-        plain_text_font = self.create_fontgroup(
+        self.plain_text_font = self.create_fontgroup(
             option='font',
             title=_("Plain text"),
             fontfilters=QFontComboBox.MonospacedFonts,
             without_group=True)
 
-        rich_text_font = self.create_fontgroup(
+        self.rich_text_font = self.create_fontgroup(
             option='rich_font',
             title=_("Rich text"),
             without_group=True)
 
         # Fonts layouts
         fonts_layout = QGridLayout(fonts_group)
-        fonts_layout.addWidget(plain_text_font.fontlabel, 0, 0)
-        fonts_layout.addWidget(plain_text_font.fontbox, 0, 1)
-        fonts_layout.addWidget(plain_text_font.sizelabel, 0, 2)
-        fonts_layout.addWidget(plain_text_font.sizebox, 0, 3)
-        fonts_layout.addWidget(rich_text_font.fontlabel, 1, 0)
-        fonts_layout.addWidget(rich_text_font.fontbox, 1, 1)
-        fonts_layout.addWidget(rich_text_font.sizelabel, 1, 2)
-        fonts_layout.addWidget(rich_text_font.sizebox, 1, 3)
+        fonts_layout.addWidget(self.plain_text_font.fontlabel, 0, 0)
+        fonts_layout.addWidget(self.plain_text_font.fontbox, 0, 1)
+        fonts_layout.addWidget(self.plain_text_font.sizelabel, 0, 2)
+        fonts_layout.addWidget(self.plain_text_font.sizebox, 0, 3)
+        fonts_layout.addWidget(self.rich_text_font.fontlabel, 1, 0)
+        fonts_layout.addWidget(self.rich_text_font.fontbox, 1, 1)
+        fonts_layout.addWidget(self.rich_text_font.sizelabel, 1, 2)
+        fonts_layout.addWidget(self.rich_text_font.sizebox, 1, 3)
         fonts_layout.setRowStretch(fonts_layout.rowCount(), 1)
 
         # Left options layout
diff --git a/spyder/preferences/configdialog.py b/spyder/preferences/configdialog.py
--- a/spyder/preferences/configdialog.py
+++ b/spyder/preferences/configdialog.py
@@ -468,7 +468,7 @@ def save_to_conf(self):
             if option in self.changed_options:
                 font = fontbox.currentFont()
                 font.setPointSize(sizebox.value())
-                self.set_font(font, option, section=sec)
+                self.set_font(font, option)
         for clayout, (sec, option, _default) in list(self.coloredits.items()):
             if option in self.changed_options:
                 self.set_option(option,


Test patch:
diff --git a/spyder/app/tests/test_mainwindow.py b/spyder/app/tests/test_mainwindow.py
--- a/spyder/app/tests/test_mainwindow.py
+++ b/spyder/app/tests/test_mainwindow.py
@@ -2031,5 +2031,38 @@ def trigger():
     CONF.set('lsp-server', 'pydocstyle', False)
 
 
+@pytest.mark.slow
+def test_preferences_change_font_regression(main_window, qtbot):
+    """
+    Test for spyder-ide/spyder/#10284 regression.
+
+    Changing font resulted in error.
+    """
+    def trigger():
+        pref = main_window.prefs_dialog_instance
+        index = 1
+        page = pref.get_page(index)
+        pref.set_current_index(index)
+        qtbot.wait(1000)
+
+        for fontbox in [page.plain_text_font.fontbox,
+                        page.rich_text_font.fontbox]:
+            fontbox.setFocus()
+            idx = fontbox.currentIndex()
+            fontbox.setCurrentIndex(idx + 1)
+            qtbot.wait(1000)
+
+        qtbot.wait(4000)
+        pref.ok_btn.animateClick(300)
+
+    timer = QTimer()
+    timer.setSingleShot(True)
+    timer.timeout.connect(trigger)
+    timer.start(5000)
+
+    main_window.show_preferences()
+    qtbot.wait(5000)
+
+
 if __name__ == "__main__":
     pytest.main()