ui_main

Contains ToolboxUI class.

author:
  1. Savolainen (VTT)
date:

14.12.2017

Module Contents

class ui_main.ToolboxUI[source]

Bases: PySide2.QtWidgets.QMainWindow

Class for application main GUI functions.

msg[source]
msg_success[source]
msg_error[source]
msg_warning[source]
msg_proc[source]
msg_proc_error[source]
connect_signals(self)[source]

Connect signals.

project(self)[source]

Returns current project or None if no project open.

qsettings(self)[source]

Returns application preferences object.

init_project(self)[source]

Initializes project at application start-up. Loads the last project that was open when app was closed or starts without a project if app is started for the first time.

new_project(self)[source]

Shows new project form.

create_project(self, name, description)[source]

Create new project and set it active.

Parameters:
  • name (str) – Project name
  • description (str) – Project description
open_project(self, load_path=None)[source]

Load project from a save file (.proj) file.

Parameters:
  • load_path (str) – Path to project save file. If default value is used,
  • file explorer dialog is opened where the user can select the (a) –
  • file to load. (project) –
Returns:

True when opening the project succeeded, False otherwise

Return type:

bool

save_project(self)[source]

Save project.

save_project_as(self)[source]

Ask user for a new project name and save. Creates a duplicate of the open project.

init_models(self, tool_template_paths)[source]

Initialize application internal data models.

Parameters:tool_template_paths (list) – List of tool definition file paths used in this project
init_project_item_model(self)[source]

Initializes project item model. Create root and category items and add them to the model.

init_tool_template_model(self, tool_template_paths)[source]

Initializes Tool template model.

Parameters:tool_template_paths (list) – List of tool definition file paths used in this project
init_connection_model(self)[source]

Initializes a model representing connections between project items.

init_shared_widgets(self)[source]

Initialize widgets that are shared among all ProjectItems of the same type.

restore_ui(self)[source]

Restore UI state from previous session.

clear_ui(self)[source]

Clean UI to make room for a new or opened project.

item_selection_changed(self, selected, deselected)[source]

Synchronize selection with scene. Check if only one item is selected and make it the active item: disconnect signals of previous active item, connect signals of current active item and show correct properties tab for the latter.

activate_no_selection_tab(self)[source]

Shows ‘No Selection’ tab.

activate_item_tab(self, item)[source]

Shows project item properties tab according to item type. Note: Does not work if a category item is given as argument.

Parameters:item (ProjectItem) – Instance of a project item
open_tool_template(self)[source]

Open a file dialog so the user can select an existing tool template .json file. Continue loading the tool template into the Project if successful.

add_tool_template(self, tool_template)[source]

Add a ToolTemplate instance to project, which then can be added to a Tool item. Add tool template definition file path into project file (.proj)

tool_template (ToolTemplate): Tool template that is added to project

update_tool_template(self, row, tool_template)[source]

Update a Tool template and refresh Tools that use it.

Parameters:
  • row (int) – Row of tool template in ToolTemplateModel
  • tool_template (ToolTemplate) – An updated Tool template
remove_selected_tool_template(self)[source]

Prepare to remove tool template selected in QListView.

remove_tool_template(self, index)[source]

Remove tool template from ToolTemplateModel and tool definition file path from project file. Removes also Tool templates from all Tool items that use this template.

remove_all_items(self)[source]

Slot for Remove All button.

remove_item(self, ind, delete_item=False, check_dialog=False)[source]

Removes item from project when it’s index in the project model is known. To remove all items in project, loop all indices through this method. This method is used in both opening and creating a new project as well as when item(s) are deleted from project. Use delete_item=False when closing the project or creating a new one. Setting delete_item=True deletes the item irrevocably. This means that data directories will be deleted from the hard drive. Handles also removing the node from the dag graph that contains it.

Parameters:
  • ind (QModelIndex) – Index of removed item in project model
  • delete_item (bool) – If set to True, deletes the directories and data associated with the item
  • check_dialog (bool) – If True, shows ‘Are you sure?’ message box
open_anchor(self, qurl)[source]

Open file explorer in the directory given in qurl.

Parameters:qurl (QUrl) – Directory path or a file to open
edit_tool_template(self, index)[source]

Open the tool template widget for editing an existing tool template.

Parameters:index (QModelIndex) – Index of the item (from double-click or contex menu signal)
open_tool_template_file(self, index)[source]

Open the Tool template definition file in the default (.json) text-editor.

Parameters:index (QModelIndex) – Index of the item
open_tool_main_program_file(self, index)[source]

Open the tool template’s main program file in the default editor.

Parameters:index (QModelIndex) – Index of the item
export_as_graphml(self)[source]

Exports all DAGs in project to separate GraphML files.

connection_data_changed(self, index)[source]

[OBSOLETE?] Called when checkbox delegate wants to edit connection data. Add or remove Link instance accordingly.

_handle_zoom_widget_minus_pressed(self)[source]

Slot for handling case when ‘-‘ button in menu is pressed.

_handle_zoom_widget_plus_pressed(self)[source]

Slot for handling case when ‘+’ button in menu is pressed.

_handle_zoom_widget_reset_pressed(self)[source]

Slot for handling case when ‘reset zoom’ button in menu is pressed.

setup_zoom_action(self)[source]

Setup zoom action in view menu.

restore_dock_widgets(self)[source]

Dock all floating and or hidden QDockWidgets back to the main window.

set_debug_qactions(self)[source]

Set shortcuts for QActions that may be needed in debugging.

hide_tabs(self)[source]

Hides project item info tab bar and connections tab in project item QTreeView. Makes (hidden) actions on how to show them if needed for debugging purposes.

add_toggle_view_actions(self)[source]

Add toggle view actions to View menu.

toggle_tabbar_visibility(self)[source]

Shows or hides the tab bar in project item info tab widget. For debugging purposes.

toggle_connections_tab_visibility(self)[source]

Shows or hides connections tab in the project item QTreeView. For debugging purposes.

update_datetime(self)[source]

Returns a boolean, which determines whether date and time is prepended to every Event Log message.

add_message(self, msg)[source]

Append regular message to Event Log.

Parameters:msg (str) – String written to QTextBrowser
add_success_message(self, msg)[source]

Append message with green text color to Event Log.

Parameters:msg (str) – String written to QTextBrowser
add_error_message(self, msg)[source]

Append message with red color to Event Log.

Parameters:msg (str) – String written to QTextBrowser
add_warning_message(self, msg)[source]

Append message with yellow (golden) color to Event Log.

Parameters:msg (str) – String written to QTextBrowser
add_process_message(self, msg)[source]

Writes message from stdout to process output QTextBrowser.

Parameters:msg (str) – String written to QTextBrowser
add_process_error_message(self, msg)[source]

Writes message from stderr to process output QTextBrowser.

Parameters:msg (str) – String written to QTextBrowser
show_add_data_store_form(self, x=0, y=0)[source]

Show add data store widget.

show_add_data_connection_form(self, x=0, y=0)[source]

Show add data connection widget.

show_add_data_interface_form(self, x=0, y=0)[source]

Show add data interface widget.

show_add_tool_form(self, x=0, y=0)[source]

Show add tool widget.

show_add_view_form(self, x=0, y=0)[source]

Show add view widget.

show_tool_template_form(self, tool_template=None)[source]

Show create tool template widget.

show_settings(self)[source]

Show Settings widget.

show_tool_config_asst(self)[source]

Show Tool configuration assistant widget.

show_about(self)[source]

Show About Spine Toolbox form.

show_user_guide(self)[source]

Open Spine Toolbox documentation index page in browser.

show_getting_started_guide(self)[source]

Open Spine Toolbox Getting Started HTML page in browser.

show_item_context_menu(self, pos)[source]

Context menu for project items listed in the project QTreeView.

Parameters:pos (QPoint) – Mouse position
show_item_image_context_menu(self, pos, name)[source]

Context menu for project item images on the QGraphicsView.

Parameters:
  • pos (QPoint) – Mouse position
  • name (str) – The name of the concerned item
show_project_item_context_menu(self, pos, ind)[source]

Create and show project item context menu.

Parameters:
  • pos (QPoint) – Mouse position
  • ind (QModelIndex) – Index of concerned item

Context menu for connection links.

Parameters:
  • pos (QPoint) – Mouse position
  • link (Link(QGraphicsPathItem)) – The concerned link
show_tool_template_context_menu(self, pos)[source]

Context menu for tool templates.

Parameters:pos (QPoint) – Mouse position
show_dc_ref_properties_context_menu(self, pos)[source]

Create and show a context-menu in data connection properties references view.

Parameters:pos (QPoint) – Mouse position
show_dc_data_properties_context_menu(self, pos)[source]

Create and show a context-menu in data connection properties data view.

Parameters:pos (QPoint) – Mouse position
show_tool_properties_context_menu(self, pos)[source]

Create and show a context-menu in Tool properties if selected Tool has a Tool template.

Parameters:pos (QPoint) – Mouse position
show_view_properties_context_menu(self, pos)[source]

Create and show a context-menu in View properties.

Parameters:pos (QPoint) – Mouse position
show_di_files_properties_context_menu(self, pos)[source]

Create and show a context-menu in Data Interface properties source files view.

Parameters:pos (QPoint) – Mouse position
remove_refs_with_del_key(self)[source]

Slot that removes selected references from the currently selected Data Connection. Used when removing DC references by pressing the Delete key on keyboard (Qt.Key_Delete).

remove_data_with_del_key(self)[source]

Slot that removes selected data files from the currently selected Data Connection. Used when removing DC data files by pressing the Delete key on keyboard (Qt.Key_Delete).

close_view_forms(self)[source]

Closes all GraphViewForm, TreeViewForm, and TabularViewForm instances opened in Data Stores and Views. Ensures that close() method is called on all corresponding DiffDatabaseMapping instances, which cleans up the databases. Also closes all SpineDatapackageWidget instances opened in Data Connections.

show_confirm_exit(self)[source]

Shows confirm exit message box.

Returns:True if user clicks Yes or False if exit is cancelled
show_save_project_prompt(self)[source]

Shows the save project message box.

closeEvent(self, event=None)[source]

Method for handling application exit.

Parameters:event (QEvent) – PySide2 event