spinetoolbox.widgets.settings_widget

Widget for controlling user settings.

Module Contents

Classes

SettingsWidgetBase

param qsettings

Toolbox settings

SpineDBEditorSettingsMixin

SpineDBEditorSettingsWidget

A widget to change user's preferred settings, but only for the Spine db editor.

SettingsWidget

A widget to change user's preferred settings.

Functions

_get_kernel_name_by_exe(p, kernel_model)

Returns the kernel name corresponding to given executable or an empty string if not found.

_selected_project_matches_kernel_project(...)

Checks if given Julia kernel's project matches the given Julia project.

_samefile(a, b)

class spinetoolbox.widgets.settings_widget.SettingsWidgetBase(qsettings)[source]

Bases: PySide6.QtWidgets.QWidget

Parameters

qsettings (QSettings) – Toolbox settings

property qsettings[source]
connect_signals()[source]

Connect signals.

keyPressEvent(e)[source]

Close settings form when escape key is pressed.

Parameters

e (QKeyEvent) – Received key press event.

mousePressEvent(e)[source]

Save mouse position at the start of dragging.

Parameters

e (QMouseEvent) – Mouse event

mouseReleaseEvent(e)[source]

Save mouse position at the end of dragging.

Parameters

e (QMouseEvent) – Mouse event

mouseMoveEvent(e)[source]

Moves the window when mouse button is pressed and mouse cursor is moved.

Parameters

e (QMouseEvent) – Mouse event

update_ui()[source]

Updates UI to reflect current settings. Called when the user choses to cancel their changes. Undoes all temporary UI changes that resulted from the user playing with certain settings.

save_settings()[source]

Gets selections and saves them to persistent memory.

update_ui_and_close()[source]

Updates UI to reflect current settings and close.

save_and_close()[source]

Saves settings and close.

class spinetoolbox.widgets.settings_widget.SpineDBEditorSettingsMixin[source]
connect_signals()[source]

Connect signals.

read_settings()[source]

Read saved settings from app QSettings instance and update UI to display them.

save_settings()[source]

Get selections and save them to persistent memory.

update_ui()[source]
set_hide_empty_classes(checked=False)[source]
set_auto_expand_entities(checked=False)[source]
set_merge_dbs(checked=False)[source]
set_snap_entities(checked=False)[source]
set_max_entity_dimension_count(value=None)[source]
set_build_iters(value=None)[source]
set_spread_factor(value=None)[source]
set_neg_weight_exp(value=None)[source]
_set_graph_property(name, value)[source]
class spinetoolbox.widgets.settings_widget.SpineDBEditorSettingsWidget(multi_db_editor)[source]

Bases: SpineDBEditorSettingsMixin, SettingsWidgetBase

A widget to change user’s preferred settings, but only for the Spine db editor.

Initialize class.

property db_mngr[source]
show()[source]
class spinetoolbox.widgets.settings_widget.SettingsWidget(toolbox)[source]

Bases: SpineDBEditorSettingsMixin, SettingsWidgetBase

A widget to change user’s preferred settings.

Parameters

toolbox (ToolboxUI) – Parent widget.

property db_mngr[source]
connect_signals()[source]

Connect signals.

_make_python_kernel_context_menu()[source]

Returns a context-menu for Python kernel comboBox.

_make_julia_kernel_context_menu()[source]

Returns a context-menu for Julia kernel comboBox.

eventFilter(o, event)[source]

Event filter that catches mouse right button release events. This event typically closes the context-menu, but we want to prevent this and show a context-menu instead.

Parameters
  • o (QObject) – Watcher

  • event (QEvent) – Event

Returns

True when event is caught, False otherwise

Return type

bool

_update_python_widgets_enabled(state)[source]

Enables or disables some widgets based on given boolean state.

_update_julia_widgets_enabled(state)[source]

Enables or disables some widgets based on given boolean state.

_update_remote_execution_page_widget_status(state)[source]

Enables or disables widgets on Remote Execution page, based on the state of remote execution enabled check box.

_show_install_julia_wizard(_=False)[source]

Opens Install Julia Wizard.

_show_add_up_spine_opt_wizard(_=False)[source]

Opens the add/update SpineOpt wizard.

browse_gams_button_clicked(_=False)[source]

Calls static method that shows a file browser for selecting a Gams executable.

browse_julia_button_clicked(_=False)[source]

Calls static method that shows a file browser for selecting a Julia path.

browse_julia_project_button_clicked(_=False)[source]

Calls static method that shows a folder browser for selecting a Julia project.

browse_python_button_clicked(_=False)[source]

Calls static method that shows a file browser for selecting a Python interpreter.

browse_conda_button_clicked(_=False)[source]

Calls static method that shows a file browser for selecting a Conda executable.

browse_certificate_directory_clicked(_=False)[source]

Calls static method that shows a file browser for selecting the security folder for Engine Server.

make_python_kernel(_=False)[source]

Makes a Python kernel for Jupyter Console based on selected Python interpreter. If a kernel using this Python interpreter already exists, sets that kernel selected in the comboBox.

make_julia_kernel(_=False)[source]

Makes a Julia kernel for Jupyter Console based on selected Julia executable and Julia project. If a kernel using the selected Julia executable and project already exists, sets that kernel selected in the comboBox.

show_python_kernel_context_menu_on_combobox(pos)[source]

Shows the context-menu on Python kernels combobox.

show_julia_kernel_context_menu_on_combobox(pos)[source]

Shows the context-menu on Julia kernels combobox.

show_python_kernel_context_menu_on_combobox_list(pos)[source]

Shows the context-menu on Python kernels combobox popup list.

show_julia_kernel_context_menu_on_combobox_list(pos)[source]

Shows the context-menu on Julia kernels combobox popup list.

_open_python_kernel_resource_dir(_=False)[source]

Opens Python kernels resource dir.

_open_julia_kernel_resource_dir(_=False)[source]

Opens Julia kernels resource dir.

open_rsc_dir(item)[source]

Open path hidden in given item’s tooltip in file browser.

browse_work_path(_=False)[source]

Open file browser where user can select the path to wanted work directory.

show_color_dialog(_=False)[source]

Lets user pick the background color from a color dialog.

update_bg_color()[source]

Set tool button icon as the selected color and update Design View scene background color.

update_scene_bg(_=False)[source]

Draw background on scene depending on radiobutton states.

update_items_path(checked=False)[source]
set_toolbar_colored_icons(checked=False)[source]
_update_properties_widget(_checked=False)[source]
read_settings()[source]

Read saved settings from app QSettings instance and update UI to display them.

_read_engine_settings()[source]

Reads Engine settings and sets the corresponding UI elements.

save_settings()[source]

Get selections and save them to persistent memory. Note: On Linux, True and False are saved as boolean values into QSettings. On Windows, booleans and integers are saved as strings. To make it consistent, we should use strings.

_save_engine_settings()[source]

Stores Engine settings to application settings.

Returns

True if settings were stored successfully, False otherwise

Return type

bool

_get_julia_settings()[source]

Returns current Julia execution settings in Settings->Tools widget.

set_work_directory(new_work_dir)[source]

Sets new work directory.

Parameters

new_work_dir (str) – Possibly a new work directory

update_ui()[source]

Updates UI to reflect current settings. Called when the user choses to cancel their changes. Undoes all temporary UI changes that resulted from the user playing with certain settings.

_edit_remote_host(new_text)[source]

Prepends host line edit with the protocol for user convenience.

Parameters

new_text (str) – Text in the line edit after user has entered a character

start_fetching_julia_kernels()[source]

Starts a thread for fetching Julia kernels.

stop_fetching_julia_kernels()[source]

Terminates the kernel fetcher thread.

add_julia_kernel(kernel_name, resource_dir, conda, icon, deats)[source]

Adds a kernel entry as an item to Julia kernels comboBox.

restore_saved_julia_kernel()[source]

Sets saved or given julia kernel selected after kernels have been loaded.

start_fetching_python_kernels(conda_path_updated=False)[source]

Starts a thread for fetching Python kernels.

stop_fetching_python_kernels()[source]

Terminates the kernel fetcher thread.

add_python_kernel(kernel_name, resource_dir, conda, icon, deats)[source]

Adds a kernel entry as an item to Python kernels comboBox.

restore_saved_python_kernel()[source]

Sets saved or given python kernel selected after kernels have been loaded.

_refresh_python_kernels(conda_path)[source]

Refreshes Python kernels when the conda line edit points to a valid conda executable or when the line edit is cleared.

Parameters

conda_path (str) – Text in line edit after it’s been changed.

closeEvent(ev)[source]
spinetoolbox.widgets.settings_widget._get_kernel_name_by_exe(p, kernel_model)[source]

Returns the kernel name corresponding to given executable or an empty string if not found.

Parameters
  • p (str) – Absolute path to an executable

  • kernel_model (QStandardItemModel) – Model containing items, which contain kernel spec details as item data

Returns

Kernel name or an empty string

Return type

str

spinetoolbox.widgets.settings_widget._selected_project_matches_kernel_project(julia_kernel_name, julia_project, kernel_model)[source]

Checks if given Julia kernel’s project matches the given Julia project.

Parameters
  • julia_kernel_name (str) – Kernel name

  • julia_project (str) – Path or some other string (e.g. ‘@.’) to denote the Julia project

  • kernel_model (QStandardItemModel) – Model containing kernels

Returns

True if projects match, False otherwise

Return type

bool

spinetoolbox.widgets.settings_widget._samefile(a, b)[source]