Skip to content

Commit

Permalink
Merge from 5.x: PR #17874
Browse files Browse the repository at this point in the history
Fixes #17872
  • Loading branch information
dalthviz committed Jun 1, 2022
2 parents 8802e67 + 7d15668 commit 45f241e
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions spyder/plugins/preferences/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from qtpy.QtCore import Qt, Signal, Slot, QRegExp
from qtpy.QtGui import QColor, QRegExpValidator, QTextOption
from qtpy.QtWidgets import (QButtonGroup, QCheckBox, QComboBox, QDoubleSpinBox,
QFontComboBox, QGridLayout, QGroupBox, QHBoxLayout,
QLabel, QLineEdit, QMessageBox, QPushButton,
QRadioButton, QSpinBox, QVBoxLayout, QWidget,
QPlainTextEdit, QTabWidget)
QFileDialog, QFontComboBox, QGridLayout, QGroupBox,
QHBoxLayout, QLabel, QLineEdit, QMessageBox,
QPlainTextEdit, QPushButton, QRadioButton,
QSpinBox, QTabWidget, QVBoxLayout, QWidget)

# Local imports
from spyder.config.base import _
Expand Down Expand Up @@ -189,8 +189,8 @@ def is_valid(self):
text = to_text_string(lineedit.text())
if not validator(text):
QMessageBox.critical(self, self.get_name(),
"%s:<br><b>%s</b>" % (invalid_msg, text),
QMessageBox.Ok)
f"{invalid_msg}:<br><b>{text}</b>",
QMessageBox.Ok)
return False

if self.tabs is not None and status:
Expand Down Expand Up @@ -271,9 +271,9 @@ def load_from_conf(self):
index = None
if index:
combobox.setCurrentIndex(index)
combobox.currentIndexChanged.connect(lambda _foo, opt=option, sect=sec:
self.has_been_modified(
sect, opt))
combobox.currentIndexChanged.connect(
lambda _foo, opt=option, sect=sec:
self.has_been_modified(sect, opt))
if combobox.restart_required:
if sec is None:
self.restart_options[option] = combobox.label_text
Expand Down Expand Up @@ -566,15 +566,16 @@ def create_browsefile(self, text, option, default=NoDefault, tip=None,
browsedir.setLayout(layout)
return browsedir

def select_file(self, edit, filters=None):
def select_file(self, edit, filters=None, **kwargs):
"""Select File"""
basedir = osp.dirname(to_text_string(edit.text()))
if not osp.isdir(basedir):
basedir = getcwd_or_home()
if filters is None:
filters = _("All files (*)")
title = _("Select file")
filename, _selfilter = getopenfilename(self, title, basedir, filters)
filename, _selfilter = getopenfilename(self, title, basedir, filters,
**kwargs)
if filename:
edit.setText(filename)

Expand Down Expand Up @@ -733,7 +734,9 @@ def create_file_combobox(self, text, choices, option, default=NoDefault,
msg)
browse_btn = QPushButton(ima.icon('FileIcon'), '', self)
browse_btn.setToolTip(_("Select file"))
browse_btn.clicked.connect(lambda: self.select_file(edit, filters))
options = QFileDialog.DontResolveSymlinks
browse_btn.clicked.connect(
lambda: self.select_file(edit, filters, options=options))

layout = QGridLayout()
layout.addWidget(combobox, 0, 0, 0, 9)
Expand All @@ -759,7 +762,7 @@ def create_fontgroup(self, option=None, text=None, title=None,
if fontfilters is not None:
fontbox.setFontFilters(fontfilters)

sizelabel = QLabel(" "+_("Size"))
sizelabel = QLabel(" " + _("Size"))
sizebox = QSpinBox()
sizebox.setRange(7, 100)
self.fontboxes[(fontbox, sizebox)] = option
Expand Down

0 comments on commit 45f241e

Please sign in to comment.