Skip to content

Commit

Permalink
PR: Add help info widget to show tooltips in Preferences (UX/UI) (#20926
Browse files Browse the repository at this point in the history
)

Co-authored-by: dalthviz <[email protected]>
Co-authored-by: Carlos Cordoba <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2023
1 parent 7f599d1 commit 8861408
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 93 deletions.
4 changes: 2 additions & 2 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,7 +3033,7 @@ def test_preferences_checkboxes_not_checked_regression(main_window, qtbot):
check_name = tab_widgets[tabname]
check = getattr(tab, check_name)
page.tabs.setCurrentIndex(idx)
check.animateClick()
check.checkbox.animateClick()
qtbot.wait(500)
dlg.ok_btn.animateClick()

Expand Down Expand Up @@ -3222,7 +3222,7 @@ def test_preferences_change_interpreter(qtbot, main_window):
# Change main interpreter on preferences
dlg, index, page = preferences_dialog_helper(qtbot, main_window,
'main_interpreter')
page.cus_exec_radio.setChecked(True)
page.cus_exec_radio.radiobutton.setChecked(True)
page.cus_exec_combo.combobox.setCurrentText(sys.executable)

mi_container = main_window.main_interpreter.get_container()
Expand Down
7 changes: 4 additions & 3 deletions spyder/plugins/appearance/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def setup_page(self):
self.delete_button.clicked.connect(self.delete_scheme)
self.schemes_combobox.currentIndexChanged.connect(self.update_preview)
self.schemes_combobox.currentIndexChanged.connect(self.update_buttons)
system_font_checkbox.stateChanged.connect(self.update_app_font_group)
system_font_checkbox.checkbox.stateChanged.connect(
self.update_app_font_group)

# Setup
for name in names:
Expand All @@ -191,8 +192,8 @@ def setup_page(self):
self.scheme_editor_dialog.add_color_scheme_stack(name, custom=True)

if sys.platform == 'darwin':
system_font_checkbox.setEnabled(False)
self.update_app_font_group(system_font_checkbox.isChecked())
system_font_checkbox.checkbox.setEnabled(False)
self.update_app_font_group(system_font_checkbox.checkbox.isChecked())
self.update_combobox()
self.update_preview()

Expand Down
35 changes: 23 additions & 12 deletions spyder/plugins/application/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def setup_page(self):
'use_custom_margin')
margin_spin = self.create_spinbox("", _("pixels"), 'custom_margin',
default=0, min_=0, max_=30)
margin_box.toggled.connect(margin_spin.spinbox.setEnabled)
margin_box.toggled.connect(margin_spin.slabel.setEnabled)
margin_box.checkbox.toggled.connect(margin_spin.spinbox.setEnabled)
margin_box.checkbox.toggled.connect(margin_spin.slabel.setEnabled)
margin_spin.spinbox.setEnabled(self.get_option('use_custom_margin'))
margin_spin.slabel.setEnabled(self.get_option('use_custom_margin'))

Expand All @@ -114,8 +114,8 @@ def setup_page(self):
'custom_cursor_blinking',
default=QApplication.cursorFlashTime(),
min_=0, max_=5000, step=100)
cursor_box.toggled.connect(cursor_spin.spinbox.setEnabled)
cursor_box.toggled.connect(cursor_spin.slabel.setEnabled)
cursor_box.checkbox.toggled.connect(cursor_spin.spinbox.setEnabled)
cursor_box.checkbox.toggled.connect(cursor_spin.slabel.setEnabled)
cursor_spin.spinbox.setEnabled(
self.get_option('use_custom_cursor_blinking'))
cursor_spin.slabel.setEnabled(
Expand Down Expand Up @@ -153,7 +153,7 @@ def set_open_file(state):
_("Open files from Finder with Spyder"),
'mac_open_file',
tip=_("Register Spyder with the Launch Services"))
mac_open_file_box.toggled.connect(set_open_file)
mac_open_file_box.checkbox.toggled.connect(set_open_file)
macOS_layout = QVBoxLayout()
macOS_layout.addWidget(mac_open_file_box)
if als.get_bundle_identifier() is None:
Expand Down Expand Up @@ -207,21 +207,32 @@ def set_open_file(state):
regex=r"[0-9]+(?:\.[0-9]*)(;[0-9]+(?:\.[0-9]*))*",
restart=True)

normal_radio.toggled.connect(self.custom_scaling_edit.setDisabled)
auto_scale_radio.toggled.connect(self.custom_scaling_edit.setDisabled)
custom_scaling_radio.toggled.connect(
self.custom_scaling_edit.setEnabled)
normal_radio.radiobutton.toggled.connect(
self.custom_scaling_edit.textbox.setDisabled)
auto_scale_radio.radiobutton.toggled.connect(
self.custom_scaling_edit.textbox.setDisabled)
custom_scaling_radio.radiobutton.toggled.connect(
self.custom_scaling_edit.textbox.setEnabled)

# Layout Screen resolution
screen_resolution_layout = QVBoxLayout()
screen_resolution_layout.addWidget(screen_resolution_label)

screen_resolution_inner_layout = QGridLayout()
screen_resolution_inner_layout.addWidget(normal_radio, 0, 0)
screen_resolution_inner_layout.addWidget(auto_scale_radio, 1, 0)
screen_resolution_inner_layout.addWidget(custom_scaling_radio, 2, 0)
screen_resolution_inner_layout.addWidget(
self.custom_scaling_edit, 2, 1)
auto_scale_radio.radiobutton, 1, 0)
screen_resolution_inner_layout.addWidget(
auto_scale_radio.radiobutton.help_label, 1, 1)
screen_resolution_inner_layout.addWidget(
custom_scaling_radio.radiobutton, 2, 0)
screen_resolution_inner_layout.addWidget(
custom_scaling_radio.radiobutton.help_label, 2, 1)
screen_resolution_inner_layout.addWidget(
self.custom_scaling_edit.textbox, 2, 2)
screen_resolution_inner_layout.addWidget(
self.custom_scaling_edit.help_label, 2, 3)
screen_resolution_inner_layout.setColumnStretch(2, 1)

screen_resolution_layout.addLayout(screen_resolution_inner_layout)
screen_resolution_group.setLayout(screen_resolution_layout)
Expand Down
9 changes: 7 additions & 2 deletions spyder/plugins/completion/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,23 @@ def setup_page(self):
completions_layout.addWidget(completions_after_characters.plabel, 3, 0)
completions_layout.addWidget(
completions_after_characters.spinbox, 3, 1)
completions_layout.addWidget(
completions_after_characters.help_label, 3, 2)
completions_layout.addWidget(completions_hint_after_idle.plabel, 5, 0)
completions_layout.addWidget(completions_hint_after_idle.spinbox, 5, 1)
completions_layout.addWidget(
completions_hint_after_idle.help_label, 5, 2)
completions_layout.addWidget(completions_wait_for_ms.plabel, 6, 0)
completions_layout.addWidget(completions_wait_for_ms.spinbox, 6, 1)
completions_layout.setColumnStretch(2, 6)
completions_layout.addWidget(completions_wait_for_ms.help_label, 6, 2)
completions_layout.setColumnStretch(3, 6)
self.completions_group.setLayout(completions_layout)

def disable_completion_after_characters(state):
completions_after_characters.plabel.setEnabled(state)
completions_after_characters.spinbox.setEnabled(state)

automatic_completion_box.toggled.connect(
automatic_completion_box.checkbox.toggled.connect(
disable_completion_after_characters)

layout = QVBoxLayout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, parent):
self.use_stdio = self.create_checkbox(
_("Use stdio pipes to communicate with server"),
'advanced/stdio')
self.use_stdio.stateChanged.connect(self.disable_tcp)
self.external_server.stateChanged.connect(self.disable_stdio)
self.use_stdio.checkbox.stateChanged.connect(self.disable_tcp)
self.external_server.checkbox.stateChanged.connect(self.disable_stdio)

# Advanced layout
advanced_g_layout = QGridLayout()
Expand All @@ -87,9 +87,9 @@ def __init__(self, parent):
advanced_options_widget = QWidget()
advanced_options_widget.setLayout(advanced_options_layout)
advanced_options_widget.setEnabled(self.get_option('advanced/enabled'))
self.advanced_options_check.toggled.connect(
self.advanced_options_check.checkbox.toggled.connect(
advanced_options_widget.setEnabled)
self.advanced_options_check.toggled.connect(
self.advanced_options_check.checkbox.toggled.connect(
self.show_advanced_warning)

# Advanced options layout
Expand All @@ -108,15 +108,16 @@ def disable_tcp(self, state):
if state == Qt.Checked:
self.advanced_host.textbox.setEnabled(False)
self.advanced_port.spinbox.setEnabled(False)
self.external_server.stateChanged.disconnect()
self.external_server.setChecked(False)
self.external_server.setEnabled(False)
self.external_server.checkbox.stateChanged.disconnect()
self.external_server.checkbox.setChecked(False)
self.external_server.checkbox.setEnabled(False)
else:
self.advanced_host.textbox.setEnabled(True)
self.advanced_port.spinbox.setEnabled(True)
self.external_server.setChecked(False)
self.external_server.setEnabled(True)
self.external_server.stateChanged.connect(self.disable_stdio)
self.external_server.checkbox.setChecked(False)
self.external_server.checkbox.setEnabled(True)
self.external_server.checkbox.stateChanged.connect(
self.disable_stdio)

def disable_stdio(self, state):
if state == Qt.Checked:
Expand Down Expand Up @@ -167,10 +168,10 @@ def is_valid(self):
# and we need to automatically check the corresponding
# option
if host not in ['127.0.0.1', 'localhost']:
self.external_server.setChecked(True)
self.external_server.checkbox.setChecked(True)

# Checks for external PyLS
if self.external_server.isChecked():
if self.external_server.checkbox.isChecked():
port = int(self.advanced_port.spinbox.text())

# Check that host and port of the current server are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, parent):
docstring_style_g_widget = QWidget()
docstring_style_g_widget.setLayout(docstring_style_g_layout)
docstring_style_g_widget.setEnabled(self.get_option('pydocstyle'))
self.docstring_style_check.toggled.connect(
self.docstring_style_check.checkbox.toggled.connect(
docstring_style_g_widget.setEnabled)

# Docstring style layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def __init__(self, parent):
code_style_g_widget = QWidget()
code_style_g_widget.setLayout(code_style_g_layout)
code_style_g_widget.setEnabled(self.get_option('pycodestyle'))
self.code_style_check.toggled.connect(code_style_g_widget.setEnabled)
self.code_style_check.checkbox.toggled.connect(
code_style_g_widget.setEnabled)

# Code style layout
code_style_group = QGroupBox(_("Code style"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def __init__(self, parent):
introspection_layout.addWidget(enable_hover_hints_box)
introspection_group.setLayout(introspection_layout)

goto_definition_box.toggled.connect(follow_imports_box.setEnabled)
goto_definition_box.checkbox.toggled.connect(
follow_imports_box.setEnabled)

# Advanced group
advanced_group = QGroupBox(_("Advanced"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def __init__(self, parent):
linting_layout.addWidget(underline_errors_box)
linting_layout.addWidget(linting_complexity_box)
self.setLayout(linting_layout)
linting_check.toggled.connect(underline_errors_box.setEnabled)
linting_check.checkbox.toggled.connect(underline_errors_box.setEnabled)
10 changes: 6 additions & 4 deletions spyder/plugins/editor/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def setup_page(self):
"", _(" ms"),
'occurrence_highlighting/timeout',
min_=100, max_=1000000, step=100)
occurrence_box.toggled.connect(occurrence_spin.spinbox.setEnabled)
occurrence_box.toggled.connect(occurrence_spin.slabel.setEnabled)
occurrence_box.checkbox.toggled.connect(
occurrence_spin.spinbox.setEnabled)
occurrence_box.checkbox.toggled.connect(
occurrence_spin.slabel.setEnabled)
occurrence_spin.spinbox.setEnabled(
self.get_option('occurrence_highlighting'))
occurrence_spin.slabel.setEnabled(
Expand Down Expand Up @@ -220,7 +222,7 @@ def enable_tabwidth_spin(index):
_('seconds'),
'autosave_interval',
min_=1, max_=3600)
autosave_checkbox.toggled.connect(autosave_spinbox.setEnabled)
autosave_checkbox.checkbox.toggled.connect(autosave_spinbox.setEnabled)

autosave_layout = QVBoxLayout()
autosave_layout.addWidget(autosave_checkbox)
Expand Down Expand Up @@ -297,7 +299,7 @@ def enable_tabwidth_spin(index):
eol_combo_choices,
'convert_eol_on_save_to',
)
convert_eol_on_save_box.toggled.connect(
convert_eol_on_save_box.checkbox.toggled.connect(
convert_eol_on_save_combo.setEnabled)
convert_eol_on_save_combo.setEnabled(
self.get_option('convert_eol_on_save'))
Expand Down
10 changes: 6 additions & 4 deletions spyder/plugins/ipythonconsole/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def setup_page(self):
"plotting libraries different to Matplotlib or to develop\n"
"GUIs with Spyder."))
autoload_pylab_box.setEnabled(self.get_option('pylab'))
pylab_box.toggled.connect(autoload_pylab_box.setEnabled)
pylab_box.checkbox.toggled.connect(autoload_pylab_box.setEnabled)

pylab_layout = QVBoxLayout()
pylab_layout.addWidget(pylab_box)
Expand Down Expand Up @@ -131,7 +131,7 @@ def setup_page(self):
backend_layout.addWidget(backend_box)
backend_group.setLayout(backend_layout)
backend_group.setEnabled(self.get_option('pylab'))
pylab_box.toggled.connect(backend_group.setEnabled)
pylab_box.checkbox.toggled.connect(backend_group.setEnabled)

# Inline backend Group
inline_group = QGroupBox(_("Inline backend"))
Expand Down Expand Up @@ -186,7 +186,7 @@ def setup_page(self):
inline_v_layout.addLayout(inline_h_layout)
inline_group.setLayout(inline_v_layout)
inline_group.setEnabled(self.get_option('pylab'))
pylab_box.toggled.connect(inline_group.setEnabled)
pylab_box.checkbox.toggled.connect(inline_group.setEnabled)

# --- Startup ---
# Run lines Group
Expand Down Expand Up @@ -215,7 +215,7 @@ def setup_page(self):
'startup/use_run_file', False)
run_file_browser = self.create_browsefile('', 'startup/run_file', '')
run_file_browser.setEnabled(False)
file_radio.toggled.connect(run_file_browser.setEnabled)
file_radio.checkbox.toggled.connect(run_file_browser.setEnabled)

run_file_layout = QVBoxLayout()
run_file_layout.addWidget(run_file_label)
Expand Down Expand Up @@ -338,8 +338,10 @@ def setup_page(self):
prompts_g_layout = QGridLayout()
prompts_g_layout.addWidget(in_prompt_edit.label, 0, 0)
prompts_g_layout.addWidget(in_prompt_edit.textbox, 0, 1)
prompts_g_layout.addWidget(in_prompt_edit.help_label, 0, 2)
prompts_g_layout.addWidget(out_prompt_edit.label, 1, 0)
prompts_g_layout.addWidget(out_prompt_edit.textbox, 1, 1)
prompts_g_layout.addWidget(out_prompt_edit.help_label, 1, 2)
prompts_layout.addLayout(prompts_g_layout)
prompts_group.setLayout(prompts_layout)

Expand Down
6 changes: 4 additions & 2 deletions spyder/plugins/maininterpreter/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def setup_page(self):
adjust_to_contents=True,
validate_callback=programs.is_python_interpreter,
)
self.def_exec_radio.toggled.connect(self.cus_exec_combo.setDisabled)
self.cus_exec_radio.toggled.connect(self.cus_exec_combo.setEnabled)
self.def_exec_radio.radiobutton.toggled.connect(
self.cus_exec_combo.setDisabled)
self.cus_exec_radio.radiobutton.toggled.connect(
self.cus_exec_combo.setEnabled)
pyexec_layout.addWidget(self.cus_exec_combo)
pyexec_group.setLayout(pyexec_layout)

Expand Down
Loading

0 comments on commit 8861408

Please sign in to comment.