Welcome to Spine Toolbox’s User Guide!¶
Spine Toolbox is an application, which provides means to define, manage, and execute complex data processing and computation tasks, such as energy system models.
You can either start reading from the first page onwards or go straight to the Getting Started section to get you started quickly. If you need help understanding the terms we use throughout the app and this User Guide, please check the Terminology section. If you want to contribute to this project, please see the Contribution Guide for Spine Toolbox. The last section contains the complete code reference of Spine Toolbox.
Getting Started¶
Welcome to the Spine Toolbox’s getting started guide. In this guide you will learn two ways of running a “Hello, World!” program on Spine Toolbox. The following topics are touched (although not exhaustively covered):
Spine Toolbox Interface¶
The central element in Spine Toolbox’s interface is the Design View, where you can visualize and manipulate your project in a pictorial way. Alongside Design view there are a few ‘dock widgets’ that provide additional functionality:
Project provides a more concise view of your project, including:
- Items currently in the project, grouped by category: Data Stores, Data Connections, Tools, Views, and Data Interfaces.
- Tool templates available in the project.
Properties provides an interface to interact with the currently selected project item.
Event Log shows relevant messages about every performed action.
Process Log shows the output of executed Tools.
Julia console provides an interface to interact with the Julia programming language, and also allows Spine Toolbox to execute Julia Tools.
Python console provides an interface to interact with the Python programming language, and also allows Spine Toolbox to execute Python Tools.
Tip
You can drag-and-drop the Dock Widgets around the screen, customizing the interface at your will. Also, you can select which ones are shown/hidden using either the View/Dock Widgets menu, or the main menu toolbar’s context menu. Spine Toolbox remembers your configuration between sessions. Selecting Restore Dock Widgets from the View/Dock Widgets menu restores the widgets back to their default location.
Tip
Most elements in the Spine Toolbox’s interface are equipped with tool tips. Leave your mouse cursor over an element (button, view, etc.) for a moment to make the tool tip appear.
Creating a Project¶
To create a new project, please do one of the following:
- From the application main menu, select File -> New project…
- Press Ctrl+N.
The New Project form will show up. Type ‘hello world’ in the name field —we will leave the description empty this time— and click Ok.
Congratulations, you have created a new project.
Creating a Tool template¶
Note
Spine Toolbox is designed to run and connect multiple tools, which are specified using Tool Templates. You may think of a Tool Template as a self-contained program specification including a list of source files, required and optional input files, and expected output files. Once a Tool template is added to a project, it can then be associated to a Tool item for its execution as part of the project workflow.
In the Project dock widget, click on the ‘add tool template button’ ()
just below the Tool templates list, and select New from the popup menu.
The Edit Tool Template form will appear. Follow the instructions below to create a minimal Tool template:
- Type ‘hello_world’ in the Type name here… field.
- Select ‘Python’ from the Select type… dropdown list,
- Click on the
button right next to the field that reads Add main program file here…, and select the option Make new main program from the popup menu.
- A file browser dialog should open. Name the file hello_world.py and save it in a folder of your choice.
After this, the Edit Tool Template form should be looking similar to this:

Click Ok at the bottom of the form. A new system dialog will appear, allowing you to select a file name and location to save the Tool template we’ve just created. Don’t change the default file name, which should be hello_world.json. Just select a folder from your system (it can be the same where you saved the main program file) and click Save.
Now you should see the new tool template in the Project widget, Tool templates list.
Tip
Saving the Tool template into a file allows you to add and use the same Tool template in
another project. To do this, you just need to click on the add tool button (),
select Add existing… from the popup menu, and then select the tool template file from your system.
Congratulations, you have just created your first Tool template.
However, the main program file hello_world.py was created empty, so for the moment this Tool template does absolutely nothing. To change that, we need to add instructions to that program file so it actually does something when executed.
Right click on the ‘hello_world’ item in the Tool templates list and select Edit main program file… from the context menu. This will open the file hello_world.py in your default editor.
Enter the following into the file’s content:
print("Hello, World!")
Save the file.
Now, whenever hello_world.py is executed, the sentence ‘Hello, World!’ will be printed to the standard output.
Adding a Tool item to the project¶
Note
The Tool item is used to run Tool templates available in the project.
Let’s add a Tool item to our project, so that we’re able to run the Tool template we created above. To add a Tool item please do one of the following:
- From the application main menu, select Edit -> Add Tool.
- Drag-and-drop the Tool icon (
) from the Drag & Drop Icon toolbar onto the Design View.
The Add Tool form will popup. Type ‘say hello world’ in the name field, select ‘hello_world’ from the dropdown list just below, and click Ok. Now you should see the newly added Tool item as an icon in the Design View, and also as an entry in the Project dock widget, Items list, under the ‘Tools’ category. It should look similar to this:

Executing a Tool¶
As long as the ‘say hello world’ Tool item is selected, you will be able to see its Properties on the right part of the window, looking similar to this:

Press execute project button on the toolbar. This will execute the Tool template ‘hello world’,
which in turn will run the main program file hello_world.py in a dedicated process.
You can see more details about execution in the Event Log. Once it’s finished, you will see its output in the Process Log or in the Python Console depending on your settings (See Settings).

Congratulations, you just ran your first Spine Toolbox project.
Editing a Tool template¶
To make things more interesting, we will now specify an input file for our ‘hello_world’ Tool template.
Note
Input files specified in the Tool template can be used by the program source files, to obtain some relevant information for the Tool’s execution. When executed, a Tool item looks for input files in Data Connection and Data Store items connected to its input.
Click on the ‘tool template options’ button () in ‘say hello world’
Properties, and select Edit Tool template from the popup menu.
This will open the ‘Edit Tool Template’ form pre-filled with data from the ‘hello_world’ template.
Click the add input files and/or directories button right below the Input files list
A dialog will appear that lets you can enter a
name for a new input file. Type ‘input.txt’ and click Ok. The form
should now be looking like this:

Click Ok at the bottom of the form.
Note
See Tool template editor for more information on editing Tool templates.
So far so good. Now let’s use this input file in our program.
Click on the ‘tool template options’ button () again,
and this time select Edit main program file… from the popup menu. This will open the file
hello_world.py in your default editor.
Delete whatever it’s in the file and enter the following instead:
with open("input.txt") as input_file:
print(input_file.read())
Save the file.
Now, whenever hello_world.py is executed, it will look for a file called ‘input.txt’ in the current directory, and print its content to the standard output.
Try executing the tool by pressing in the toolbar.
The execution will fail. This is because the file ‘input.txt’ is not
made available for the Tool:

Adding a Data Connection item to the project¶
Note
The Data Connection item is used to hold and manipulate generic data files, so that other items, notably Tool items, can make use of that data.
Let’s add a Data Connection item to our project, so that we’re able to pass the file ‘input.txt’ to ‘say hello world’. To add a Data Connection item, please do one of the following:
- From the application main menu, click Edit -> Add Data Connection.
- Drag-and-drop the Data Connection icon (
) from the main window toolbar onto the Design View.
The Add Data Connection form will show up. Type ‘pass input txt’ in the name field and click Ok. Now you should see the newly added Data Connection item as an icon in the Design View, and also as an entry in the Project dock widget, Items list, under the ‘Data Connections’ category. It should look similar to this:

Adding data files to a Data Connection¶
As long as the ‘pass input txt’ Data Connection item is selected, you will be able to see its Properties on the right part of the window, looking similar to this:

Right click anywhere within the Data box and select New file… from the context menu. When prompted to enter a name for the new file, type ‘input.txt’ and click Ok.
Now you should see the newly created file in the Data list:

Double click on this file to open it in your default text editor. Then enter the following into the file’s content:
Hello again, World!
Save the file.
Connecting project items¶
As mentioned above, a Tool item looks for input files in Data Connection and Data Store items connected to its input. Thus, what we need to do now is create a connection from ‘pass input txt’ to ‘say hello world’, so the file ‘input.txt’ gets passed.
To do this, click on one of the connector slots at the edges of ‘pass input txt’ in the Design view, and then on a similar slot in ‘say hello world’. This will create an arrow pointing from one to another, as seen below:

Press on the toolbar. The Tool will run successfully this time:

That’s all for now. I hope you’ve enjoyed following this guide as much as I enjoyed writing it. See you next time.
Tutorials¶
Welcome to the Spine Toolbox’s tutorials page. The following tutorials are available:
Case Study A5 tutorial¶
Welcome to Spine Toolbox’s Case Study A5 tutorial. Case Study A5 is one of the Spine Project case studies designed to verify Toolbox and Model capabilities. To this end, it reproduces an already existing study about hydropower on the Skellefte river, which models one week of operation of the fifteen power stations along the river.
This tutorial provides a step-by-step guide to run Case Study A5 on Spine Toolbox and is organized as follows:
Introduction¶
Model assumptions¶
For each power station in the river, the following information is known:
- The capacity, or maximum electricity output. This datum also provides the maximum water discharge as per the efficiency curve (see next point).
- The efficiency curve, or conversion rate from water to electricity. In this study, a piece-wise linear efficiency with two segments is assumed. Moreover, this curve is monotonically decreasing, i.e., the efficiency in the first segment is strictly greater than the efficiency in the second segment.
- The maximum magazine level, or amount of water that can be stored in the reservoir.
- The magazine level at the beginning of the simulation period, and at the end.
- The minimum amount of water that the plant needs to discharge at every hour. This is usually zero (except for one of the plants).
- The minimum amount of water that needs to be spilled at every hour. Spilled water does not go through the turbine and thus does not serve to produce electricity; it just helps keeping the magazine level at bay.
- The downstream plant, or next plant in the river course.
- The time that it takes for the water to reach the downstream plant. This time can be different depending on whether the water is discharged (goes through the turbine) or spilled.
- The local inflow, or amount of water that naturally enters the reservoir at every hour. In this study, it is assumed constant over the entire simulation period.
- The hourly average water discharge. It is assumed that before the beginning of the simulation, this amount of water has constantly been discharged at every hour.
The system is operated so as to maximize total profit over the week, while respecting capacity constraints, maximum magazine level constrains, and so on. Hourly profit per plant is simply computed as the product of the electricity price and the production, minus a penalty for changes on the water discharge in two consecutive hours. This penalty is computed as the product of a constant penalty factor, common to all plants, and the absolute value of the difference in discharge with respect to the previous hour.
Modelling choices¶
The model of the electric system is fairly simple, only two elements are needed:
- A common electricity node.
- A load unit that takes electricity from that node.
On the contrary, the model of the river system is more detailed. Each power station in the river is modelled using the following elements:
- An upper water node, located at the entrance of the station.
- A lower water node, located at the exit of the station.
- A reservoir unit, that takes water from the upper node to put it into a water storage and viceversa.
- A power plant unit, that discharges water from the upper node into the lower node, and feeds electricity produced in the process to the common electricity node.
- A spillway connection, that takes spilled water from the upper node and releases it to the downstream upper node.
- A discharge connection, that takes water from the lower node and releases it to the downstream upper node.
Below is a schematic of the model. For clarity, only the Rebnis station is presented in full detail:

Guide¶
Installing requirements¶
Make sure that Spine Toolbox and julia 1.0 (or greater) are properly installed as described at the following links:
Setting up project¶
Launch Spine Toolbox and from the main menu, select File -> New… to create a new project. Type “Case Study A5” as the project name and click Ok.
Drag the Data Store icon (
) from the toolbar and drop it into the Design View. This will open the Add Data Store dialog. Type “input” as the Data Store name and click Ok.
Repeat the above operation to create a Data Store called “output”.
Drag the Tool icon (
) from the toolbar and drop it into the Design View. This will open the Add Tool dialog. Type “Spine model” as the Tool name and click Ok.
Note
Each item in the Design view is equipped with three connectors (the small squares at the item boundaries).
Click on one of “input” connectors and then on one of “Spine model” connectors. This will create a connection from the former to the latter.
Repeat the procedure to create a connection from “Spine model” to “output”. It should look something like this:
Todo
Add image
From the main menu, select File -> Save project.
Entering input data¶
Creating input database¶
Follow the steps below to create a new Spine database for Spine Model in the ‘input’ Data Store:
- Select the ‘input’ Data Store item in the Design View.
- Go to Data Store Properties, check the box that reads For Spine Model and press New Spine db.
Still in Data Store Properties, click Tree view. This will open the newly created database in the Data store tree view, looking similar to this:
Note
The Data store tree view is a dedicated interface within Spine Toolbox for visualizing and managing Spine databases.
Creating objects¶
Follow the steps below to add power plants to the model as objects of class
unit
:Go to Object tree, right-click on
unit
and select Add objects from the context menu. This will open the Add objects dialog.With your mouse, select the list of plant names from the text-box below and copy it to the clipboard (Ctrl+C):
Rebnis_pwr_plant Sadva_pwr_plant Bergnäs_pwr_plant Slagnäs_pwr_plant Bastusel_pwr_plant Grytfors_pwr_plant Gallejaur_pwr_plant Vargfors_pwr_plant Rengård_pwr_plant Båtfors_pwr_plant Finnfors_pwr_plant Granfors_pwr_plant Krångfors_pwr_plant Selsfors_pwr_plant Kvistforsen_pwr_plant
Go back to the Add objects dialog, select the first cell under the object name column and press Ctrl+V. This will paste the list of plant names from the clipboard into that column, looking similar to this:
Click Ok.
Back in the Data store tree view, under Object tree, double click on
unit
to confirm that the objects are effectively there.From the main menu, select Session -> Commit to open the Commit changes dialog. Enter “Add power plants” as the commit message and click Commit.
Repeat the procedure to add reservoirs as objects of class
unit
, with the following names:Rebnis_rsrv Sadva_rsrv Bergnäs_rsrv Slagnäs_rsrv Bastusel_rsrv Grytfors_rsrv Gallejaur_rsrv Vargfors_rsrv Rengård_rsrv Båtfors_rsrv Finnfors_rsrv Granfors_rsrv Krångfors_rsrv Selsfors_rsrv Kvistforsen_rsrv
Repeat the procedure to add discharge and spillway connections as objects of class
connection
, with the following names:Rebnis_to_Bergnäs_disch Sadva_to_Bergnäs_disch Bergnäs_to_Slagnäs_disch Slagnäs_to_Bastusel_disch Bastusel_to_Grytfors_disch Grytfors_to_Gallejaur_disch Gallejaur_to_Vargfors_disch Vargfors_to_Rengård_disch Rengård_to_Båtfors_disch Båtfors_to_Finnfors_disch Finnfors_to_Granfors_disch Granfors_to_Krångfors_disch Krångfors_to_Selsfors_disch Selsfors_to_Kvistforsen_disch Kvistforsen_to_downstream_disch Rebnis_to_Bergnäs_spill Sadva_to_Bergnäs_spill Bergnäs_to_Slagnäs_spill Slagnäs_to_Bastusel_spill Bastusel_to_Grytfors_spill Grytfors_to_Gallejaur_spill Gallejaur_to_Vargfors_spill Vargfors_to_Rengård_spill Rengård_to_Båtfors_spill Båtfors_to_Finnfors_spill Finnfors_to_Granfors_spill Granfors_to_Krångfors_spill Krångfors_to_Selsfors_spill Selsfors_to_Kvistforsen_spill Kvistforsen_to_downstream_spill
Repeat the procedure to add water storages as objects of class
storage
, with the following names:Rebnis_stor Sadva_stor Bergnäs_stor Slagnäs_stor Bastusel_stor Grytfors_stor Gallejaur_stor Vargfors_stor Rengård_stor Båtfors_stor Finnfors_stor Granfors_stor Krångfors_stor Selsfors_stor Kvistforsen_stor
Repeat the procedure to add water nodes as objects of class
node
, with the following names:Rebnis_upper Sadva_upper Bergnäs_upper Slagnäs_upper Bastusel_upper Grytfors_upper Gallejaur_upper Vargfors_upper Rengård_upper Båtfors_upper Finnfors_upper Granfors_upper Krångfors_upper Selsfors_upper Kvistforsen_upper Rebnis_lower Sadva_lower Bergnäs_lower Slagnäs_lower Bastusel_lower Grytfors_lower Gallejaur_lower Vargfors_lower Rengård_lower Båtfors_lower Finnfors_lower Granfors_lower Krångfors_lower Selsfors_lower Kvistforsen_lower
Finally, add
water
andelectricity
as objects of classcommodity
;electricity_node
as an object of clasnode
;electricity_load
as an object of classunit
; andsome_week
andpast
as objects of classtemporal_block
.
Establishing relationships¶
Follow the steps below to establish that power plant units receive water from the station’s upper node at each time slice in the one week horizon, as relationships of class
unit__node__direction__temporal_block
:Go to Relationship tree, right-click on
unit__node__direction__temporal_block
and select Add relationships from the context menu. This will open the Add relationships dialog.Select again all power plant names and copy them to the clipboard (Ctrl+C).
Go back to the Add relationships dialog, select the first cell under the unit name column and press Ctrl+V. This will paste the list of plant names from the clipboard into that column.
Repeat the procedure to paste the list of upper node names into the node name column.
For each row in the table, enter
from_node
under direction name andsome_week
under temporal block name. Now the form should be looking like this:Tip
To enter the same text on several cells, copy the text into the clipboard, then select all target cells and press Ctrl+V.
Click Ok.
Back in the Data store tree view, under Relationship tree, double click on
unit__node__direction__temporal_block
to confirm that the relationships are effectively there.From the main menu, select Session -> Commit to open the Commit changes dialog. Enter “Add sending nodes of power plants” as the commit message and click Commit.
Repeat the procedure to establish that power plant units release water to the station’s lower node at each time slice in the one week horizon, as relationships of class
unit__node__direction__temporal_block
:Repeat the procedure to establish that power plant units release electricity to the common electricity node at each time slice in the one week horizon, as relationships of class
unit__node__direction__temporal_block
:Repeat the procedure to establish that reservoir units take and release water to and from the station’s upper node at each time slice in the one week horizon, as relationships of class
unit__node__direction__temporal_block
:Repeat the procedure to establish that the electricity load takes electricity from the common electricity node at each time slice in the one week horizon, as a relationship of class
unit__node__direction__temporal_block
:Repeat the procedure to establish that discharge connections take water from the lower node of one station and release it to the upper node of the downstream station, at each time slice in the one week horizon, as relationships of class
connection__node__direction__temporal_block
:Repeat the procedure to establish that spillway connections take water from the upper node of one station and release it to the upper node of the downstream station, at each time slice in the one week horizon, as relationships of class
connection__node__direction__temporal_block
:Repeat the procedure to establish that water nodes balance water, and the electricity node balances electricity, as relationships of class
node__commodity
:Repeat the procedure to establish that all nodes are balanced at each time slice in the one week horizon, as relationships of class
node__temporal_block
:Repeat the procedure to establish the connection of each storage to the corresponding unit, as relationships of class
storage__unit
:Repeat the procedure to establish that all storages store water, as relationships of class
storage__commodity
:
Running Spine model¶
Configuring Julia¶
- Go to Spine Toolbox mainwindow and from the main menu, select File -> Settings. This will open the Settings dialog.
- Go to the Julia group box and enter the path to your julia executable in the first line edit.
- (Optional) Enter the path of a julia project that you want to use with Spine Toolbox in the second line edit. Leave blank to use julia’s home project.
- Click Ok.
- From the application main menu, select File -> Tool configuration assistant. This will install the Spine Model package to the julia project specified above. Follow the instructions until completion.
Main Window¶
This section describes the different components in the application main window.
The first time you start the application you will see the main window like this.

The application main window contains six dock widgets (Project, Properties, Event Log, Process Log, Julia Console, and Python Console), a tool bar, a Design view, and a menu bar with File, Edit, View, and Help menus. The Project dock widget contains a list of project items and Tool templates that are available in your project. The Properties dock widget shows the properties of the selected project item. Event Log shows messages depending on what you do in Spine Toolbox. Process Log shows messages from processes that are spawned by the application, i.e. it shows the stdout and stderr streams of GAMS, Julia, Python (if Tools are executed without embedded Julia and Python Consoles, see Settings section), and executable programs. Julia and Python Consoles provide full iJulia and a iPython consoles. If you choose to execute Julia tools in the embedded Julia Console, the Julia code will be included into the Julia Console and executed there. You can interact with the iJulia in the Julia Console like you would with any iJulia you use.
Tip
You can configure the Julia and Python versions you want to use in File->Settings
.
The menu bar in the top of the application contains File, Edit, View, and Help menus. In the File menu
you can create a new project, save the project, open an existing project, rename your project, and open the
application Settings among other things. Spine Toolbox is project based, which means that you need to create
a new project or open an existing one before you can do anything. You can create a new project by selecting
File->New project...
from the menu bar. Drag & Drop Icon tool bar contains the available
project item types. The button can be used to remove all items from your project.
The Execute icons control the execution of the items in the Design view where you build your project.
The
button executes all Directed-Acyclic Graphs (DAG) in the project in a row. The
button
executes the selected DAG. You can select a DAG to be executed by selecting a single project item from the desired
DAG in the Design View. The
button terminates DAG execution (if running).
You can add a new project item to your project by pointing your mouse cursor on any of the draggable items in the Drag & Drop Icon tool bar, then click-and-drag the item on to the Design view. After this you will be presented a dialog, which asks you to fill in basic information about the new project item (name, description, etc.).
The main window is very customizable so you can e.g. close the dock widgets that you do not need and/or you can resize the views to fit your needs and display size or resolution.
Note
If you want to restore all dock widgets to their default place use the menu item View->Dock Widgets->
Restore Dock Widgets
. This will show all hidden dock widgets and restore them to the main window.
Here is one example, how you can customize the main window. In the picture, a user has created a project First project, which contains five project items. A Data Store called Database, a Data Connection called Data Files, A Tool called Julia Model, a View called View, and a Data Interface called Mapper. You can also see the project items categorized by their project item type in the Project dock widget.

Project Items¶
Project items in the Design view and the connections between them make up the graph (Directed Acyclic Graph, DAG)
that is executed when the or
buttons are pressed.
See Executing Projects for more information on how the DAG is processed by Spine Toolbox.
The following items are currently available:
Data Store
¶
A Data store item represents a connection to a Spine model database. Currently, the item supports sqlite and mysql dialects. The database can be accessed and modified using data store views available from the item’s properties or from a right-click context menu.
Data Connection
¶
A Data connection item provides access to data files. It also provides access to the Datapackage editor.
Tool
¶
Tool is the heart of a DAG. It is usually the actual model to be executed in Spine Toolbox but can be an arbitrary script or executable as well. A tool is specified by its template.
View
¶
A View item is meant for inspecting data from multiple sources using the data store views. Note that the data is opened in read-only mode so modifications are not possible from the View item.
Note
Currently, only Tree view supports multiple databases.
Data Interface
¶
This item provides mapping from tabulated data (comma separated values, Excel) to the Spine data model.
Tool template editor¶
This section describes how to make a new Tool template and how to edit existing Tool templates.
To execute a Julia, Python, GAMS, or an executable script in Spine Toolbox, you must first create a Tool template to your project. You can open the Tool template editor in several ways. One way is to press the Tool icon with a plus button in the Project dock widget. This presents you a pop-up menu with the New and Add existing… options.

When you click on New the following form pops up.

Start by giving the Tool template a name. Then select the type of the Tool. You have four options (Julia,
Python, GAMS or Executable). Then select, whether you want the Tool template to be executed in the work directory or
in its source directory (See Terminology section). You can give the Tool template a description,
describing what the Tool template does. Main program file is the main file of your simulation model, or an
executable script. You can create a blank file into a new directory by pressing the button and selecting
Make new main program or you can browse to find an existing main program file by pressing the same button and
selecting Select existing main program. Command line arguments will be appended to the actual command that
Spine Toolbox executes in the background, e.g. if you have a Windows batch file called do_things.bat, which
accepts command line arguments a and b. If you set a b on the command line arguments. This is the equivalent
of running the batch file in command prompt with the command do_things.bat a b.
Additional source files is a list of files that the main program requires in order to run. You can add individual files or whole directories at once to this list.
Tip
You can also drag&drop a directory from your operating systems File Explorer into the Additional source files list.
Input files is a list of input data files that the program requires in order to execute. You can also add directories and subdirectories. Wildcards are not supported (see Optional input files).
Examples:
- data.csv -> File is copied to the same work directory as the main program
- input/data.csv -> Creates directory input/ to the work directory and copies file data.csv there
- output/ -> Creates an empty directory output/ into the work directory
Optional input files are files that may be utilized by your program if they are found. Unix-style wildcards ? and * are supported.
Examples:
- data.csv -> If found, file is copied to the same work directory as the main program
- *.csv -> All found .csv files are copied to the same work directory as the main program
- input/data_?.dat -> All found files matching the pattern data_?.dat are copied into input/ directory in the work directory.
Output files are files that will be archived into a timestamped result directory of the Tool’s project directory after the Tool template has finished execution. Unix-style wildcards ? and * are supported.
Examples:
- results.csv -> File is copied from work directory into results directory
- *.csv -> All .csv files from work directory are copied into results directory
- output/*.gdx -> All GDX files from the work directory’s output/ subdirectory will be copied to into output/ subdirectory in the results directory.
When you are happy with your Tool template, click Ok, and you will be asked where to save the Tool template file. It is recommended to save the file into the same directory where the main program file is located. The Tool template file is a text file in JSON format and has an extension .json
Tip
Only name, type, and main program file fields are required to make a Tool template. The other fields are optional.
Here is a minimal Tool template for a Julia script script.jl

Note
Under the hood, the contents of the Tool template are saved to a Tool template definition file in JSON format. Users do not need to worry about the contents of these files since reading and writing them is managed by the app. For the interested, here are the contents of the Tool template definition file that we just created.:
{
"name": "Example Tool template",
"description": "",
"tooltype": "julia",
"execute_in_work": true,
"includes": [
"script.jl"
],
"inputfiles": [],
"inputfiles_opt": [],
"outputfiles": [],
"cmdline_args": ""
}
After the user has clicked Ok and saved the file, the new Tool template has been added to the project.

To edit this Tool template, just right-click on the Tool template name and select Edit Tool template from the context-menu.
You are now ready to execute the Tool template in Spine Toolbox. You just need to select a Tool item in the
Design view, set the template Example Tool template to it, and click or
button.
Executing Projects¶
This section describes how executing a project works. Execution happens by pressing the or the
buttons in the main window tool bar. A project consists of project items and connections (yellow arrows) that
are visualized on the Design View. You use the project items and the connections to build a Directed Acyclic
Graph (DAG), with the project items as nodes and the connections as edges. A DAG is traversed using the
breadth-first-search algorithm.
Rules of DAGs:
- A single project item with no edges is a DAG.
- All project items that are connected, are considered as a single DAG. It does not matter, which direction the edges go. If there is a path between two nodes, they are considered as belonging to the same DAG.
- Loops are not allowed (this is what acyclic means).
You can connect the nodes in the Design View how ever you want but you cannot execute the resulting DAGs if they break the rules above. Here is an example project with three DAGs.

- DAG 1: nodes: a, b, c, d. edges: a-b, a-c, b-d, c-d
- DAG 2: nodes: e, f. edges: e-f
- DAG 3: nodes: g. edges: None
When you press the button, all three DAGs are executed in a row. You can see the progress and the current
executed node in the Event Log. Execution order of DAG 1 is a->b->c->d or
a->c->b->d since nodes b and c are siblings. DAG 2 execution order is e->f and DAG 3 is just g. If you have
a DAG in your project that breaks the rules above, that DAG is skipped and the execution continues with the next DAG.
You can execute a single DAG in the project by selecting a node in the desired DAG and pressing the
button in the tool bar. For example, to execute only DAG 1 you can select (in Design View or in the project item
list in Project dock widget) any of the nodes a, b, c, or d and then press the
button.
Tip
If you are not sure how execution works in your DAG, you can test the execution just like in the above picture by adding and connecting empty Data Connection items and then pressing the play buttons.
Executing Tools as a part of the DAG¶
All project items in the DAG are executed, but the real processing only happens when a Tool project item is executed. When you have created at least one Tool template, you can execute a Tool as part of the DAG. The Tool template defines the process that is depicted by the Tool project item. As an example, below we have two project items; Julia Model Tool and Data File Data Connection connected as a DAG with an edge between the nodes.

Selecting the Julia Model shows its properties in the Properties dock widget. In the top of the Tool Properties, there is a template drop-down menu. From this drop-down menu, you can select the Tool template for this particular Tool item. The Example Tool Template tool template has been selected for the Tool Julia Model. Below the drop-down menu, you can see the details of the Tool template, command line arguments, Source files (the first one is the main program file), Input files, Optional input files and Output files. Results… button opens the Tool’s result archive directory in the File Explorer (all Tools have their own result directory). The Execute in radio buttons control, whether this Tool is first copied to a work directory and executed there, or if the execution should happen in the source directory where the main program file is located.
Note
The Example Tool Template has been modified a bit from previous sections. It now requires an Input file data.csv.
When you click on the button, the execution starts from the Data File Data Connection. When executed,
Data Connection items advertise their files and references to project items that are in the same DAG and
executed after them. In this particular example, the Data File item contains a file called data.csv as depicted
in the below picture.

When it’s the Julia Model tools turn to be executed, it checks if it finds the file data.csv from project items, that have already been executed. When the DAG is set up like this, the Tool finds the input file that it requires and then starts processing the Tool template starting with the main program file script.jl. Note that if the edge would be the other way around (from Julia Model to Data File) execution would start from the Julia Model and it would fail because it cannot find the required file data.csv. The same thing happens if there is no edge between the two project items. In this case the project items would be in separate DAGs.
Since the Tool template type was set as Julia and the main program is a Julia script, Spine Toolbox starts the execution in the Julia Console (if you have selected this in the application Settings, See Settings section).
Tool execution algorithm¶
The below figure depicts what happens when a Tool item with a valid Tool template is executed.

Settings¶
Spine Toolbox settings are categorized in the following way
Application settings¶
You can open the application settings from the main window menu File->Settings…, or by pressing F1.

The settings on this form have been categorized into six categories. General, GAMS, Julia, Python and Data store views settings are general application settings, which affect all projects. Settings in the Project category only affect the current project.
General settings¶
- Open previous project at startup If checked, application opens the project at startup that was open the last time the application was shut down. If left unchecked, application starts without a project open.
- Show confirm exit prompt If checked, confirm exit prompt is shown. If unchecked, application exits without prompt.
- Save project at exit Unchecked: Does not save project and does not show message box. Partially checked: Shows message box (default). Checked: Saves project and does not show message box.
- Show date and time in Event Log messages If checked, date and time is appended into every Event Log message.
- Delete data when project item is removed from project Check this box to delete project item’s data when a project item is removed from project. This means, that the project item directory and its contents will be deleted from your hard drive.
- Project directory Directory where projects are saved. This is non-editable at the moment.
- Smooth zoom Controls the way zooming (by using the mouse wheel) behaves in Design View and Graph View. Controls if the zoom in/out is continuous or discrete. On older computers, smooth zoom is not recommended.
- Design View background Choosing grid shows a black grid as the Design View background. Choosing Solid and then clicking on the square next to it let’s you choose the background color.
GAMS settings¶
- GAMS program Path to Gams executable you wish to use to execute GAMS Tool templates. Leave this blank to use the system GAMS i.e. GAMS set up in your system PATH variable.
Julia settings¶
- Julia executable Path to Julia executable you wish to use to execute Julia Tool templates. This is the Julia that will be used in the embedded Julia Console and also the Julia that is used when executing Julia Tool templates as in the shell. Leave this blank, if you wish to use the system Julia.
- Julia home project Set the Julia home project here.
- Use embedded Julia Console Check this box to execute Julia Tool templates in the built-in Julia Console. If
you leave this un-checked, Julia Tool templates will be executed as in the shell. For example, on Windows this
would be the equivalent as running command
julia.exe example_script.jl
in the command prompt. If you decide to use the embedded Julia Console, theexample_script.jl
is included into the console and executed there. It is highly recommended to use the embedded Julia Console, since this gives significant performance improvements compared to shell execution.
Python settings¶
- Python interpreter Path to Python executable you wish to use to execute Python Tool templates. This is the Python that will be used in the embedded Python Console and also the Python that is used when executing Python Tool templates as in the shell. Leave this blank, if you wish to use the system Python.
- Use embedded Python Console Check this box to execute Python Tool templates in the embedded iPython Console.
If you un-check this box, Python Tool templates will be executed as in the shell. For example, on Windows this
would be the equivalent as running command
python.exe script.py
in the command prompt. If you decide to use the embedded Python Console, thescript.py
is executed there.
Data Store views settings¶
- Commit session when view is closed This checkbox controls what happens when you close the Tree view, the Graph view, or the tabular view and when you have uncommitted changes. Unchecked: Does not commit session and does not show message box. Partially checked: Shows message box (default). Checked: Commits session and does not show message box.
Project settings¶
These settings affect only the project that is currently open.
- Name Current project name. If you want to change the name of the project, use menu option File-Save as….
- Description Current project description. You can edit the description here.
- Work directory Directory where processing the Tool takes place. You can change this directory. Make sure to clean up the directory every now and then.
Project item settings / properties¶
Each project item (Data Store, Data Connection, Tool, View, and Data Interface) has its own set of properties. These are saved into the project save file. You can view and edit them in project item properties on the main window.
Application preferences¶
Spine Toolbox remembers the size, location, and placement of most of the application windows from the previous session (i.e. when closing and restarting the app).
Where are the Settings stored?¶
Application Settings and Preferences are saved to a location that depends on your operating system. On Windows,
there is no separate settings file, the settings are stored into registry key
HKEY_CURRENT_USER\Software\SpineProject\Spine Toolbox
. It is safe to delete this key if you want to reset
application to factory settings.
Projects are saved to .proj files in the Project directory. In addition, each project has its own dedicated directory under the Project directory which can be used to keep data from different projects separate. All project items in a project have their own directory under that project’s directory, where individual project item data can be stored (e.g. .sqlite files in Data Store directories).
Data store views¶
This section describes the different interfaces for viewing and editing data in a Spine database.
To open any of the viewing interfaces, select a Data Store and click the corresponding button in its Properties:

Tabular view¶
The Tabular view is used to display and edit the data in a Spine database via a table-like interface. The interface lets you filter and pivot the data for exploration and editing. To start the Tabular view, select a Data Store item and press the Tabular view button in its Properties.

The Tabular view has three main components:
- Selection component (1), where you can select the object class or relationship class to visualize.
- Pivot lists (2), where you can transform the data view and choose, e.g., which items go into rows and which into columns.
- Main table (3), where the actual data is displayed.
From the drop-down list at the top of the selection component, you can select two different input types:
- value: display all objects (or relationships), as well as all parameters and parameter values for the selected object (or relationship) class.
- set: display only the objects (or relationships) for the selected object (or relationship) class.
Pivoting and filtering data¶
You can transform (pivot) the data-view by dragging items across the Pivot lists:

Here is how each of the Pivot lists works:
- Rows: All items in this list are displayed in the Main table so there is a unique row for each object (or relationship) that belongs to that object (or relationship) class.
- Columns: All items in this list are displayed in the Main table so there is a unique column for each object (or relationship) that belongs to that object (or relationship) class.
- Frozen: All items in this list are excluded from the Main table and shown in the Frozen values table instead; the Main table is then filtered by the selected item in the Frozen values table.
To filter a specific item you can use the filter buttons just above the Main view. You can apply multiple filters at the same time.
Editing Data¶
When editing parameter values, cells get painted in different colors:

- Green: New data
- Yellow: Edited data
- Red: Deleted data
To restore a cell to its initial value, right click on it and select Restore value from the context menu. You can also hover an edited cell to see the original value.
When editing item names, cells also get painted in different colors although their meaning is a bit different:

- Green: New item. This means that all objects and parameters in green cells will be inserted when committing changes.
- Red: Invalid item. This means that the item, as well as all data for that row/column cannot be inserted when committing changes. The affected rows/columns will get a gray background. Invalid names are:
- Empty names: An item must have a name.
- Duplicate names: If the name (or combination of item names) is already assigned to an object (or relationship).
- Existing name: If the name is already taken by another object or parameter.
If you edit an item’s name, the original item is not deleted from the database on commit. To delete an item from the database, right click on the cell with the name, and select Delete item:name from the context menu.
A new relationship is added as soon as a valid combination of objects for that relationship class is entered, even if the row/column is invalid. To remove a relationship, right click on it and select Delete item:name from the context menu.
Commit/Rollback changes¶
To save changes select Session -> Commit from the menu bar, enter a commit message and press Commit. Any changes made in the Tabular view will be saved into the database.
To undo any changes since the last commit, select Session -> Rollback from the menu bar.
Tree view¶
The Tree view is used to display the different object and relationship classes, with their objects and relationships in a hierarchical tree. You can also add, edit, and delete object classes, relationship classes, objects, relationships, parameters and parameter values. The Tree view is useful to get an overview of the data and the relationships within a Spine database:

The interface has four main components:
- Object tree, where you can expand and collapse the different levels of the hierarchy. It also acts as a filtering tool for the other two table components, so that only items selected in the Object tree are shown in the Parameter tables.
- Relationship tree, similar to Object tree but for relationships.
- Object parameter table, where you can view, add, edit, and delete object parameter definitions and values.
- Relationship parameter table, where you can view, add, edit, and delete relationship parameter definitions and values.
Editing items¶
To add object classes, relationship classes, objects or relationships you can use the Edit menu from the main menu bar, as well as the context menu from the Object tree. In the dialog that pops up you can enter new items by typing their names or pasting data from the clipboard.

To delete an item, you can again use the Edit menu from the main menu bar or the item’s context menu from the Object tree.

Editing items is done following a similar procedure.
Viewing parameter definitions and values¶
In the Parameter tables, you can switch between viewing parameter definitions or values by using the tabs in the upper right corner.
You can also (further) filter the tables by clicking on the column headers.
Editing parameters definitions and values¶
To add new parameter definitions or values you can directly do it in the last row of each table. The tables also support pasting values from the clipboard.
Graph view¶
The Graph view is used to visualize the Spine database structure into a graph. Here you can select objects to see how they are related. You can also view parameter definition and values same as in the Tree view.

Plotting¶
Basic data visualization is available in the data store views. Currently, it is possible to plot plain parameter values as well as time series. There are some limitations in plotting data from different sources, however. For instance, object and relationship parameter time series cannot be plotted on the same graph at the moment.
To plot a column, select the values from a table and then Plot from the right click popup menu.


Selecting data in multiple columns plots the selection in a single window.
X axis for plain values¶
It is possible to plot plain values against X values given by a designated column in the pivot table of the Tabular view.
To set a column as the X column right click the top empty area above the column header and select Use as X from the popup menu. An (X) in the topmost cell indicates that the column is designated as containing the X axis.

When selecting and plotting other columns in the same table the data will be plotted against the values in the X column instead of row numbers.
Parameter value editor¶
Parameter value editor is used to edit object and relationship parameter values such as time series, time patterns or durations. It can also convert between different value types like from a time series to a time pattern.
The editor is available from a right click popup menu or by double clicking a parameter value in one of the data store views.
Choosing value type¶

The combo box at the top of the editor window allows changing the type of the current value.
Plain values¶
The simplest parameter values are of the Plain value type. These are numbers or booleans
which can be set by entering true
or false
on the Parameter value field.

Time series¶
There are two types of time series: variable and fixed resolution. Variable resolution means that the time stamps can be arbitrary while in fixed resolution series the time steps between consecutive stamps are fixed.


The editor windows is split into two in both cases. The left side holds all the options and a table with all the data while the right side shows a plot of the series. The plot is not editable and is for visualization purposes only.
In the table rows can be added or removed from a popup menu available by a right click. Data can be copied and pasted by Ctrl-C and Ctrl-V. Copying from/to an external spreadsheet program is supported.
The time steps of a fixed resolution series are edited by the Start time and Resolution fields. The format for the start time is ISO8601. The Resolution field takes a single time step or a comma separated list of steps. If a list of resolution steps are provided then the steps are repeated so as to fit the data in the table.
The Ignore year option available for both variable and fixed resolution time series allows the time series to be used independent of the the year. Only the month, day and time information is used by the model.
The Repeat option means that the time series is cycled, i.e. it starts from the beginning once the time steps run out.
Time patterns¶
The time pattern editor holds a single table which shows the period on the right column and the corresponding values on the left. Inserting/removing rows and copy-pasting works as in the time series editor.

Durations¶
A single value or a comma separated list of time durations can be entered to the Duration field.

Importing and exporting data¶
Note
This section is a work in progress.
This section explains the different ways of importing and exporting data to and from a Spine database.
Excel¶
In this section the excel import/export functionality is explained.
To import/export an excel file, select a Data store and open the Tree view. Then select File -> Import or File -> Export from the main menu.
Format¶
The excel files for import/export are formatted in the following way:
Tip
An easy way to get a excel template is to export an existing spine-database to excel.
Object classes:

Object timeseries:

Relationship classes:

Relationship timeseries:

When importing, all sheets with a valid format are imported, whereas sheets with invalid format are simply ignored. When exporting all object classes and relationship classes are exported. Only parameter values with timeseries data are exported in the timeseries format.
Spine datapackage editor¶
Note
This section is a work in progress.
This section describes the Spine datapackage editor, used to interact with tabular data and export it into Spine format.
To open the Spine datapackage editor, select a Data Connection with CSV files in it, and press the Datapackage button in its Properties:


Terminology¶
Here is a list of definitions that are used throughout the User Guide and in Spine Toolbox.
Spine Toolbox Terminology¶
- Data Connection is a project item used to store a collection of data files that may or may not be in Spine data format. It facilitates data transfer from original data sources e.g. spreadsheet files to Spine Toolbox. The original data source file does not need to conform to the format that Spine Toolbox is capable of reading, since there we can use an interpreting layer (Data Interface) between the raw data and the Spine format database (Data Store).
- Data Interface is a project item that can be used to import data from e.g. an Excel file, transform it to Spine data structure, and into a Data Store.
- Data Store is a project item. It’s a Spine Toolbox internal data container which follows the Spine data model. A data store is implemented using a database, it may be, for example, an SQL database.
- Project is a Spine Toolbox concept and consists of a data processing chain that is built by the user for solving a particular problem. Current items that constitute a project are; Data Connection, Data Store, Tool, View, and a Data Interface. There can be any number of these items in a project, and they can be connected by drawing links between them.
- Source directory When in context of Tool templates, a Source directory is the directory where the main program file of the Tool template is located. This is also the recommended place where the Tool template definition file (.json) is saved.
- Tool is a project item that is used to execute Tool templates. To execute a script or a simulation model in Spine Toolbox, you attach a Tool template to a Tool.
- Tool template can be a computational process or a simulation model, or it can also be a script to convert data or calculate a new variable. Tool template takes some data as input and produces an output. Tool template contains a reference to the model code, external program that executes the code, and input data that the model code requires. Spine Model is a Tool template from Spine Toolbox’s point-of-view.
- View A project item that can be used for visualizing project data.
- Work directory A directory where Tool template execution takes place. When a Tool is executed, Spine Toolbox creates a new work directory, copies all required and optional files needed for running the Tool template to this directory and executes it there. After execution has finished, output or result files can be archived into a timestamped results directory from the work directory.
Spine project Terminology¶
- Case study Spine project has 13 case studies that help to improve, validate and deploy different aspects of the Spine Model and Spine Toolbox.
- Data Interface is a component in Spine Toolbox, which handles connecting to and importing from external data sources.
- Data Package is a data container format consisting of a metadata descriptor file (‘datapackage.json’) and resources such as data files.
- Data sources are all the original, unaltered, sources of data that are used to generate necessary input data for Spine Toolbox tools.
- Scenario A scenario combines data connections to form a meaningful data set for the target tool.
- Spine data structure Spine data structure defines the format for storing and moving data within Spine Toolbox. A generic data structure allows representation of many different modelling entities. Data structures have a class defining the type of entity they represent, can have properties and can be related to other data structures. Spine data structures can be manipulated and visualized within Spine Toolbox while Spine Model will be able to directly utilize as well as output them.
- Spine Model An interpreter, which formulates a solver-ready mixed-integer optimization problem based on the input data and the equations defined in the Spine Model. Outputs the solver results.
- Use case Potential way to use Spine Toolbox. Use cases together are used to test the functionality and stability of Spine Toolbox and Spine Model under different potential circumstances.
Dependencies¶
Spine Toolbox requires Python 3.6 or higher.
Spine Toolbox uses code from packages and/or projects listed in the table below. Required packages must be installed for the application to start. Users can choose the SQL dialect API (pymysql, pyodbc psycopg2, and cx_Oracle) they want to use. These can be installed in Spine Toolbox when needed. If you want to deploy the application by using the provided setup.py file, you need to install cx_Freeze package (6.0b1 version or newer is recommended). All version numbers are minimum versions except for pyside2, where the version should be less than 5.12, which is not supported (yet).
Required packages¶
The following packages are available from requirements.txt
Package name | Version | License |
---|---|---|
pyside2 | <5.12 | LGPL |
datapackage | 1.2.3 | MIT |
qtconsole | 4.3.1 | BSD |
sqlalchemy | 1.2.6 | MIT |
openpyxl | 2.5.0 | MIT/Expat |
spinedb_api | 0.0.36 | LGPL |
numpy | 1.15.1 | BSD |
matplotlib | 3.0 | BSD |
scipy | 1.1.0 | BSD |
jupyter-client | 5.2.4 | BSD |
networkx | 2.2 | BSD |
pymysql | 0.9.2 | MIT |
pyodbc | 4.0.23 | MIT |
psycopg2 | 2.7.4 | LGPL |
cx_Oracle | 6.3.1 | BSD |
python-dateutil | 2.8.0 | PSF |
pandas | 0.24.0 | BSD |
Developer packages¶
The developer packages are available from dev-requirements.txt
.
Sphinx and sphinx_rtd_theme packages are needed for building the user guide.
Black is used for code formatting while pylint does linting.
Pre-commit hook enables automatic code formatting at git commit.
Package name | Version | License |
---|---|---|
black | 19.3b0 | MIT |
pre-commit | 1.16.1 | MIT |
pylint | 2.3.0 | GPL |
sphinx | 1.7.5 | BSD |
sphinx_rtd_theme | 0.4.0 | MIT |
recommonmark | 0.5.0 | MIT |
sphinx-autoapi | 1.1.0 | MIT |
Contribution Guide for Spine Toolbox¶
All are welcome to contribute!
Coding Style¶
Follow the style you see used in the repository! Consistency with the rest of the project always trumps other considerations. It doesn’t matter if you have your own style or if the rest of the code breaks with the greater community - just follow along.
Spine Toolbox coding style follows PEP-8 style guide for Python code with the following variations:
- Maximum line length is 120 characters. Longer lines are acceptable if there’s a sound reason.
- Google style docstrings with the title and input parameters are required for all classes, functions, and methods. For small functions or methods only the summary is necessary. Return types are highly recommended but not required if it is obvious what the function or method returns.
- Other deviations from PEP-8 can be discussed if there are good reasons.
Contributing to the User Guide¶
Spine Toolbox uses Sphinx to create HTML pages from restructured text (.rst) files. The .rst files are
plain text files that are formatted in a way that Sphinx understands and is able to turn them into HTML.
You can find a brief introduction to reStructured text in (http://www.sphinx-doc.org/en/stable/rest.html).
You can modify the existing or create new .rst files into docs/source
directory. When you are done editing, run
bin/build_doc.bat
on Windows or bin/build_doc.sh
on Linux to build the HTML pages. The created pages are
found in docs/build/html
directory.
Contributing to the Spine Toolbox Graphical User Interface¶
If you want to change or add new widgets into the application, you need to use the bin/build_ui.bat
(Windows) or
bin/build_ui.sh
(Linux) scripts. The main design of the widgets should be done with Qt Designer (designer.exe
or designer
) that is included with PySide2. The files produced by Qt Designer are XML files (.ui). You can
also embed graphics (e.g. icons, logos, etc.) into the application by using Qt Designer. When you are done
modifying widgets in the designer, you need to run the build_ui
script for the changes to take effect.
This script uses tools provided in the PySide2 package to turn .ui files into Python files, in essence
rebuilding the whole Spine Toolbox user interface.
Styling the widgets should be done with Qt Style Sheets in code. Avoid using style sheets in Qt Designer.
Reporting Bugs¶
This section is based on a set of best practices for open source projects (http://contribution-guide-org.readthedocs.io/)
Due Diligence¶
Before submitting a bug report, please do the following:
Perform basic troubleshooting steps.
- Make sure you’re on the latest version. If you’re not on the most recent version, your problem may have been solved already! Upgrading is always the best first step.
- Try older versions. If you’re already on the latest release, try rolling back a few minor versions (e.g. if on 1.7, try 1.5 or 1.6) and see if the problem goes away. This will help the devs narrow down when the problem first arose in the commit log.
- Try switching up dependency versions. If you think the problem may be due to a problem with a dependency (other libraries, etc.). Try upgrading/downgrading those as well.
- Search the project’s bug/issue tracker to make sure it’s not a known issue. If you don’t find a pre-existing issue, consider checking with the maintainers in case the problem is non-bug-related.
What to Put in Your Bug Report¶
Make sure your report gets the attention it deserves: bug reports with missing information may be ignored or punted back to you, delaying a fix. The below constitutes a bare minimum; more info is almost always better:
- What version of the Python interpreter are you using? E.g. Python 2.7.3, Python 3.6?
- What operating system are you on? Windows? (Vista, 7, 8, 8.1, 10). 32-bit or 64-bit? Mac OS X? (e.g. 10.7.4, 10.9.0) Linux (Which distro? Which version of that distro? 32 or 64 bits?) Again, more detail is better.
- Which version or versions of the software are you using? If you have forked the project from Git, which branch and which commit? Otherwise, supply the application version number (Help->About menu). Also, ideally you followed the advice above and have ruled out (or verified that the problem exists in) a few different versions.
- How can the developers recreate the bug? What were the steps used to invoke it. A screenshot demonstrating the bug is usually the most helpful thing you can report (if applicable) Relevant output from the Event Log or debug messages from the console of your run, should also be included.
Feature Requests¶
The developers of Spine Toolbox are happy to hear new ideas for features or improvements to existing functionality. The format for requesting new features is free. Just fill out the required fields on the issue tracker and give a description of the new feature. A picture accompanying the description is a good way to get your idea into development faster. But before you make a new issue, check that there isn’t a related idea already open in the issue tracker. If you have an idea on how to improve an existing issue, just join the conversation.
Submitting features/bugfixes¶
If you feel like you can fix a bug that’s been bothering you or you want to add a new feature to the application but the devs seem to be too busy with something else, please follow these instructions.
Version Control Branching¶
Always make a new branch for your work, no matter how small. This makes it easy for others to take just that one set of changes from your repository, in case you have multiple unrelated changes floating around.
A corollary: don’t submit unrelated changes in the same branch/pull request! The maintainer shouldn’t have to reject your awesome bugfix because the feature you put in with it needs more review.
Name your new branch descriptively, e.g. issue#XXX-fixing-a-serious-bug or issue#ZZZ-cool-new-feature. New branches should in general be based on the latest dev branch. In case you want to include a new feature still in development, you can also start working from its branch. The developers will backport any relevant bug-fixes to previous or upcoming releases under preparation.
Finally, make a pull request from your branch so that the developers can review your changes. You might be asked to make additional changes or clarifications or add tests to prove the new feature works as intended.
Test-driven development is your friend¶
Any bug fix that doesn’t include a test proving the existence of the bug being fixed, may be suspect. Ditto for new features that can’t prove they actually work.
It is recommended to use test-first development as it really helps make features better designed and identifies potential edge cases earlier instead of later. Writing tests before the implementation is strongly encouraged.
Full example¶
Here’s an example workflow. Your username is yourname
and you’re submitting a basic bugfix.
Preparing your Fork
- Click ‘Fork’ on Github, creating e.g.
yourname/Spine-Toolbox
- Clone your project:
git clone git@github.com:yourname/Spine-Toolbox
cd Spine-Toolbox
- Create a virtual environment and install requirements
- Create a branch:
git checkout -b foo-the-bars master
Making your Changes
- Add changelog entry crediting yourself.
- Write tests expecting the correct/fixed functionality; make sure they fail.
- Hack, hack, hack.
- Run tests again, making sure they pass.
- Commit your changes:
git commit -m "Foo the bars"
Creating Pull Requests
- Push your commit to get it back up to your fork:
git push origin HEAD
- Visit Github, click handy ‘Pull request‘ button that it will make upon noticing your new branch.
- In the description field, write down issue number (if submitting code fixing an existing issue) or describe the issue + your fix (if submitting a wholly new bugfix).
- Hit ‘submit’! And please be patient - the maintainers will get to you when they can.
API Reference¶
This page contains auto-generated API reference documentation [1].
graphics_items
¶
Classes for drawing graphics items on QGraphicsScene.
authors: |
|
---|---|
date: | 4.4.2018 |
Module Contents¶
-
class
graphics_items.
ConnectorButton
(parent, toolbox, position='left')[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItem
Connector button graphics item. Used for Link drawing between project items.
-
parent
¶ Project item bg rectangle
Type: QGraphicsItem
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
position
¶ Either “top”, “left”, “bottom”, or “right”
Type: str
-
mousePressEvent
(self, event)[source]¶ Connector button mouse press event. Starts drawing a link.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
mouseDoubleClickEvent
(self, event)[source]¶ Connector button mouse double click event. Makes sure the LinkDrawer is hidden.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
-
class
graphics_items.
ProjectItemIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItem
Base class for Tool and View project item icons drawn in Design View.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Icon width
Type: int
-
h
¶ Icon height
Type: int
-
setup
(self, pen, brush, svg, svg_color)[source]¶ Setup item’s attributes according to project item type. Intended to be called in the constructor’s of classes that inherit from ItemImage class.
Parameters: - pen (QPen) – Used in drawing the background rectangle outline
- brush (QBrush) – Used in filling the background rectangle
- svg (str) – Path to SVG icon file
- svg_color (QColor) – Color of SVG icon
-
name
(self)[source] Returns name of the item that is represented by this icon.
-
update_name_item
(self, new_name)[source]¶ Set a new text to name item. Used when a project item is renamed.
-
set_name_attributes
(self)[source]¶ Set name QGraphicsSimpleTextItem attributes (font, size, position, etc.)
Returns items connector button (QWidget).
-
hoverEnterEvent
(self, event)[source]¶ Sets a drop shadow effect to icon when mouse enters its boundaries.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
hoverLeaveEvent
(self, event)[source]¶ Disables the drop shadow when mouse leaves icon boundaries.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
mouseMoveEvent
(self, event)[source]¶ Moves icon(s) while the mouse button is pressed. Update links that are connected to selected icons.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
contextMenuEvent
(self, event)[source]¶ Show item context menu.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
keyPressEvent
(self, event)[source]¶ Handles deleting and rotating the selected item when dedicated keys are pressed.
Parameters: event (QKeyEvent) – Key event
-
-
class
graphics_items.
DataConnectionIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIcon
Data Connection icon for the Design View.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Width of master icon
Type: int
-
h
¶ Height of master icon
Type: int
-
name
¶ Item name
Type: str
-
dragEnterEvent
(self, event)[source]¶ Drag and drop action enters. Accept file drops from the filesystem.
Parameters: event (QGraphicsSceneDragDropEvent) – Event
-
dragLeaveEvent
(self, event)[source]¶ Drag and drop action leaves.
Parameters: event (QGraphicsSceneDragDropEvent) – Event
-
-
class
graphics_items.
ToolIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIcon
Tool image with a rectangular background, an SVG icon, a name label, and a connector button.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Width of master icon
Type: int
-
h
¶ Height of master icon
Type: int
-
name
¶ Item name
Type: str
-
-
class
graphics_items.
DataStoreIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIcon
Data Store item that is drawn into QGraphicsScene. NOTE: Make sure to set self._master as the parent of all drawn items. This groups the individual QGraphicsItems together.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Width of master icon
Type: int
-
h
¶ Height of master icon
Type: int
-
name
¶ Item name
Type: str
-
-
class
graphics_items.
ViewIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIcon
View icon for the Design View
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Width of background rectangle
Type: int
-
h
¶ Height of background rectangle
Type: int
-
name
¶ Item name
Type: str
-
-
class
graphics_items.
DataInterfaceIcon
(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIcon
Data Interface item that is drawn into QGraphicsScene. NOTE: Make sure to set self._master as the parent of all drawn items. This groups the individual QGraphicsItems together.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
x
¶ Icon x coordinate
Type: int
-
y
¶ Icon y coordinate
Type: int
-
w
¶ Width of master icon
Type: int
-
h
¶ Height of master icon
Type: int
-
name
¶ Item name
Type: str
-
-
class
graphics_items.
Link
(toolbox, src_connector, dst_connector)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPathItem
An item that represents a connection between project items.
-
src_connector
¶ Source connector button
Type: ConnectorButton
-
dst_connector
¶ Destination connector button
Type: ConnectorButton
-
mousePressEvent
(self, e)[source]¶ Trigger slot button if it is underneath.
Parameters: e (QGraphicsSceneMouseEvent) – Mouse event
-
mouseDoubleClickEvent
(self, e)[source]¶ Accept event to prevent unwanted feedback links to be created when propagating this event to connector buttons underneath.
-
contextMenuEvent
(self, e)[source]¶ Show context menu unless mouse is over one of the slot buttons.
Parameters: e (QGraphicsSceneMouseEvent) – Mouse event
-
-
class
graphics_items.
LinkDrawer
[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPathItem
An item that allows one to draw links between slot buttons in QGraphicsView.
-
class
graphics_items.
ObjectItem
(graph_view_form, object_name, object_class_id, object_class_name, x, y, extent, object_id=0, label_color=Qt.transparent)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPixmapItem
Object item to use with GraphViewForm.
-
graph_view_form
¶ ‘owner’
Type: GraphViewForm
-
object_name
¶ object name
Type: str
-
object_class_id
¶ object class id
Type: int
-
object_class_name
¶ object class name
Type: str
-
x
¶ x-coordinate of central point
Type: float
-
y
¶ y-coordinate of central point
Type: float
-
extent
¶ preferred extent
Type: int
-
object_id
¶ object id (for filtering parameters)
Type: int
-
label_font
¶ label font
Type: QFont
-
label_color
¶ label bg color
Type: QColor
-
paint
(self, painter, option, widget=None)[source]¶ Try and make it more clear when an item is selected.
-
check_for_merge_target
(self, scene_pos)[source]¶ Checks if this item is touching another item so they can merge (this happens when building a relationship).
-
merge_item
(self, other)[source]¶ Merges this item with another. Tries to create a relationship if needed.
Moves related items.
-
-
class
graphics_items.
ArcItem
(graph_view_form, relationship_class_id, src_item, dst_item, width, arc_color, object_id_list='', token_color=QColor(), token_object_extent=0, token_object_label_color=QColor(), token_object_name_tuple_list=())[source]¶ Bases:
PySide2.QtWidgets.QGraphicsLineItem
Arc item to use with GraphViewForm.
-
graph_view_form
¶ ‘owner’
Type: GraphViewForm
-
relationship_class_id
¶ relationship class id
Type: int
-
src_item
¶ source item
Type: ObjectItem
-
dst_item
¶ destination item
Type: ObjectItem
-
width
¶ Preferred line width
Type: int
-
arc_color
¶ arc color
Type: QColor
-
object_id_list
¶ object id comma separated list
Type: str
-
token_object_extent
¶ token preferred extent
Type: int
-
token_color
¶ token bg color
Type: QColor
-
token_object_name_tuple_list
¶ token (object class name, object name) tuple list
Type: list
-
paint
(self, painter, option, widget=None)[source]¶ Try and make it more clear when an item is selected.
-
move_src_by
(self, pos_diff)[source]¶ Move source point by pos_diff. Used when moving ObjectItems around.
-
-
class
graphics_items.
ObjectLabelItem
(object_item, text, width, bg_color)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsTextItem
Object label item to use with GraphViewForm.
-
object_item
¶ the ObjectItem instance
Type: ObjectItem
-
text
¶ text
Type: str
-
width
¶ maximum width
Type: int
-
bg_color
¶ color to paint the label
Type: QColor
-
set_text
(self, text)[source]¶ Store real text, and then try and fit it as best as possible in the width (reduce font point size, elide text…)
-
-
class
graphics_items.
ArcTokenItem
(arc_item, color, object_extent, object_label_color, *object_name_tuples)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsEllipseItem
Arc token item to use with GraphViewForm.
-
color
¶ color to paint the token
Type: QColor
-
object_extent
¶ Preferred extent
Type: int
-
object_label_color
¶ Preferred extent
Type: QColor
-
object_name_tuples
¶ one or more (object class name, object name) tuples
Type: Iterable
-
-
class
graphics_items.
SimpleObjectItem
(parent, extent, label_color, object_class_name, object_name)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPixmapItem
Object item to use with GraphViewForm.
-
parent
¶ arc token item
Type: ArcTokenItem
-
extent
¶ preferred extent
Type: int
-
label_color
¶ label bg color
Type: QColor
-
object_class_name
¶ object class name
Type: str
-
object_name
¶ object name
Type: str
-
-
class
graphics_items.
OutlinedTextItem
(text, font, brush=QBrush(Qt.black), outline_pen=QPen(Qt.white, 3, Qt.SolidLine))[source]¶ Bases:
PySide2.QtWidgets.QGraphicsSimpleTextItem
Outlined text item to use with GraphViewForm.
-
text
¶ text to show
Type: str
-
font
¶ font to display the text
Type: QFont
-
brush
¶ Type: QBrus
-
outline_pen
¶ Type: QPen
-
project
¶
Spine Toolbox project class.
authors: |
|
---|---|
date: | 10.1.2018 |
Module Contents¶
-
class
project.
SpineToolboxProject
(toolbox, name, description, work_dir=None, ext='.proj')[source]¶ Bases:
metaobject.MetaObject
Class for Spine Toolbox projects.
-
name
¶ Project name
Type: str
-
description
¶ Project description
Type: str
-
work_dir
¶ Project work directory
Type: str
-
ext
¶ Project save file extension(.proj)
Type: str
-
change_name
(self, name)[source]¶ Changes project name and updates project dir and save file name.
Parameters: name (str) – Project (long) name
-
change_filename
(self, new_filename)[source]¶ Change the save filename associated with this project.
Parameters: new_filename (str) – Filename used in saving the project. No full path. Example ‘project.proj’
-
change_work_dir
(self, new_work_path)[source]¶ Change project work directory.
Parameters: new_work_path (str) – Absolute path to new work directory
-
rename_project
(self, name)[source]¶ Save project under a new name. Used with File->Save As… menu command. Checks if given project name is valid.
Parameters: name (str) – New (long) name for project
-
save
(self, tool_def_paths)[source]¶ Collect project information and objects into a dictionary and write to a JSON file.
Parameters: tool_def_paths (list) – List of paths to tool definition files
-
load
(self, item_dict)[source]¶ Populate project item model with items loaded from project file.
Parameters: item_dict (dict) – Dictionary containing all project items in JSON format Returns: Boolean value depending on operation success.
-
load_tool_template_from_file
(self, jsonfile)[source]¶ Create a Tool template according to a tool definition file.
Parameters: jsonfile (str) – Path of the tool template definition file Returns: Instance of a subclass if Tool
-
load_tool_template_from_dict
(self, definition, path)[source]¶ Create a Tool template according to a dictionary.
Parameters: - definition (dict) – Dictionary with the tool definition
- path (str) – Folder of the main program file
Returns: Instance of a subclass if Tool
-
add_data_store
(self, name, description, url, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Store to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- url (dict) – Url information
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_data_connection
(self, name, description, references, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Connection to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- references (list(str)) – List of file paths
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_tool
(self, name, description, tool_template, use_work=True, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Tool to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- tool_template (ToolTemplate) – Tool template of this tool
- use_work (bool) – Execute in work directory
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_view
(self, name, description, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a View to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_data_interface
(self, name, description, import_file_path='', mappings=None, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Interface to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
append_connection_model
(self, item_name, category)[source]¶ Adds new item to connection model to keep project and connection model synchronized.
-
set_item_selected
(self, item)[source]¶ Sets item selected and shows its info screen.
Parameters: item (ProjectItem) – Project item to select
-
execute_selected
(self)[source]¶ Starts executing selected directed acyclic graph. Selected graph is determined by the selected project item(s). Aborts, if items from multiple graphs are selected.
-
execute_project
(self)[source]¶ Determines the number of directed acyclic graphs to execute in the project. Determines the execution order of project items in each graph. Creates an instance for executing the first graph and starts executing it.
-
graph_execution_finished
(self, state)[source]¶ Releases resources from previous execution and prepares the next graph for execution if there are still graphs left. Otherwise, finishes the run.
Parameters: state (int) – 0: Ended normally. -1: User pressed Stop button
-
stop
(self)[source]¶ Stops execution of the current DAG. Slot for the main window Stop tool button in the toolbar.
-
parameter_value_formatting
¶
Functions for textual display of parameter values in table views.
authors: |
|
---|---|
date: | 12.7.2019 |
Module Contents¶
-
parameter_value_formatting.
format_for_DisplayRole
(value_in_database)[source]¶ Returns the value’s database representation formatted for Qt.DisplayRole.
config
¶
Application constants and style sheets
author: |
|
---|---|
date: | 2.1.2018 |
Module Contents¶
-
config.
OPTIONAL_KEYS
= ['description', 'short_name', 'inputfiles', 'inputfiles_opt', 'outputfiles', 'cmdline_args', 'execute_in_work'][source]¶
-
config.
STATUSBAR_SS
= QStatusBar{background-color: #EBEBE0;border-width: 1px;border-color: gray;border-style: groove;}[source]¶
-
config.
SETTINGS_SS
= #SettingsForm{background-color: ghostwhite;}QLabel{color: black;}QLineEdit{font-size: 11px;}QGroupBox{border: 2px solid gray; background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #80B0FF, stop: 1 #e6efff);border-radius: 5px;margin-top: 0.5em;}QGroupBox:title{border-radius: 2px; background-color: ghostwhite;subcontrol-origin: margin;subcontrol-position: top center;padding-top: 0px;padding-bottom: 0px;padding-right: 3px;padding-left: 3px;}QCheckBox{outline-style: dashed; outline-width: 1px; outline-color: white;}QPushButton{background-color: #505F69; border: 1px solid #29353d; color: #F0F0F0; border-radius: 4px; padding: 3px; outline: none;}QPushButton:disabled {background-color: #32414B; border: 1px solid #29353d; color: #787878; border-radius: 4px; padding: 3px;}QPushButton::menu-indicator {subcontrol-origin: padding; subcontrol-position: bottom right; bottom: 4px;}QPushButton:focus{background-color: #637683; border: 1px solid #148CD2;}QPushButton:hover{border: 1px solid #148CD2; color: #F0F0F0;}QPushButton:pressed{background-color: #19232D; border: 1px solid #19232D;}[source]¶
-
config.
ICON_TOOLBAR_SS
= QToolBar{spacing: 6px; background: qlineargradient(x1: 1, y1: 1, x2: 0, y2: 0, stop: 0 #cce0ff, stop: 1 #66a1ff);padding: 3px;border-style: solid;}QToolButton{background-color: white;border-width: 1px;border-style: inset;border-color: darkslategray;border-radius: 2px;}QLabel{color:black;padding: 3px;}[source]¶
-
config.
TEXTBROWSER_SS
= QTextBrowser {background-color: #19232D; border: 1px solid #32414B; color: #F0F0F0; border-radius: 2px;}QTextBrowser:hover,QTextBrowser:selected,QTextBrowser:pressed {border: 1px solid #668599;}[source]¶
-
config.
MAINWINDOW_SS
= QMainWindow::separator{width: 3px; background-color: lightgray; border: 1px solid white;}QPushButton{background-color: #505F69; border: 1px solid #29353d; color: #F0F0F0; border-radius: 4px; padding: 3px; outline: none; min-width: 75px;}QPushButton:disabled {background-color: #32414B; border: 1px solid #29353d; color: #787878; border-radius: 4px; padding: 3px;}QPushButton::menu-indicator {subcontrol-origin: padding; subcontrol-position: bottom right; bottom: 4px;}QPushButton:focus{background-color: #637683; border: 1px solid #148CD2;}QPushButton:hover{border: 1px solid #148CD2; color: #F0F0F0;}QPushButton:pressed{background-color: #19232D; border: 1px solid #19232D;}QToolButton:focus{border-color: black; border-width: 1px; border-style: ridge;}QToolButton:pressed{background-color: #f2f2f2;}QToolButton::menu-indicator{width: 0px;}QCheckBox{padding: 2px; spacing: 10px; outline-style: dashed; outline-width: 1px; outline-color: black;}QComboBox:focus{border-color: black; border-width: 1px; border-style: ridge;}QLineEdit:focus{border-color: black; border-width: 1px; border-style: ridge;}QTextEdit:focus{border-color: black; border-width: 1px; border-style: ridge;}QTreeView:focus{border-color: darkslategray; border-width: 2px; border-style: ridge;}[source]¶
models
¶
Classes for handling models in PySide2’s model/view framework. Note: These are Spine Toolbox internal data models.
authors: |
|
---|---|
date: | 23.1.2018 |
Module Contents¶
-
class
models.
ProjectItemModel
(toolbox, root)[source]¶ Bases:
PySide2.QtCore.QAbstractItemModel
Class to store project items, e.g. Data Stores, Data Connections, Tools, Views.
-
root
[source]¶ Root item for the project item tree
Type: ProjectItem
-
root
(self)[source] Returns root project item.
-
rowCount
(self, parent=QModelIndex())[source]¶ Reimplemented rowCount method.
Parameters: parent (QModelIndex) – Index of parent item whose children are counted. Returns: Number of children of given parent Return type: int
-
flags
(self, index)[source]¶ Returns flags for the item at given index
Parameters: index (QModelIndex) – Flags of item at this index.
-
parent
(self, index=QModelIndex())[source]¶ Returns index of the parent of given index.
Parameters: index (QModelIndex) – Index of item whose parent is returned Returns: Index of parent item Return type: QModelIndex
-
index
(self, row, column, parent=QModelIndex())[source]¶ Returns index of item with given row, column, and parent.
Parameters: - row (int) – Item row
- column (int) – Item column
- parent (QModelIndex) – Parent item index
Returns: Item index
Return type: QModelIndex
-
data
(self, index, role=None)[source]¶ Returns data in the given index according to requested role.
Parameters: - index (QModelIndex) – Index to query
- role (int) – Role to return
Returns: Data depending on role.
Return type: object
-
project_item
(self, index)[source]¶ Returns project item at given index.
Parameters: index (QModelIndex) – Index of project item Returns: Item at given index or root project item if index is not valid Return type: ProjectItem
-
find_category
(self, category_name)[source]¶ Returns the index of the given category name.
Parameters: category_name (str) – Name of category item to find Returns: index of a category item or None if it was not found Return type: QModelIndex
-
find_item
(self, name)[source]¶ Returns the QModelIndex of the project item with the given name
Parameters: name (str) – The searched project item (long) name Returns: Index of a project item with the given name or None if not found Return type: QModelIndex
-
insert_item
(self, item, parent=QModelIndex())[source]¶ Adds a new item to model. Fails if given parent is not a category item nor a root item. New item is inserted as the last item.
Parameters: - item (ProjectItem) – Project item to add to model
- parent (QModelIndex) – Parent project item
Returns: True if successful, False otherwise
Return type: bool
-
remove_item
(self, item, parent=QModelIndex())[source]¶ Removes item from model.
Parameters: - item (ProjectItem) – Project item to remove
- parent (QModelIndex) – Parent of item that is to be removed
Returns: True if item removed successfully, False if item removing failed
Return type: bool
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Changes the name of the project item at given index to given value. # TODO: If the item is a Data Store the reference sqlite path must be updated.
Parameters: - index (QModelIndex) – Project item index
- value (str) – New project item name
- role (int) – Item data role to set
Returns: True or False depending on whether the new name is acceptable.
Return type: bool
-
items
(self, category_name=None)[source]¶ Returns a list of items in model according to category name. If no category name given, returns all project items in a list.
Parameters: category_name (str) – Item category. Data Connections, Data Stores, Tools or Views permitted. Returns: obj:’list’ of :obj:’ProjectItem’: Depending on category_name argument, returns all items or only items according to category. An empty list is returned if there are no items in the given category or if an unknown category name was given.
-
n_items
(self)[source]¶ Returns the number of all project items in the model excluding category items and root.
Returns: Number of items Return type: int
-
item_names
(self)[source]¶ Returns all project item names in a list.
Returns: ‘list’ of obj:’str’: Item names Return type: obj
-
-
class
models.
ToolTemplateModel
(toolbox=None)[source]¶ Bases:
PySide2.QtCore.QAbstractListModel
Class to store tools that are available in a project e.g. GAMS or Julia models.
-
rowCount
(self, parent=None)[source]¶ Must be reimplemented when subclassing. Returns the number of Tools in the model.
Parameters: parent (QModelIndex) – Not used (because this is a list) Returns: Number of rows (available tools) in the model
-
data
(self, index, role=None)[source]¶ Must be reimplemented when subclassing.
Parameters: - index (QModelIndex) – Requested index
- role (int) – Data role
Returns: Data according to requested role
-
flags
(self, index)[source]¶ Returns enabled flags for the given index.
Parameters: index (QModelIndex) – Index of Tool
-
insertRow
(self, tool, row=None, parent=QModelIndex())[source]¶ Insert row (tool) into model.
Parameters: - tool (Tool) – Tool added to the model
- row (str) – Row to insert tool to
- parent (QModelIndex) – Parent of child (not used)
Returns: Void
-
removeRow
(self, row, parent=QModelIndex())[source]¶ Remove row (tool) from model.
Parameters: - row (int) – Row to remove the tool from
- parent (QModelIndex) – Parent of tool on row (not used)
Returns: Boolean variable
-
update_tool_template
(self, tool, row)[source]¶ Update tool template.
Parameters: - tool (ToolTemplate) – new tool, to replace the old one
- row (int) – Position of the tool to be updated
Returns: Boolean value depending on the result of the operation
-
tool_template
(self, row)[source]¶ Returns tool template on given row.
Parameters: row (int) – Row of tool template Returns: ToolTemplate from tool template list or None if given row is zero
-
find_tool_template
(self, name)[source]¶ Returns tool template with the given name.
Parameters: name (str) – Name of tool template to find
-
-
class
models.
ConnectionModel
(toolbox=None)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
Table model for storing connections between items.
-
rowCount
(self, *args, **kwargs)[source]¶ Number of rows in the model. This should be the same as the number of items in the project.
-
columnCount
(self, *args, **kwargs)[source]¶ Number of columns in the model. This should be the same as the number of items in the project.
-
headerData
(self, section, orientation, role=Qt.DisplayRole)[source]¶ Returns header data according to given role.
-
setHeaderData
(self, section, orientation, value, role=Qt.EditRole)[source]¶ Sets the data for the given role and section in the header with the specified orientation to the value supplied.
-
data
(self, index, role)[source]¶ Returns the data stored under the given role for the item referred to by the index. DisplayRole is a string “False” or “True” depending on if a Link is present.
Parameters: - index (QModelIndex) – Index of item
- role (int) – Data role
Returns: Item data for given role.
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Set data of single cell in table. Toggles the checkbox state at index.
Parameters: - index (QModelIndex) – Index of data to edit
- value (QVariant) – Value to write to index (Link instance)
- role (int) – Role for editing
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Inserts count rows into the model before the given row. Items in the new row will be children of the item represented by the parent model index.
Parameters: - row (int) – Row number where new rows are inserted
- count (int) – Number of inserted rows
- parent (QModelIndex) – Parent index
Returns: True if rows were inserted successfully, False otherwise
-
insertColumns
(self, column, count, parent=QModelIndex())[source]¶ Inserts count columns into the model before the given column. Items in the new column will be children of the item represented by the parent model index.
Parameters: - column (int) – Column number where new columns are inserted
- count (int) – Number of inserted columns
- parent (QModelIndex) – Parent index
Returns: True if columns were inserted successfully, False otherwise
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Removes count rows starting with the given row under parent.
Parameters: - row (int) – Row number where to start removing rows
- count (int) – Number of removed rows
- parent (QModelIndex) – Parent index
Returns: True if rows were removed successfully, False otherwise
-
removeColumns
(self, column, count, parent=QModelIndex())[source]¶ Removes count columns starting with the given column under parent.
Parameters: - column (int) – Column number where to start removing columns
- count (int) – Number of removed columns
- parent (QModelIndex) – Parent index
Returns: True if columns were removed successfully, False otherwise
-
append_item
(self, name, index)[source]¶ Embiggens connections table by a new item.
Parameters: - name (str) – New item name
- index (int) – Table row and column where the new item is appended
Returns: True if successful, False otherwise
-
remove_item
(self, name)[source]¶ Removes project item from connections table.
Parameters: name (str) – Name of removed item Returns: True if successful, False otherwise
-
output_items
(self, name)[source]¶ Returns a list of output items for the given item.
Parameters: name (str) – Project item name Returns: Output project item names in a list if they exist or an empty list if they don’t. Return type: (list)
-
input_items
(self, name)[source]¶ Returns a list of input items for the given item.
Parameters: name (str) – Project item name Returns: Input project item names in a list if they exist or an empty list if they don’t. Return type: (list)
-
reset_model
(self, connection_table)[source]¶ Reset model. Used in replacing the current model with a boolean table that represents connections. Overwrites the current model with a True or False (boolean) table that is read from a project save file (.json). This table is updated by restore_links() method to add Link instances to True cells and Nones to False cells.
-
-
class
models.
MinimalTableModel
(parent=None)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
Table model for outlining simple tabular data.
-
parent
¶ the parent widget, usually an instance of TreeViewForm
Type: QMainWindow
-
insert_horizontal_header_labels
(self, section, labels)[source]¶ Insert horizontal header labels at the given section.
-
setHeaderData
(self, section, orientation, value, role=Qt.EditRole)[source]¶ Sets the data for the given role and section in the header with the specified orientation to the value supplied.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index.
Parameters: - index (QModelIndex) – Index of item
- role (int) – Data role
Returns: Item data for given role.
-
row_data
(self, row, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the given row.
Parameters: - row (int) – Item row
- role (int) – Data role
Returns: Row data for given role.
-
column_data
(self, column, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the given column.
Parameters: - column (int) – Item column
- role (int) – Data role
Returns: Column data for given role.
-
model_data
(self, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role in the entire model.
Parameters: role (int) – Data role Returns: Model data for given role.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Inserts count rows into the model before the given row. Items in the new row will be children of the item represented by the parent model index.
Parameters: - row (int) – Row number where new rows are inserted
- count (int) – Number of inserted rows
- parent (QModelIndex) – Parent index
Returns: True if rows were inserted successfully, False otherwise
-
insertColumns
(self, column, count, parent=QModelIndex())[source]¶ Inserts count columns into the model before the given column. Items in the new column will be children of the item represented by the parent model index.
Parameters: - column (int) – Column number where new columns are inserted
- count (int) – Number of inserted columns
- parent (QModelIndex) – Parent index
Returns: True if columns were inserted successfully, False otherwise
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Removes count rows starting with the given row under parent.
Parameters: - row (int) – Row number where to start removing rows
- count (int) – Number of removed rows
- parent (QModelIndex) – Parent index
Returns: True if rows were removed successfully, False otherwise
-
removeColumns
(self, column, count, parent=QModelIndex())[source]¶ Removes count columns starting with the given column under parent.
Parameters: - column (int) – Column number where to start removing columns
- count (int) – Number of removed columns
- parent (QModelIndex) – Parent index
Returns: True if columns were removed successfully, False otherwise
-
-
class
models.
EmptyRowModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A table model with a last empty row.
-
_handle_data_changed
(self, top_left, bottom_right, roles=None)[source]¶ Insert a new last empty row in case the previous one has been filled with any data other than the defaults.
-
-
class
models.
HybridTableModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model that concatenates two models, one for existing items and another one for new items.
-
flags
(self, index)[source]¶ Return flags for given index. Depending on the index’s row we will land on one of the two models.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Return data for given index and role. Depending on the index’s row we will land on one of the two models.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. Distribute indexes and data among the two models and call batch_set_data on each of them.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-model (or the empty model) and call insertRows on it.
-
-
class
models.
DatapackageResourcesModel
(parent)[source]¶ Bases:
models.MinimalTableModel
A model of datapackage resource data, used by SpineDatapackageWidget.
-
parent
¶ Type: SpineDatapackageWidget
-
-
class
models.
DatapackageFieldsModel
(parent)[source]¶ Bases:
models.MinimalTableModel
A model of datapackage field data, used by SpineDatapackageWidget.
-
parent
¶ Type: SpineDatapackageWidget
-
-
class
models.
DatapackageForeignKeysModel
(parent)[source]¶ Bases:
models.EmptyRowModel
A model of datapackage foreign key data, used by SpineDatapackageWidget.
-
parent
¶ Type: SpineDatapackageWidget
-
project_item
¶
ProjectItem class.
authors: |
|
---|---|
date: | 4.10.2018 |
Module Contents¶
-
class
project_item.
ProjectItem
(name, description, is_root=False, is_category=False)[source]¶ Bases:
metaobject.MetaObject
Base class for all project items. Create root and category items by instantiating objects from this class.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
is_root
¶ True if new item should be a root item
Type: bool
-
is_category
¶ True if new item should be a category item
Type: bool
-
child
(self, row)[source]¶ Returns child ProjectItem on given row.
Parameters: row (int) – Row of child to return Returns: ProjectItem on given row or None if it does not exist
-
add_child
(self, child_item)[source]¶ Append child project item as the last item in the children list. Set parent of this items parent as this item. This method is called by ProjectItemModel when new items are added.
Parameters: child_item (ProjectItem) – Project item to add Returns: True if operation succeeded, False otherwise
-
ui_main
¶
Contains ToolboxUI class.
author: |
|
---|---|
date: | 14.12.2017 |
Module Contents¶
-
class
ui_main.
ToolboxUI
[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
Class for application main GUI functions.
-
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.
-
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_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.
Initialize widgets that are shared among all ProjectItems of the same type.
-
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_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_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_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
-
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.
-
restore_dock_widgets
(self)[source]¶ Dock all floating and or hidden QDockWidgets back to the main window.
-
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.
-
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
Context menu for project items listed in the project QTreeView.
Parameters: pos (QPoint) – Mouse position
Context menu for project item images on the QGraphicsView.
Parameters: - pos (QPoint) – Mouse position
- name (str) – The name of the concerned item
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
Context menu for tool templates.
Parameters: pos (QPoint) – Mouse position
Create and show a context-menu in data connection properties references view.
Parameters: pos (QPoint) – Mouse position
Create and show a context-menu in data connection properties data view.
Parameters: pos (QPoint) – Mouse position
Create and show a context-menu in Tool properties if selected Tool has a Tool template.
Parameters: pos (QPoint) – Mouse position
Create and show a context-menu in View properties.
Parameters: pos (QPoint) – Mouse position
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.
-
data_connection
¶
Module for data connection class.
author: |
|
---|---|
date: | 19.12.2017 |
Module Contents¶
-
class
data_connection.
DataConnection
(toolbox, name, description, references, x, y)[source]¶ Bases:
project_item.ProjectItem
Data Connection class.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
references
¶ List of file references
Type: list
-
x
¶ Initial X coordinate of item icon
Type: int
-
y
¶ Initial Y coordinate of item icon
Type: int
-
make_signal_handler_dict
(self)[source]¶ Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.
-
restore_selections
(self)[source]¶ Restore selections into shared widgets when this project item is selected.
-
save_selections
(self)[source]¶ Save selections in shared widgets for this project item into instance variables.
-
add_files_to_references
(self, paths)[source]¶ Add multiple file paths to reference list.
Parameters: paths (list) – A list of paths to files
-
receive_files_dropped_on_dc
(self, item, file_paths)[source]¶ Called when files are dropped onto a data connection graphics item. If the item is this Data Connection’s graphics item, add the files to data.
-
add_references
(self, checked=False)[source]¶ Let user select references to files for this data connection.
-
remove_references
(self, checked=False)[source]¶ Remove selected references from reference list. Do not remove anything if there are no references selected.
-
copy_to_project
(self, checked=False)[source]¶ Copy selected file references to this Data Connection’s data directory.
-
datapackage_form_destroyed
(self)[source]¶ Notify a connection that datapackage form has been destroyed.
-
file_references
(self)[source]¶ Returns a list of paths to files that are in this item as references.
-
refresh
(self)[source]¶ Refresh data files in Data Connection Properties. NOTE: Might lead to performance issues.
-
populate_reference_list
(self, items)[source]¶ List file references in QTreeView. If items is None or empty list, model is cleared.
-
populate_data_list
(self, items)[source]¶ List project internal data (files) in QTreeView. If items is None or empty list, model is cleared.
-
plotting
¶
Functions for plotting on PlotWidget.
Currently plotting from the table views found in Graph, Tree and Tabular views are supported.
The main entrance points to plotting are: - plot_selection() which plots selected cells on a table view returning a PlotWidget object - plot_pivot_column() which is a specialized method for plotting entire columns of a pivot table - add_time_series_plot() which adds a time series plot to an existing PlotWidget
author: |
|
---|---|
date: | 9.7.2019 |
Module Contents¶
-
exception
plotting.
PlottingError
(message)[source]¶ Bases:
Exception
An exception signalling failure in plotting.
-
message
[source] Returns the error message.
-
-
plotting.
_raise_if_types_inconsistent
(values)[source]¶ Raises an exception if not all values are TimeSeries or floats.
-
plotting.
_filter_name_columns
(selections)[source]¶ Returns a dict with all but the entry with the greatest key removed.
-
plotting.
_organize_selection_to_columns
(indexes)[source]¶ Organizes a list of model indexes into a dictionary of {column: (rows)} entries.
-
plotting.
_collect_single_column_values
(model, column, rows, hints)[source]¶ Collects selected parameter values from a single column in a PivotTableModel.
The return value of this function depends on what type of data the given column contains. In case of plain numbers, a list of floats and a single label string are returned. In case of time series, a list of TimeSeries objects is returned, accompanied by a list of labels, each label corresponding to one of the time series.
Parameters: - model (QAbstractTableModel) – a table model
- column (int) – a column index to the model
- rows (Sequence) – row indexes to plot
- hints (PlottingHints) – a plot support object
Returns: a tuple of values and label(s)
-
plotting.
_collect_column_values
(model, column, rows, hints)[source]¶ Collects selected parameter values from a single column in a PivotTableModel for plotting.
The return value of this function depends on what type of data the given column contains. In case of plain numbers, a single tuple of two lists of x and y values and a single label string are returned. In case of time series, a list of TimeSeries objects is returned, accompanied by a list of labels, each label corresponding to one of the time series.
Parameters: - model (QAbstractTableModel) – a table model
- column (int) – a column index to the model
- rows (Sequence) – row indexes to plot
- hints (PlottingHints) – a support object
Returns: a tuple of values and label(s)
-
plotting.
plot_pivot_column
(model, column, hints)[source]¶ Returns a plot widget with a plot of an entire column in PivotTableModel.
Parameters: - model (PivotTableModel) – a pivot table model
- column (int) – a column index to the model
- hints (PlottingHints) – a helper needed for e.g. plot labels
Returns: a PlotWidget object
-
plotting.
plot_selection
(model, indexes, hints)[source]¶ Returns a plot widget with plots of the selected indexes.
Parameters: - model (QAbstractTableModel) – a model
- indexes (Iterable) – a list of QModelIndex objects for plotting
- hints (PlottingHints) – a helper needed for e.g. plot labels
Returns: a PlotWidget object
-
plotting.
add_time_series_plot
(plot_widget, value, label=None)[source]¶ Adds a time series step plot to a plot widget.
Parameters: - plot_widget (PlotWidget) – a plot widget to modify
- value (TimeSeries) – the time series to plot
- label (str) – a label for the time series
-
plotting.
tree_graph_view_parameter_value_name
(index, table_view)[source]¶ Returns a label for Tree or Graph view table cell.
Parameters: - index (QModelIndex) – an index to the table model
- table_view (QTableView) – a table view widget corresponding to index
Returns: a unique name for the parameter value as a string
-
class
plotting.
PlottingHints
[source]¶ A base class for plotting hints.
The functionality in this class allows the plotting functions to work without explicit knowledge of the underlying table model or widget.
-
filter_columns
(self, selections, model)[source]¶ Filters columns and returns the filtered selections.
-
is_index_in_data
(self, model, index)[source]¶ Returns true if the cell given by index is actually plottable data.
-
-
class
plotting.
GraphAndTreeViewPlottingHints
(table_view)[source]¶ Bases:
plotting.PlottingHints
Support for plotting data in Graph and Tree views.
-
table_view
¶ a parameter value or definition widget
Type: QTableView
-
cell_label
(self, model, index)[source]¶ Returns a label build from the columns on the left from the data column.
-
-
class
plotting.
PivotTablePlottingHints
[source]¶ Bases:
plotting.PlottingHints
Support for plotting data in Tabular view.
-
is_index_in_data
(self, model, index)[source]¶ Returns True if index is in the data portion of the table.
-
tool_configuration_assistants
¶
Classes for tool configuration assistants.
authors: |
|
---|---|
date: | 10.1.2019 |
Module Contents¶
-
class
tool_configuration_assistants.
SpineModelConfigurationAssistant
(toolbox)[source]¶ Bases:
PySide2.QtCore.QObject
Configuration assistant for SpineModel.jl.
-
spine_model_version_check
(self)[source]¶ Return qsubprocess that checks current version of SpineModel.
-
py_call_program_check
(self)[source]¶ Return qsubprocess that checks the python program used by PyCall in current julia version.
-
time_series_model_variable_resolution
¶
A model for variable resolution time series, used by the parameter value editors.
authors: |
|
---|---|
date: | 5.7.2019 |
Module Contents¶
-
class
time_series_model_variable_resolution.
TimeSeriesModelVariableResolution
(series)[source]¶ Bases:
indexed_value_table_model.IndexedValueTableModel
A model for variable resolution time series type parameter values.
-
series
¶ a time series
Type: TimeSeriesVariableResolution
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the time stamp or the corresponding value at given model index.
Column index 0 refers to time stamps while index 1 to values.
Parameters: - index (QModelIndex) – an index to the model
- role (int) – a role
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Inserts new time stamps and values to the series.
When inserting in the middle of the series the new time stamps are distributed evenly among the time span between the two time stamps around the insertion point. When inserting at the beginning or at the end of the series the duration between the new time stamps is set equal to the first/last duration in the original series.
The new values are set to zero.
Parameters: - row (int) – a numeric index to the first stamp/value to insert
- count (int) – number of stamps/values to insert
- parent (QModelIndex) – index to a parent model
Returns: True if the insertion was successful
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Removes time stamps/values from the series.
Parameters: - row (int) – a numeric index to the series where to begin removing
- count (int) – how many stamps/values to remove
- parent (QModelIndex) – an index to the parent model
Returns: True if the operation was successful.
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Sets a given time stamp or value in the series.
Column index 0 refers to time stamps while index 1 to values.
Parameters: - index (QModelIndex) – an index to the model
- value (numpy.datetime64, float) – a new stamp or value
- role (int) – a role
Returns: True if the operation was successful
-
executioner
¶
Contains classes for handling project item execution.
author: |
|
---|---|
date: | 8.4.2019 |
Module Contents¶
-
class
executioner.
DirectedGraphHandler
(toolbox)[source]¶ Class for manipulating graphs according to user’s actions.
Parameters: toolbox (ToolboxUI) – QMainWindow instance -
remove_dag
(self, dag)[source]¶ Remove graph from instance variable list.
Parameters: dag (DiGraph) – Graph to remove
-
add_dag_node
(self, node_name)[source]¶ Create directed graph with one node and add it to list.
Parameters: node_name (str) – Project item name to add as a node
-
add_graph_edge
(self, src_node, dst_node)[source]¶ Adds an edge between the src and dst nodes. If nodes are in different graphs, the reference to union graph is saved and the references to the original graphs are removed. If src and dst nodes are already in the same graph, the edge is added to the graph. If src and dst are the same node, a self-loop (feedback) edge is added.
Parameters: - src_node (str) – Source project item node name
- dst_node (str) – Destination project item node name
-
remove_graph_edge
(self, src_node, dst_node)[source]¶ Removes edge from a directed graph.
Parameters: - src_node (str) – Source project item node name
- dst_node (str) – Destination project item node name
-
remove_node_from_graph
(self, node_name)[source]¶ Removes node from a graph that contains it. Called when project item is removed from project.
Parameters: node_name (str) – Project item name
-
rename_node
(self, old_name, new_name)[source]¶ Handles renaming the node and edges in a graph when a project item is renamed.
Parameters: - old_name (str) – Old project item name
- new_name (str) – New project item name
Returns: True if successful, False if renaming failed
Return type: bool
-
dag_with_node
(self, node_name)[source]¶ Returns directed graph that contains given node.
Parameters: node_name (str) – Node to look for Returns: Directed graph that contains node or None if not found. Return type: (DiGraph)
-
dag_with_edge
(self, src_node, dst_node)[source]¶ Returns directed graph that contains given edge.
Parameters: - src_node (str) – Source node name
- dst_node (str) – Destination node name
Returns: Directed graph that contains edge or None if not found.
Return type: (DiGraph)
-
calc_exec_order
(self, g)[source]¶ Returns an bfs-ordered list of nodes in the given graph. Adds a dummy source node to the graph if there are more than one nodes that have no inbound connections. The dummy source node is needed for the bfs-algorithm.
Parameters: g (DiGraph) – Directed graph to process Returns: bfs-ordered list of node names (first item at index 0). Empty list if given graph is not a DAG. Return type: list
-
node_is_isolated
(self, node, allow_self_loop=False)[source]¶ Checks if the project item with the given name has any connections.
Parameters: - node (str) – Project item name
- allow_self_loop (bool) – If default (False), Self-loops are considered as an in-neighbor or an out-neighbor so the method returns False. If True, single node with a self-loop is considered isolated.
Returns: - True if project item has no in-neighbors nor out-neighbors, False if it does.
Single node with a self-loop is NOT isolated (returns False).
Return type: bool
-
static
source_nodes
(g)[source]¶ Returns a list of source nodes in given graph. A source node has no incoming edges. This is determined by calculating the in-degree of each node in the graph. If nodes in-degree == 0, it is a source node
Parameters: g (DiGraph) – Graph to examine Returns: List of source node names or an empty list is there are none. Return type: list
-
static
nodes_connected
(dag, a, b)[source]¶ Checks if node a is connected to node b. Edge directions are ignored. If any of source node a’s ancestors or descendants have a path to destination node b, returns True. Also returns True if destination node b has a path to any of source node a’s ancestors or descendants.
Parameters: - dag (DiGraph) – Graph that contains nodes a and b
- a (str) – Node name
- b (str) – Another node name
Returns: True if a and b are connected, False otherwise
Return type: bool
-
-
class
executioner.
ExecutionInstance
(toolbox, execution_list)[source]¶ Bases:
PySide2.QtCore.QObject
Class for the graph that is being executed. Contains references to files and resources advertised by project items so that project items downstream can find them.
Parameters: - toolbox (ToolboxUI) – QMainWindow instance
- execution_list (list) – Ordered list of nodes to execute
-
item_execution_finished
(self, item_finish_state)[source]¶ Pop next project item to execute or finish current graph if there are no items left.
Parameters: - item_finish_state (int) – 0=Continue to next project item. -2=Stop executing this graph (happens when e.g.
- does not find req. input files or something) (Tool) –
-
add_ds_ref
(self, dialect, ref)[source]¶ Adds given database reference to a dictionary. Key is the dialect. If dialect is sqlite, value is a list of full paths to sqlite files. For other dialects, key is the dialect and value is a list of URLs to database servers.
Parameters: - dialect (str) – Dialect name (lower case)
- ref (str) – Database reference
-
add_di_data
(self, di_name, data)[source]¶ Adds given data from data interface to a list.
Parameters: - di_name (str) – Data interface name
- data (dict) – Data to import
-
append_dc_refs
(self, refs)[source]¶ Adds given file paths (Data Connection file references) to a list.
Parameters: refs (list) – List of file paths (references)
-
append_dc_files
(self, files)[source]¶ Adds given project data file paths to a list.
Parameters: files (list) – List of file paths
-
append_tool_output_file
(self, filepath)[source]¶ Adds given file path to a list containing paths to Tool output files.
Parameters: filepath (str) – Path to a tool output file (in tool result directory)
indexed_value_table_model
¶
A model for indexed parameter values, used by the parameter value editors.
authors: |
|
---|---|
date: | 18.6.2019 |
Module Contents¶
-
class
indexed_value_table_model.
IndexedValueTableModel
(value, index_header, value_header)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
A base class for time pattern and time series models.
-
index_header
¶ a header for the index column
Type: str
-
value_header
¶ a header for the value column
Type: str
-
value
[source] Returns the parameter value associated with the model.
-
helpers
¶
General helper functions and classes.
authors: |
|
---|---|
date: | 10.1.2018 |
Module Contents¶
-
helpers.
pyside2_version_check
()[source]¶ Check that PySide2 version is older than 5.12, since this is not supported yet. Issue #238 in GitLab.
qt_version is the Qt version used to compile PySide2 as string. E.g. “5.11.2” qt_version_info is a tuple with each version component of Qt used to compile PySide2. E.g. (5, 11, 2)
-
helpers.
spinedb_api_version_check
()[source]¶ Check if spinedb_api is the correct version and explain how to upgrade if it is not.
-
helpers.
busy_effect
(func)[source]¶ Decorator to change the mouse cursor to ‘busy’ while a function is processed.
Parameters: func – Decorated function.
-
helpers.
project_dir
(qsettings)[source]¶ Returns current project directory.
Parameters: qsettings (QSettings) – Settings object
-
helpers.
get_datetime
(show)[source]¶ Returns date and time string for appending into Event Log messages.
Parameters: show (boolean) – True returns date and time string. False returns empty string.
-
helpers.
create_dir
(base_path, folder='', verbosity=False)[source]¶ Create (input/output) directories recursively.
Parameters: - base_path (str) – Absolute path to wanted dir
- folder (str) – (Optional) Folder name. Usually short name of item.
- verbosity (bool) – True prints a message that tells if the directory already existed or if it was created.
Returns: True if directory already exists or if it was created successfully.
Raises: OSError if operation failed.
-
helpers.
create_output_dir_timestamp
()[source]¶ Creates a new timestamp string that is used as Tool output directory.
Returns: Timestamp string or empty string if failed.
-
helpers.
create_log_file_timestamp
()[source]¶ Creates a new timestamp string that is used as Data Interface and Data Store error log file.
Returns: Timestamp string or empty string if failed.
-
helpers.
copy_files
(src_dir, dst_dir, includes=None, excludes=None)[source]¶ Method for copying files. Does not copy folders.
Parameters: - src_dir (str) – Source directory
- dst_dir (str) – Destination directory
- includes (list) – Included files (wildcards accepted)
- excludes (list) – Excluded files (wildcards accepted)
Returns: Number of files copied
Return type: count (int)
-
helpers.
erase_dir
(path, verbosity=False)[source]¶ Delete directory and all its contents without prompt.
Parameters: - path (str) – Path to directory
- verbosity (bool) – Print logging messages or not
-
helpers.
copy_dir
(widget, src_dir, dst_dir)[source]¶ Make a copy of a directory. All files and folders are copied.
Parameters: - widget (QWidget) – Parent widget for QMessageBoxes
- src_dir (str) – Absolute path to directory that will be copied
- dst_dir (str) – Absolute path to new directory
-
helpers.
rename_dir
(widget, old_dir, new_dir)[source]¶ Rename directory. Note: This is not used in renaming projects due to unreliability. Looks like it works fine in renaming project items though.
Parameters: - widget (QWidget) – Parent widget for QMessageBoxes
- old_dir (str) – Absolute path to directory that will be renamed
- new_dir (str) – Absolute path to new directory
-
helpers.
fix_name_ambiguity
(name_list, offset=0)[source]¶ Modify repeated entries in name list by appending an increasing integer.
-
helpers.
tuple_itemgetter
(itemgetter_func, num_indexes)[source]¶ Change output of itemgetter to always be a tuple even for one index
-
helpers.
format_string_list
(str_list)[source]¶ Return an unordered html list with all elements in str_list. Intended to print error logs as returned by spinedb_api.
Parameters: str_list (list(str)) –
-
helpers.
get_db_map
(url, upgrade=False)[source]¶ Returns a DiffDatabaseMapping instance from url. If the db is not the latest version, asks the user if they want to upgrade it.
-
helpers.
do_get_db_map
(url, upgrade)[source]¶ Returns a DiffDatabaseMapping instance from url. Called by get_db_map.
-
helpers.
int_list_to_row_count_tuples
(int_list)[source]¶ Breaks a list of integers into a list of tuples (row, count) corresponding to chunks of successive elements.
-
class
helpers.
IconListManager
(icon_size)[source]¶ A class to manage icons for icon list widgets.
-
class
helpers.
IconManager
[source]¶ A class to manage object class icons for data store forms.
-
create_object_pixmap
(self, display_icon)[source]¶ Create a pixmap corresponding to display_icon, cache it, and return it.
-
setup_object_pixmaps
(self, object_classes)[source]¶ Called after adding or updating object classes. Create the corresponding object pixmaps and clear obsolete entries from the relationship class icon cache.
-
-
class
helpers.
CharIconEngine
(char, color)[source]¶ Bases:
PySide2.QtGui.QIconEngine
Specialization of QIconEngine used to draw font-based icons.
-
helpers.
make_icon_id
(icon_code, color_code)[source]¶ Take icon and color codes, and return equivalent integer.
tool
¶
Tool class.
author: |
|
---|---|
date: | 19.12.2017 |
Module Contents¶
-
class
tool.
Tool
(toolbox, name, description, tool_template, use_work, x, y)[source]¶ Bases:
project_item.ProjectItem
Tool class.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
tool_template
[source]¶ Template for this Tool
Type: ToolTemplate
-
use_work
¶ Execute associated Tool template in work (True) or source directory (False)
Type: bool
-
x
¶ Initial X coordinate of item icon
Type: int
-
y
¶ Initial Y coordinate of item icon
Type: int
-
make_signal_handler_dict
(self)[source]¶ Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.
-
restore_selections
(self)[source]¶ Restore selections into shared widgets when this project item is selected.
-
save_selections
(self)[source]¶ Save selections in shared widgets for this project item into instance variables.
-
update_tool_template
(self, row)[source]¶ Update Tool template according to selection in the template comboBox.
Parameters: row (int) – Selected row in the comboBox
-
set_tool_template
(self, tool_template)[source]¶ Sets Tool Template for this Tool. Removes Tool Template if None given as argument.
Parameters: tool_template (ToolTemplate) – Template for this Tool. None removes the template.
-
update_tool_ui
(self)[source]¶ Update Tool UI to show Tool template details. Used when Tool template is changed. Overrides execution mode (work or source) with the template default.
-
restore_tool_template
(self, tool_template)[source]¶ Restores the Tool Template of this Tool. Removes Tool Template if None given as argument. Needed in order to override tool template default execution mode (work or source).
Parameters: tool_template (ToolTemplate) – Template for this Tool. None removes the template.
-
edit_tool_template
(self)[source]¶ Open Tool template editor for the Tool template attached to this Tool.
-
open_tool_main_program_file
(self)[source]¶ Open Tool template main program file in an external text edit application.
-
open_tool_main_directory
(self)[source]¶ Open directory where the Tool template main program is located in file explorer.
-
tool_template
(self)[source] Returns Tool template.
-
count_files_and_dirs
(self)[source]¶ Count the number of files and directories in required input files model.
Returns: Tuple containing the number of required files and directories.
-
create_subdirectories
(self)[source]¶ Iterate items in required input files and check if there are any directories to create. Create found directories directly to ToolInstance base directory.
Returns: Boolean variable depending on success
-
copy_input_files
(self, paths)[source]¶ Copy input files from given paths to work or source directory, depending on where the Tool template requires them to be.
Parameters: paths (dict) – Key is path to destination file, value is path to source file. Returns: Boolean variable depending on operation success
-
copy_optional_input_files
(self, paths)[source]¶ Copy optional input files from given paths to work or source directory, depending on where the Tool template requires them to be.
Parameters: paths (dict) – Key is the optional file name pattern, value is a list of paths to source files. Returns: Boolean variable depending on operation success
-
find_output_items
(self)[source]¶ Find output items of this Tool.
Returns: List of Data Store and Data Connection items.
-
update_instance
(self)[source]¶ Initialize and update instance so that it is ready for processing. This is where Tool type specific initialization happens (whether the tool is GAMS, Python or Julia script).
-
populate_source_file_model
(self, items)[source]¶ Add required source files (includes) into a model. If items is None or an empty list, model is cleared.
-
populate_input_file_model
(self, items)[source]¶ Add required Tool input files into a model. If items is None or an empty list, model is cleared.
-
populate_opt_input_file_model
(self, items)[source]¶ Add optional Tool template files into a model. If items is None or an empty list, model is cleared.
-
populate_output_file_model
(self, items)[source]¶ Add Tool output files into a model. If items is None or an empty list, model is cleared.
-
populate_template_model
(self, populate)[source]¶ Add all tool template specs to a single QTreeView. If items is None or an empty list, model is cleared.
Parameters: populate (bool) – False to clear model, True to populate.
-
find_input_files
(self)[source]¶ Iterates files in required input files model and looks for them from execution instance.
Returns: Dictionary of paths where required files are found or None if some file was not found.
-
find_optional_input_files
(self)[source]¶ Tries to find optional input files from previous project items in the DAG. Returns found paths.
Returns: Dictionary of optional input file paths or an empty dictionary if no files found. Key is the optional input item and value is a list of paths that matches the item.
-
time_series_model_fixed_resolution
¶
A model for fixed resolution time series, used by the parameter value editors.
authors: |
|
---|---|
date: | 4.7.2019 |
Module Contents¶
-
class
time_series_model_fixed_resolution.
TimeSeriesModelFixedResolution
(series)[source]¶ Bases:
indexed_value_table_model.IndexedValueTableModel
A model for fixed resolution time series type parameter values.
-
series
¶ a time series
Type: TimeSeriesFixedResolution
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the time stamp or the corresponding value at given model index.
Column index 0 refers to time stamps while index 1 to values.
Parameters: - index (QModelIndex) – an index to the model
- role (int) – a role
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Inserts new values to the series.
The new values are set to zero. Start time or resolution are left unchanged.
Parameters: - row (int) – a numeric index to the first stamp/value to insert
- count (int) – number of stamps/values to insert
- parent (QModelIndex) – index to a parent model
Returns: True if the operation was successful
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Removes values from the series.
Parameters: - row (int) – a numeric index to the series where to begin removing
- count (int) – how many stamps/values to remove
- parent (QModelIndex) – an index to the parent model
Returns: True if the operation was successful.
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Sets a given value in the series.
Column index 1 refers to values. Note it does not make sense to set the time stamps in fixed resolution series.
Parameters: - index (QModelIndex) – an index to the model
- value (numpy.datetime64, float) – a new stamp or value
- role (int) – a role
Returns: True if the operation was successful
-
datapackage_import_export
¶
Functions to import/export between spine database and frictionless data’s datapackage.
author: |
|
---|---|
date: | 28.8.2018 |
treeview_models
¶
Classes for handling models in tree and graph views.
authors: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
class
treeview_models.
ObjectClassListModel
(graph_view_form)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to list object classes in the GraphViewForm.
-
class
treeview_models.
RelationshipClassListModel
(graph_view_form)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to list relationship classes in the GraphViewForm.
-
class
treeview_models.
ObjectTreeModel
(parent, flat=False)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to display Spine data structure in a treeview with object classes at the outer level.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index.
-
static
backward_sweep
(index, call=None)[source]¶ Sweep the tree from the given index towards the root, and apply call on each.
-
forward_sweep
(self, index, call=None)[source]¶ Sweep the tree from the given index towards the leaves, and apply call on each.
-
new_relationship_class_row
(self, db_map, relationship_class)[source]¶ Returns new relationship class item.
-
add_relationship_classes
(self, db_map, relationship_classes)[source]¶ Add relationship class items to model.
-
update_object_classes
(self, db_map, object_classes)[source]¶ Update object classes in the model. This of course means updating the object class name in relationship class items.
-
update_objects
(self, db_map, objects)[source]¶ Update object in the model. This of course means updating the object name in relationship items.
-
update_relationship_classes
(self, db_map, relationship_classes)[source]¶ Update relationship classes in the model.
-
update_relationships
(self, db_map, relationships)[source]¶ Update relationships in the model. Move rows if the objects in the relationship change.
-
-
class
treeview_models.
RelationshipTreeModel
(parent)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to display Spine data structure in a treeview with relationship classes at the outer level.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index.
-
new_relationship_class_row
(self, db_map, relationship_class)[source]¶ Returns new relationship class item.
-
add_relationship_classes
(self, db_map, relationship_classes)[source]¶ Add relationship class items to the model.
-
update_object_classes
(self, db_map, object_classes)[source]¶ Update object classes in the model. This just means updating the object class name in relationship class items.
-
update_objects
(self, db_map, objects)[source]¶ Update object in the model. This just means updating the object name in relationship items.
-
update_relationship_classes
(self, db_map, relationship_classes)[source]¶ Update relationship classes in the model.
-
-
class
treeview_models.
SubParameterModel
(parent)[source]¶ Bases:
models.MinimalTableModel
A parameter model which corresponds to a slice of the entire table. The idea is to combine several of these into one big model. Allows specifying set of columns that are non-editable (e.g., object_class_name) TODO: how column insertion/removal impacts fixed_columns?
-
class
treeview_models.
SubParameterValueModel
(parent)[source]¶ Bases:
treeview_models.SubParameterModel
A parameter model which corresponds to a slice of an entire parameter value table. The idea is to combine several of these into one big model.
-
class
treeview_models.
SubParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.SubParameterModel
A parameter model which corresponds to a slice of an entire parameter definition table. The idea is to combine several of these into one big model.
-
class
treeview_models.
EmptyParameterModel
(parent)[source]¶ Bases:
models.EmptyRowModel
An empty parameter model. It implements bath_set_data for all ‘EmptyParameter’ models.
-
class
treeview_models.
EmptyParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterModel
An empty parameter value model. Implements add_items_to_db for both EmptyObjectParameterValueModel and EmptyRelationshipParameterValueModel.
-
class
treeview_models.
EmptyObjectParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterValueModel
An empty object parameter value model. Implements items_to_add.
-
class
treeview_models.
EmptyRelationshipParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterValueModel
An empty relationship parameter value model. Reimplements alsmot all methods from the super class EmptyParameterModel.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. A little different from the base class implementation, since here we need to support creating relationships on the fly.
-
relationships_on_the_fly
(self, indexes)[source]¶ A dict of row (int) to relationship item (KeyedTuple), which can be either retrieved or added on the fly. Extend set of indexes as additional data is set.
-
-
class
treeview_models.
EmptyParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterModel
An empty parameter definition model.
-
class
treeview_models.
EmptyObjectParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterDefinitionModel
An empty object parameter definition model.
-
class
treeview_models.
EmptyRelationshipParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterDefinitionModel
An empty relationship parameter definition model.
-
class
treeview_models.
ObjectParameterModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model that concatenates several ‘sub’ object parameter models, one per object class.
-
flags
(self, index)[source]¶ Return flags for given index. Depending on the index’s row we will land on a specific model. Models whose object class id is not selected are skipped.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Return data for given index and role. Depending on the index’s row we will land on a specific model. Models whose object class id is not selected are skipped.
-
rowCount
(self, parent=QModelIndex())[source]¶ Return the sum of rows in all models. Skip models whose object class id is not selected.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. Distribute indexes and data among the different submodels and call batch_set_data on each of them.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-model (or the empty model) and call insertRows on it.
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-models (or empty model) and call removeRows on them.
-
auto_filter_values
(self, column)[source]¶ Return values to populate the auto filter of given column. Each ‘row’ in the returned value consists of: 1) The ‘checked’ state, True if the value hasn’t been filtered out 2) The value itself (an object name, a parameter name, a numerical value…) 3) A set of object class ids where the value is found.
Rename parameter tags in model.
Remove parameter tags from model.
-
-
class
treeview_models.
ObjectParameterValueModel
(parent=None)[source]¶ Bases:
treeview_models.ObjectParameterModel
A model that concatenates several ‘sub’ object parameter value models, one per object class.
-
class
treeview_models.
ObjectParameterDefinitionModel
(parent=None)[source]¶ Bases:
treeview_models.ObjectParameterModel
A model that concatenates several object parameter definition models (one per object class) vertically.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter definition data for a different object class.
-
move_rows_to_sub_models
(self, rows)[source]¶ Move rows from empty row model to a new sub_model. Called when the empty row model succesfully inserts new data in the db.
-
-
class
treeview_models.
RelationshipParameterModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model that combines several relationship parameter models (one per relationship class), one on top of the other.
-
add_object_class_id_lists
(self, db_map, wide_relationship_class_list)[source]¶ Populate a dictionary of object class id lists per relationship class.
-
flags
(self, index)[source]¶ Return flags for given index. Depending on the index’s row we will land on a specific model. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Return data for given index and role. Depending on the index’s row we will land on a specific model. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
rowCount
(self, parent=QModelIndex())[source]¶ Return the sum of rows in all models. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. Distribute indexes and data among the different submodels and call batch_set_data on each of them.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-model (or the empty model) and call insertRows on it.
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-models (or empty model) and call removeRows on them.
-
auto_filter_values
(self, column)[source]¶ Return values to populate the auto filter of given column. Each ‘row’ in the returned value consists of: 1) The ‘checked’ state, True if the value hasn’t been filtered out 2) The value itself (an object name, a parameter name, a numerical value…) 3) A set of relationship class ids where the value is found.
-
rename_relationship_classes
(self, db_map, relationship_classes)[source]¶ Rename relationship classes in model.
Rename parameter tags in model.
-
remove_relationship_classes
(self, db_map, relationship_classes)[source]¶ Remove relationship classes from model.
Remove parameter tags from model.
-
-
class
treeview_models.
RelationshipParameterValueModel
(parent=None)[source]¶ Bases:
treeview_models.RelationshipParameterModel
A model that combines several relationship parameter value models (one per relationship class), one on top of the other.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter value data for a different relationship class.
-
-
class
treeview_models.
RelationshipParameterDefinitionModel
(parent=None)[source]¶ Bases:
treeview_models.RelationshipParameterModel
A model that combines several relationship parameter definition models (one per relationship class), one on top of the other.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter definition data for a different relationship class.
-
move_rows_to_sub_models
(self, rows)[source]¶ Move rows from empty row model to a new sub_model. Called when the empty row model succesfully inserts new data in the db.
-
-
class
treeview_models.
ObjectParameterDefinitionFilterProxyModel
(parent, parameter_definition_id_column)[source]¶ Bases:
PySide2.QtCore.QSortFilterProxyModel
A filter proxy model for object parameter models.
-
class
treeview_models.
ObjectParameterValueFilterProxyModel
(parent, parameter_definition_id_column, object_id_column, db_column)[source]¶ Bases:
treeview_models.ObjectParameterDefinitionFilterProxyModel
A filter proxy model for object parameter value models.
-
class
treeview_models.
RelationshipParameterDefinitionFilterProxyModel
(parent, parameter_definition_id_column)[source]¶ Bases:
PySide2.QtCore.QSortFilterProxyModel
A filter proxy model for relationship parameter definition models.
-
class
treeview_models.
RelationshipParameterValueFilterProxyModel
(parent, parameter_definition_id_column, object_id_list_column, db_column)[source]¶ Bases:
treeview_models.RelationshipParameterDefinitionFilterProxyModel
A filter proxy model for relationship parameter value models.
-
class
treeview_models.
TreeNode
(parent, row, text=None, level=None, identifier=None)[source]¶ A helper class to use as the internalPointer of indexes in ParameterValueListModel.
- Attributes
- parent (TreeNode): the parent node row (int): the row, needed by ParameterValueListModel.parent() text (str, NoneType): the text to show level (int, NoneType): the level in the tree id (int, NoneType): the id from the db table
-
class
treeview_models.
ParameterValueListModel
(parent)[source]¶ Bases:
PySide2.QtCore.QAbstractItemModel
A class to display parameter value list data in a treeview.
-
index
(self, row, column, parent=QModelIndex())[source]¶ Returns the index of the item in the model specified by the given row, column and parent index. Toplevel indexes get their pointer from the _root_nodes attribute; whereas inner indexes get their pointer from the child_nodes attribute of the parent node.
-
parent
(self, index)[source]¶ Returns the parent of the model item with the given index. Use the internal pointer to retrieve the parent node and use it to create the parent index.
-
rowCount
(self, parent=QModelIndex())[source]¶ Returns the number of rows under the given parent. Get it from the lenght of the appropriate list.
-
columnCount
(self, parent=QModelIndex())[source]¶ Returns the number of columns under the given parent. Always 1.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index. Bold toplevel items. Get the DisplayRole from the text attribute of the internal pointer.
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Sets the role data for the item at index to value. Returns True if successful; otherwise returns False. Basically just update the text attribute of the internal pointer.
-
appendRows
(self, count, parent=QModelIndex())[source]¶ Append count rows into the model. Items in the new row will be children of the item represented by the parent model index.
-
_handle_data_changed
(self, top_left, bottom_right, roles=None)[source]¶ Called when data in the model changes.
-
append_empty_rows
(self, index)[source]¶ Append emtpy rows if index is the last children, so the user can continue editing the model.
-
-
class
treeview_models.
LazyLoadingArrayModel
(parent, stride=256)[source]¶ Bases:
models.EmptyRowModel
A model of array data, used by TreeViewForm.
-
parent
¶ the parent widget
Type: JSONEditor
-
stride
¶ The number of elements to fetch
Type: int
-
tool_templates
¶
Tool template classes.
authors: |
|
---|---|
date: | 24.1.2018 |
Module Contents¶
-
class
tool_templates.
ToolTemplate
(toolbox, name, tooltype, path, includes, description=None, inputfiles=None, inputfiles_opt=None, outputfiles=None, cmdline_args=None, execute_in_work=True)[source]¶ Bases:
metaobject.MetaObject
Super class for various tool templates.
-
toolbox
¶ QMainWindow instance
Type: ToolBoxUI
-
name
¶ Name of the tool
Type: str
-
description
¶ Short description of the tool
Type: str
-
path
¶ Path to tool
Type: str
-
includes
¶ List of files belonging to the tool template (relative to ‘path’) # TODO: Change to src_files
Type: str
-
inputfiles
¶ List of required data files
Type: list
-
inputfiles_opt
¶ List of optional data files (wildcards may be used)
Type: list, optional
-
outputfiles
¶ List of output files (wildcards may be used)
Type: list, optional
-
cmdline_args
¶ Tool command line arguments (read from tool definition file)
Type: str, optional
-
execute_in_work
¶ Execute in work folder?
Type: bool
-
set_return_code
(self, code, description)[source]¶ Set a return code and associated text description for the tool.
Parameters: - code (int) – Return code
- description (str) – Description
-
set_def_path
(self, path)[source]¶ Set definition file path for tool.
Parameters: path (str) – Absolute path to the definition file.
-
static
check_definition
(ui, data)[source]¶ Check that a tool template definition contains the required keys and that it is in correct format.
Parameters: - ui (ToolboxUI) – QMainWindow instance
- data (dict) – Tool template definition
Returns: Dictionary or None if there was a problem in the tool definition.
-
-
class
tool_templates.
GAMSTool
(toolbox, name, tooltype, path, includes, description=None, inputfiles=None, inputfiles_opt=None, outputfiles=None, cmdline_args=None, execute_in_work=True)[source]¶ Bases:
tool_templates.ToolTemplate
Class for GAMS tool templates.
-
name
¶ GAMS Tool name
Type: str
-
description
¶ GAMS Tool description
Type: str
-
path
¶ Path to model main file
Type: str
-
includes
¶ List of files belonging to the tool (relative to ‘path’). # TODO: Change to src_files
Type: str
-
First file in the list is the main GAMS program.
-
inputfiles
¶ List of required data files
Type: list
-
inputfiles_opt
¶ List of optional data files (wildcards may be used)
Type: list, optional
-
outputfiles
¶ List of output files (wildcards may be used)
Type: list, optional
-
cmdline_args
¶ GAMS tool command line arguments (read from tool definition file)
Type: str, optional
-
update_gams_options
(self, key, value)[source]¶ Update GAMS command line options. Only ‘cerr and ‘logoption’ keywords supported.
Parameters: - key – Option name
- value – Option value
-
static
load
(toolbox, path, data)[source]¶ Create a GAMSTool according to a tool definition.
Parameters: - toolbox (ToolboxUI) – QMainWindow instance
- path (str) – Base path to tool files
- data (dict) – Dictionary of tool definitions
Returns: GAMSTool instance or None if there was a problem in the tool definition file.
-
-
class
tool_templates.
JuliaTool
(toolbox, name, tooltype, path, includes, description=None, inputfiles=None, inputfiles_opt=None, outputfiles=None, cmdline_args=None, execute_in_work=True)[source]¶ Bases:
tool_templates.ToolTemplate
Class for Julia tool templates.
-
name
¶ Julia Tool name
Type: str
-
description
¶ Julia Tool description
Type: str
-
path
¶ Path to model main file
Type: str
-
includes
¶ List of files belonging to the tool (relative to ‘path’). # TODO: Change to src_files
Type: str
-
First file in the list is the main Julia program.
-
inputfiles
¶ List of required data files
Type: list
-
inputfiles_opt
¶ List of optional data files (wildcards may be used)
Type: list, optional
-
outputfiles
¶ List of output files (wildcards may be used)
Type: list, optional
-
cmdline_args
¶ Julia tool command line arguments (read from tool definition file)
Type: str, optional
-
update_julia_options
(self, key, value)[source]¶ Update Julia command line options.
Parameters: - key – Option name
- value – Option value
-
static
load
(toolbox, path, data)[source]¶ Create a JuliaTool according to a tool definition.
Parameters: - toolbox (ToolboxUI) – QMainWindow instance
- path (str) – Base path to tool files
- data (dict) – Dictionary of tool definitions
Returns: JuliaTool instance or None if there was a problem in the tool definition file.
-
-
class
tool_templates.
PythonTool
(toolbox, name, tooltype, path, includes, description=None, inputfiles=None, inputfiles_opt=None, outputfiles=None, cmdline_args=None, execute_in_work=True)[source]¶ Bases:
tool_templates.ToolTemplate
Class for Python tool templates.
-
name
¶ Python Tool name
Type: str
-
description
¶ Python Tool description
Type: str
-
path
¶ Path to model main file
Type: str
-
includes
¶ List of files belonging to the tool (relative to ‘path’). # TODO: Change to src_files
Type: str
-
First file in the list is the main Python program.
-
inputfiles
¶ List of required data files
Type: list
-
inputfiles_opt
¶ List of optional data files (wildcards may be used)
Type: list, optional
-
outputfiles
¶ List of output files (wildcards may be used)
Type: list, optional
-
cmdline_args
¶ Python tool command line arguments (read from tool definition file)
Type: str, optional
-
update_python_options
(self, key, value)[source]¶ Update Python command line options.
Parameters: - key – Option name
- value – Option value
-
static
load
(toolbox, path, data)[source]¶ Create a PythonTool according to a tool definition.
Parameters: - toolbox (ToolboxUI) – QMainWindow instance
- path (str) – Base path to tool files
- data (dict) – Dictionary of tool definitions
Returns: PythonTool instance or None if there was a problem in the tool definition file.
-
-
class
tool_templates.
ExecutableTool
(toolbox, name, tooltype, path, includes, description=None, inputfiles=None, inputfiles_opt=None, outputfiles=None, cmdline_args=None, execute_in_work=True)[source]¶ Bases:
tool_templates.ToolTemplate
Class for Executable tool templates.
-
name
¶ Tool name
Type: str
-
description
¶ Tool description
Type: str
-
path
¶ Path to main script file
Type: str
-
includes
¶ List of files belonging to the tool (relative to ‘path’). # TODO: Change to src_files
Type: str
-
First file in the list is the main script file.
-
inputfiles
¶ List of required data files
Type: list
-
inputfiles_opt
¶ List of optional data files (wildcards may be used)
Type: list, optional
-
outputfiles
¶ List of output files (wildcards may be used)
Type: list, optional
-
cmdline_args
¶ Tool command line arguments (read from tool definition file)
Type: str, optional
-
static
load
(toolbox, path, data)[source]¶ Create an ExecutableTool according to a tool specification.
Parameters: - toolbox (ToolboxUI) – QMainWindow instance
- path (str) – Base path to tool files
- data (dict) – Tool specification
Returns: ExecutableTool instance or None if there was a problem in the tool specification.
-
tool_instance
¶
Contains ToolInstance class.
authors: |
|
---|---|
date: | 1.2.2018 |
Module Contents¶
-
class
tool_instance.
ToolInstance
(tool_template, toolbox, tool_output_dir, project, execute_in_work)[source]¶ Bases:
PySide2.QtCore.QObject
Class for Tool instances.
Parameters: - tool_template (ToolTemplate) – Tool for which this instance is created
- toolbox (ToolboxUI) – QMainWindow instance
- tool_output_dir (str) – Directory where results are saved
- project (SpineToolboxProject) – Current project
- execute_in_work (bool) – True executes instance in work dir, False executes in Tool template source dir
- Class Variables:
- instance_finished_signal (Signal): Signal to emit when a Tool instance has finished processing
-
execute
(self)[source]¶ Starts executing Tool template instance in Julia Console, Python Console or in a sub-process.
-
julia_repl_tool_finished
(self, ret)[source]¶ Runs when Julia tool using Julia Console has finished processing.
Parameters: ret (int) – Tool template process return value
-
julia_tool_finished
(self, ret)[source]¶ Runs when Julia tool from command line (without REPL) has finished processing.
Parameters: ret (int) – Tool template process return value
-
python_console_tool_finished
(self, ret)[source]¶ Runs when Python Tool in Python Console has finished processing.
Parameters: ret (int) – Tool template process return value
-
python_tool_finished
(self, ret)[source]¶ Runs when Python tool from command line has finished processing.
Parameters: ret (int) – Tool template process return value
-
gams_tool_finished
(self, ret)[source]¶ Runs when GAMS tool has finished processing.
Parameters: ret (int) – Tool template process return value
-
executable_tool_finished
(self, ret)[source]¶ Runs when an executable tool has finished processing.
Parameters: ret (int) – Tool template process return value
-
handle_output_files
(self, ret)[source]¶ Creates a timestamped result directory for Tool template output files. Starts copying Tool template output files from work directory to result directory and print messages to Event Log depending on how the operation went.
Parameters: ret (int) – Tool template process return value
-
copy_output
(self, target_dir)[source]¶ Copies Tool template output files from work directory to given target directory.
Parameters: target_dir (str) – Destination directory for Tool template output files Returns: Contains two lists. The first list contains paths to successfully copied files. The second list contains paths (or patterns) of Tool template output files that were not found. Return type: tuple Raises: OSError
– If creating a directory fails.
-
make_work_output_dirs
(self)[source]¶ Makes sure that work directory has the necessary output directories for Tool output files. Checks only “outputfiles” list. Alternatively you can add directories to “inputfiles” list in the tool definition file.
Returns: True for success, False otherwise. Return type: bool Raises: OSError
– If creating an output directory to work fails.
data_store
¶
Module for data store class.
authors: |
|
---|---|
date: | 18.12.2017 |
Module Contents¶
-
class
data_store.
DataStore
(toolbox, name, description, url, x, y)[source]¶ Bases:
project_item.ProjectItem
Data Store class.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
x
¶ Initial X coordinate of item icon
Type: int
-
y
¶ Initial Y coordinate of item icon
Type: int
-
make_signal_handler_dict
(self)[source]¶ Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.
-
url
(self)[source] Return the url attribute, for saving the project.
-
make_url
(self, log_errors=True)[source]¶ Return a sqlalchemy url from the current url attribute or None if not valid.
-
open_sqlite_file
(self, checked=False)[source]¶ Open file browser where user can select the path to an SQLite file that they want to use.
-
load_url_into_selections
(self)[source]¶ Load url attribute into shared widget selections. Used when activating the item, and creating a new Spine db.
-
enable_no_dialect
(self)[source]¶ Adjust widget enabled status to default when no dialect is selected.
-
check_dialect
(self, dialect)[source]¶ Check if selected dialect is supported. Offer to install DBAPI if not.
Returns: True if dialect is supported, False if not.
-
install_dbapi_conda
(self, dbapi)[source]¶ Install DBAPI using conda. Fails if conda is not installed.
-
open_directory
(self, checked=False)[source]¶ Open file explorer in this Data Store’s data directory.
-
do_create_new_spine_database
(self, url, for_spine_model)[source]¶ Separate method so ‘busy_effect’ don’t overlay any message box.
-
qsubprocess
¶
Module to handle running tools in a QProcess.
author: |
|
---|---|
date: | 1.2.2018 |
Module Contents¶
-
class
qsubprocess.
QSubProcess
(toolbox, program=None, args=None, silent=False, semisilent=False)[source]¶ Bases:
PySide2.QtCore.QObject
Class to handle starting, running, and finishing PySide2 QProcesses.
-
start_process
(self, workdir=None)[source]¶ Start the execution of a command in a QProcess.
Parameters: workdir (str) – Script directory
-
wait_for_finished
(self, msecs=30000)[source]¶ Wait for subprocess to finish.
Returns: True if process finished successfully, False otherwise
-
on_state_changed
(self, new_state)[source]¶ Runs when QProcess state changes.
Parameters: new_state (QProcess::ProcessState) – Process state number
-
on_process_error
(self, process_error)[source]¶ Run if there is an error in the running QProcess.
Parameters: process_error (QProcess::ProcessError) – Process error number
-
metaobject
¶
MetaObject class.
authors: |
|
---|---|
date: | 18.12.2017 |
Module Contents¶
-
class
metaobject.
MetaObject
(name, description)[source]¶ Bases:
PySide2.QtCore.QObject
Class for an object which has a name, type, and some description.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
tabularview_models
¶
Spine Toolbox grid view
author: |
|
---|---|
date: | 1.11.2018 |
Module Contents¶
-
class
tabularview_models.
PivotModel
[source]¶ -
-
set_new_data
(self, data, index_names, index_type, rows=(), columns=(), frozen=(), frozen_value=(), index_entries=None, valid_index_values=None, tuple_index_entries=None, used_index_values=None, index_real_names=None)[source]¶ set the data of the model, index names and any additional indexes that don’t have data, valid index values.
-
static
_is_invalid_pivot
(rows, columns, frozen, frozen_value, index_names)[source]¶ checks if given pivot is valid for index_names, returns str with error message if invalid else None
-
_index_key_getter
(self, names_of_index)[source]¶ creates a itemgetter that always returns tuples from list of index names
-
_get_unique_index_values
(self, index, filter_index, filter_value)[source]¶ Finds unique index values for index names in index filtered by index names in filter_index with values in filter_value
-
static
_index_entries_without_data
(pivot_index, pivot_set, filter_index, filter_value, tuple_index_entries)[source]¶ find values in tuple_index_entries that are not present in pivot_set for index in pivot index filtered by filter_index and filter_value
-
get_pivoted_data
(self, row_mask, col_mask)[source]¶ gets data from current pivot with indexes in row_mask and col_mask
-
set_pivoted_data
(self, data, row_mask, col_mask)[source]¶ paste list of lists into current pivot, no change of indexes, row_mask list of indexes where to paste data rows in current pivot col_mask list of indexes where to paste data columns in current pivot
-
delete_tuple_index_values
(self, delete_tuples)[source]¶ deletes values from keys with combination of indexes given that match tuple_index_entries
-
paste_data
(self, row_start=0, row_header_data=None, col_start=0, col_header_data=None, data=None, row_mask=None, col_mask=None)[source]¶ Paste a list of list into current view of AbstractTable
-
-
class
tabularview_models.
PivotTableModel
(parent=None)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
-
set_data
(self, data, index_names, index_type, rows=(), columns=(), frozen=(), frozen_value=(), index_entries=None, valid_index_values=None, tuple_index_entries=None, used_index_values=None, index_real_names=None)[source]¶
-
rowCount
(self, parent=QModelIndex())[source]¶ Number of rows in table, number of header rows + datarows + 1 empty row
-
columnCount
(self, parent=QModelIndex())[source]¶ Number of columns in table, number of header columns + datacolumns + 1 empty columns
-
index_in_top_left
(self, index)[source]¶ check if index is in top left corner, where pivot names are displayed
-
-
class
tabularview_models.
PivotTableSortFilterProxy
(parent=None)[source]¶ Bases:
PySide2.QtCore.QSortFilterProxyModel
data_interface
¶
Contains DataInterface class.
authors: |
|
---|---|
date: | 10.6.2019 |
Module Contents¶
-
class
data_interface.
DataInterface
(toolbox, name, description, filepath, settings, x, y)[source]¶ Bases:
project_item.ProjectItem
DataInterface class.
-
name
¶ Project item name
Type: str
-
description
¶ Project item description
Type: str
-
filepath
¶ Path to file
Type: str
-
settings
¶ dict with mapping settings
Type: dict
-
x
¶ Initial icon scene X coordinate
Type: int
-
y
¶ Initial icon scene Y coordinate
Type: int
-
make_signal_handler_dict
(self)[source]¶ Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.
-
restore_selections
(self)[source]¶ Restores selections into shared widgets when this project item is selected.
-
save_selections
(self)[source]¶ Saves selections in shared widgets for this project item into instance variables.
-
update_name_label
(self)[source]¶ Update Data Interface tab name label. Used only when renaming project items.
-
_handle_import_editor_clicked
(self, checked=False)[source]¶ Opens Import editor for the file selected in list view.
-
_handle_files_double_clicked
(self, index)[source]¶ Opens Import editor for the double clicked index.
-
get_connector
(self, importee)[source]¶ Shows a QDialog to select a connector for the given source file. Mimics similar routine in spine_io.widgets.import_widget.ImportDialog
-
select_connector_type
(self, index)[source]¶ Opens dialog to select connector type for the given index.
-
view
¶
Module for view class.
authors: |
|
---|---|
date: | 14.07.2018 |
Module Contents¶
-
class
view.
View
(toolbox, name, description, x, y)[source]¶ Bases:
project_item.ProjectItem
View class.
-
name
¶ Object name
Type: str
-
description
¶ Object description
Type: str
-
x
¶ Initial X coordinate of item icon
Type: int
-
y
¶ Initial Y coordinate of item icon
Type: int
-
make_signal_handler_dict
(self)[source]¶ Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.
-
restore_selections
(self)[source]¶ Restore selections into shared widgets when this project item is selected.
-
save_selections
(self)[source]¶ Save selections in shared widgets for this project item into instance variables.
-
find_input_items
(self)[source]¶ Find input project items (only Data Stores now) that are connected to this View.
Returns: List of Data Store items.
-
open_graph_view_btn_clicked
(self, checked=False)[source]¶ Slot for handling the signal emitted by clicking on ‘Graph view’ button.
-
open_tabular_view_btn_clicked
(self, checked=False)[source]¶ Slot for handling the signal emitted by clicking on ‘Tabular view’ button.
-
open_tree_view_btn_clicked
(self, checked=False)[source]¶ Slot for handling the signal emitted by clicking on ‘Tree view’ button.
-
_open_view
(self, view_store, supports_multiple_databases)[source]¶ Opens references in a view window.
Parameters: - view_store (dict) – a dictionary where to store the view window
- supports_multiple_databases (bool) – True if the view supports more than one database
-
populate_reference_list
(self, items)[source]¶ Add given list of items to the reference model. If None or an empty list given, the model is cleared.
-
time_pattern_model
¶
A model for time patterns, used by the parameter value editors.
authors: |
|
---|---|
date: | 4.7.2019 |
Module Contents¶
-
class
time_pattern_model.
TimePatternModel
(value)[source]¶ Bases:
indexed_value_table_model.IndexedValueTableModel
A model for time pattern type parameter values.
-
value
¶ a time pattern value
Type: TimePattern
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Inserts new time period - value pairs into the pattern.
New time periods are initialized to empty strings and the corresponding values to zeros.
Parameters: - row (int) – an index where to insert the new data
- count (int) – number of time period - value pairs to insert
- parent (QModelIndex) – an index to a parent model
Returns: True if the operation was successful
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Removes time period - value pairs from the pattern.
-
row
¶ an index where to remove the data
Type: int
-
count
¶ number of time period - value pairs to remove
Type: int
-
parent
¶ an index to a parent model
Type: QModelIndex
Returns: True if the operation was successful -
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Sets a time period or a value in the pattern.
Column index 0 corresponds to the time periods while 1 corresponds to the values.
-
index
¶ an index to the model
Type: QModelIndex
-
value
a new time period or value
Type: str, float
-
role
¶ a role
Type: int
Returns: True if the operation was successful -
-
excel_import_export
¶
Functions to import and export from excel to spine database.
author: |
|
---|---|
date: | 21.8.2018 |
Module Contents¶
-
excel_import_export.
import_xlsx_to_db
(db, filepath)[source]¶ reads excel file in ‘filepath’ and insert into database in mapping ‘db’. Returns two list, one with succesful writes to database, one with errors when trying to write to database.
Parameters: - db (spinedb_api.DatabaseMapping) – database mapping for database to write to
- filepath (str) – str with filepath to excel file to read from
Returns: (Int, List) Returns number of inserted items and a list of error information on all failed writes
-
excel_import_export.
get_objects_and_parameters
(db)[source]¶ Exports all object data from spine database into unstacked list of lists
Parameters: db (spinedb_api.DatabaseMapping) – database mapping for database Returns: (List, List) First list contains parameter data, second one json data
-
excel_import_export.
get_relationships_and_parameters
(db)[source]¶ Exports all relationship data from spine database into unstacked list of lists
Parameters: db (spinedb_api.DatabaseMapping) – database mapping for database Returns: (List, List) First list contains parameter data, second one json data
-
excel_import_export.
unstack_list_of_tuples
(data, headers, key_cols, value_name_col, value_col)[source]¶ Unstacks list of lists or list of tuples and creates a list of namedtuples whit unstacked data (pivoted data)
Parameters: - data (List[List]) – List of lists with data to unstack
- headers (List[str]) – List of header names for data
- key_cols (List[Int]) – List of index for column that are keys, columns to not unstack
- value_name_col (Int) – index to column containing name of data to unstack
- value_col (Int) – index to column containing value to value_name_col
Returns: List of list with headers in headers list (List): List of header names for each item in inner list
Return type: (List[List])
-
excel_import_export.
stack_list_of_tuples
(data, headers, key_cols, value_cols)[source]¶ Stacks list of lists or list of tuples and creates a list of namedtuples with stacked data (unpivoted data)
Parameters: - data (List[List]) – List of lists with data to unstack
- headers (List[str]) – List of header names for data
- key_cols (List[Int]) – List of index for columns that are keys
- value_cols (List[Int]) – List of index for columns containing values to stack
Returns: List of namedtuples whit fields given by headers and ‘parameter’ and ‘value’ which contains stacked values
Return type: (List[namedtuple])
-
excel_import_export.
get_unstacked_relationships
(db)[source]¶ Gets all data for relationships in a unstacked list of list
Parameters: db (spinedb_api.DatabaseMapping) – database mapping for database Returns: Two list of data for relationship, one with parameter values and the second one with json values Return type: (List, List)
-
excel_import_export.
get_unstacked_objects
(db)[source]¶ Gets all data for objects in a unstacked list of list
Parameters: db (spinedb_api.DatabaseMapping) – database mapping for database Returns: Two list of data for objects, one with parameter values and the second one with json values Return type: (List, List)
-
excel_import_export.
write_relationships_to_xlsx
(wb, relationship_data)[source]¶ Writes Classes, parameter and parameter values for relationships. Writes one sheet per relationship class.
Parameters: - wb (openpyxl.Workbook) – excel workbook to write too.
- relationship_data (List[List]) – List of lists containing relationship
- give by function get_unstacked_relationships (data) –
-
excel_import_export.
write_json_array_to_xlsx
(wb, data, sheet_type)[source]¶ Writes json array data for object classes and relationship classes. Writes one sheet per relationship/object class.
Parameters: - wb (openpyxl.Workbook) – excel workbook to write too.
- data (List[List]) – List of lists containing json data give by function
- and get_unstacked_relationships (get_unstacked_objects) –
- sheet_type (str) – str with value “relationship” or “object” telling if data is for a relationship or object
-
excel_import_export.
write_TimeSeries_to_xlsx
(wb, data, sheet_type, data_type)[source]¶ Writes spinedb_api TimeSeries data for object classes and relationship classes. Writes one sheet per relationship/object class.
Parameters: - wb (openpyxl.Workbook) – excel workbook to write too.
- data (List[List]) – List of lists containing json data give by function
- and get_unstacked_relationships (get_unstacked_objects) –
- sheet_type (str) – str with value “relationship” or “object” telling if data is for a relationship or object
-
excel_import_export.
write_objects_to_xlsx
(wb, object_data)[source]¶ Writes Classes, parameter and parameter values for objects. Writes one sheet per relationship/object class.
Parameters: - wb (openpyxl.Workbook) – excel workbook to write too.
- object_data (List[List]) – List of lists containing relationship data give by function get_unstacked_objects
-
excel_import_export.
export_spine_database_to_xlsx
(db, filepath)[source]¶ Writes all data in a spine database into an excel file.
Parameters: - db (spinedb_api.DatabaseMapping) – database mapping for database.
- filepath (str) – str with filepath to save excel file to.
-
excel_import_export.
read_spine_xlsx
(filepath)[source]¶ reads all data from a excel file where the sheets are in valid spine data format
Parameters: filepath (str) – str with filepath to excel file to read from.
-
excel_import_export.
merge_spine_xlsx_data
(data)[source]¶ Merge data from different sheets with same object class or relationship class.
Parameters: data (List(SheetData)) – list of SheetData Returns: List of SheetData with only one relationship/object class per item Return type: (List[SheetData])
-
excel_import_export.
validate_sheet
(ws)[source]¶ Checks if supplied sheet is a valid import sheet for spine.
Parameters: ws (openpyxl.workbook.worksheet) – worksheet to validate Returns: True if sheet is valid, False otherwise Return type: (bool)
-
excel_import_export.
read_json_sheet
(ws, sheet_type)[source]¶ Reads a sheet containg json array data for objects and relationships
Parameters: - ws (openpyxl.workbook.worksheet) – worksheet to read from
- sheet_type (str) – str with value “relationship” or “object” telling if sheet is a relationship or object sheet
Returns: (List[SheetData])
-
excel_import_export.
read_TimeSeries_sheet
(ws, sheet_type)[source]¶ Reads a sheet containg json array data for objects and relationships
Parameters: - ws (openpyxl.workbook.worksheet) – worksheet to read from
- sheet_type (str) – str with value “relationship” or “object” telling if sheet is a relationship or object sheet
Returns: (List[SheetData])
-
excel_import_export.
read_parameter_sheet
(ws)[source]¶ Reads a sheet containg parameter data for objects and relationships
Parameters: ws (openpyxl.workbook.worksheet) – worksheet to read from Returns: (List[SheetData])
-
excel_import_export.
read_2d
(ws, start_row=1, end_row=1, start_col=1, end_col=1)[source]¶ Reads a 2d area from worksheet into a list of lists where each line is the inner list.
Parameters: - ws (openpyxl.workbook.worksheet) – Worksheet to look in
- start_row (Integer) – start row to read, 1-indexed (as excel)
- end_row (Integer) – row to read to, 1-indexed (as excel)
- start_col (Integer) – start column to read, 1-indexed (as excel)
- end_col (Integer) – end column to read to, 1-indexed (as excel)
Returns: (List) List of all lines read.
-
excel_import_export.
max_col_in_row
(ws, row=1)[source]¶ Finds max col index for given row. If no data exists on row, returns 1.
Parameters: - ws (openpyxl.workbook.worksheet) – Worksheet to look in
- row (Integer) – index for row to search, 1-indexed (as excel)
Returns: (Integer) column index of last cell with value.
spine_io
¶
Init file for spine_io package. Intentionally empty.
author: |
|
---|---|
date: | 1.6.2019 |
Subpackages¶
spine_io.importers
¶
Intentionally empty.
author: |
|
---|---|
date: | 1.6.2019 |
Submodules¶
spine_io.importers.csv_reader
¶Contains CSVConnector class and a help function.
author: |
|
---|---|
date: | 1.6.2019 |
-
spine_io.importers.csv_reader.
select_csv_file
(parent=None)[source]¶ Launches QFileDialog with no filter
-
class
spine_io.importers.csv_reader.
CSVConnector
[source]¶ Bases:
spine_io.io_api.SourceConnection
Template class to read data from another QThread
-
get_tables
(self)[source]¶ Method that should return a list of table names, list(str)
Raises: NotImplementedError
– [description]
-
static
parse_options
(options)[source]¶ Parses options dict to dialect and quotechar options for csv.reader
Parameters: {dict} -- dict with options (options) – “delimiter”: file delimiter “quotechar”: file quotechar “has_header”: if first row should be treated as a header “skip”: how many rows should be skipped Returns: - tuple(dict, bool, integer) – tuple dialect for csv.reader,
- quotechar for csv.reader and number of rows to skip
-
file_iterator
(self, options, max_rows)[source]¶ creates an iterator that reads max_rows number of rows from text file
Parameters: - {dict} -- dict with options (options) –
- {integer} -- max number of rows to read, if -1 then read all rows (max_rows) –
Returns: iterator – iterator of csv file
-
get_data_iterator
(self, table, options, max_rows=-1)[source]¶ Creates a iterator for the file in self.filename
Parameters: - {string} -- ignored, used in abstract IOWorker class (table) –
- {dict} -- dict with options (options) –
Keyword Arguments: {int} -- how many rows of data to read, if -1 read all rows (default (max_rows) – {-1})
Returns: [type] – [description]
-
spine_io.importers.excel_reader
¶Contains ExcelConnector class and a help function.
author: |
|
---|---|
date: | 1.6.2019 |
-
spine_io.importers.excel_reader.
select_excel_file
(parent=None)[source]¶ Launches QFileDialog with .xlsx and friends filter
-
class
spine_io.importers.excel_reader.
ExcelConnector
[source]¶ Bases:
spine_io.io_api.SourceConnection
Template class to read data from another QThread
spine_io.importers.gdx_connector
¶Contains GDXConnector class and a help function.
author: |
|
---|---|
date: | 1.6.2019 |
-
spine_io.importers.gdx_connector.
select_gdx_file
(parent=None)[source]¶ Launches QFileDialog with .gdx filter
-
class
spine_io.importers.gdx_connector.
GdxConnector
[source]¶ Bases:
spine_io.io_api.SourceConnection
Template class to read data from another QThread
-
get_tables
(self)[source]¶ Method that should return a list of table names, list(str)
Raises: NotImplementedError
– [description]
-
get_data_iterator
(self, table, options, max_rows=-1)[source]¶ Creates a iterator for the file in self.filename
Parameters: - {string} -- ignored, used in abstract IOWorker class (table) –
- {dict} -- dict with options (options) –
Keyword Arguments: {int} -- how many rows of data to read, if -1 read all rows (default (max_rows) – {-1})
Returns: [type] – [description]
-
spine_io.importers.odbc_reader
¶Contains ODBCConnector class.
author: |
|
---|---|
date: | 1.6.2019 |
spine_io.importers.sqlalchemy_connector
¶Contains SqlAlchemyConnector class and a help function.
author: |
|
---|---|
date: | 1.6.2019 |
-
spine_io.importers.sqlalchemy_connector.
select_sa_conn_string
(parent=None)[source]¶ Launches QInputDialog for entering connection string
-
class
spine_io.importers.sqlalchemy_connector.
SqlAlchemyConnector
[source]¶ Bases:
spine_io.io_api.SourceConnection
Template class to read data from another QThread.
-
get_tables
(self)[source]¶ Method that should return a list of table names, list(str)
Raises: NotImplementedError
– [description]
-
get_data_iterator
(self, table, options, max_rows=-1)[source]¶ Creates a iterator for the file in self.filename
Parameters: - {string} -- table name (table) –
- {dict} -- dict with options, not used (options) –
Keyword Arguments: {int} -- how many rows of data to read, if -1 read all rows (default (max_rows) – {-1})
Returns: [type] – [description]
-
Submodules¶
spine_io.connection_manager
¶
Contains ConnectionManager class.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
spine_io.connection_manager.
ConnectionManager
(connection, parent=None)[source]¶ Bases:
PySide2.QtCore.QObject
Class to manage data connections in another thread.
Parameters: connection (class) – A class derived from SourceConnection, e.g. CSVConnector -
set_table
(self, table)[source]¶ Sets the current table of the data source.
Parameters: {str} -- str with table name (table) –
-
request_tables
(self)[source]¶ Get tables tables from source, emits two singals, fetchingData: ConnectionManager is busy waiting for data startTableGet: a signal that the worker in another thread is listening to know when to run get a list of table names.
-
request_data
(self, table=None, max_rows=-1)[source]¶ Request data from emits dataReady to with data
Keyword Arguments: - {str} -- which table to get data from (default (table) – {None})
- {int} -- how many rows to read (default (max_rows) – {-1})
-
request_mapped_data
(self, table_mappings, max_rows=-1)[source]¶ Get mapped data from csv file
Parameters: {dict} -- dict with filename as key and a list of mappings as value (table_mappings) – Keyword Arguments: {int} -- number of rows to read, if -1 read all rows (default (max_rows) – {-1})
-
connection_ui
(self)[source]¶ launches a modal ui that prompts the user to select source.
ex: fileselect if source is a file.
-
init_connection
(self)[source]¶ Creates a Worker and a new thread to read source data. If there is an existing thread close that one.
-
-
class
spine_io.connection_manager.
ConnectionWorker
(source, connection, parent=None)[source]¶ Bases:
PySide2.QtCore.QObject
A class for delegating SourceConnection operations to another QThread.
Parameters: - source (str) – path of the source file
- connection (class) – A class derived from SourceConnection for connecting to the source file
spine_io.io_api
¶
Contains a class template for a data source connector used in import ui.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
spine_io.io_api.
SourceConnection
[source]¶ Template class to read data from another QThread
-
connect_to_source
(self, source)[source]¶ Connects to source, ex: connecting to a database where source is a connection string.
Parameters: {} -- object with information on source to be connected to, ex (source) – filepath string for a csv connection
-
get_tables
(self)[source]¶ Method that should return a list of table names, list(str)
Raises: NotImplementedError
– [description]
-
get_data_iterator
(self, table, options, max_rows=-1)[source]¶ Function that should return a data iterator, data header and number of columns.
-
spine_io.io_models
¶
Classes for handling models in PySide2’s model/view framework.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
spine_io.io_models.
MappingPreviewModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model for highlighting columns, rows, and so on, depending on Mapping specification. Used by ImportPreviewWidget.
-
set_mapping
(self, mapping)[source]¶ Set mapping to display colors from
Parameters: {MappingSpecModel} -- mapping model (mapping) –
-
data_color
(self, index)[source]¶ returns background color for index depending on mapping
Parameters: {PySide2.QtCore.QModelIndex} -- index (index) – Returns: [QColor] – QColor of index
-
-
class
spine_io.io_models.
MappingSpecModel
(model, parent=None)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
A model to hold a Mapping specification.
widgets
¶
Init file for widgets package. Intentionally empty.
author: |
|
---|---|
date: | 3.1.2018 |
Submodules¶
widgets.about_widget
¶
A widget for presenting basic information about the application.
author: |
|
---|---|
date: | 14.12.2017 |
Module Contents¶
-
class
widgets.about_widget.
AboutWidget
(toolbox, version)[source]¶ Bases:
PySide2.QtWidgets.QWidget
About widget class.
-
version
¶ Application version number
Type: str
-
calc_pos
(self)[source]¶ Calculate the top-left corner position of this widget in relation to main window position and size in order to show about window in the middle of the main window.
-
keyPressEvent
(self, e)[source]¶ Close form when Escape, Enter, Return, or Space bar keys are pressed.
Parameters: e (QKeyEvent) – Received key press event.
-
closeEvent
(self, event=None)[source]¶ Handle close window.
Parameters: event (QEvent) – Closing event if ‘X’ is clicked.
-
mousePressEvent
(self, e)[source]¶ Save mouse position at the start of dragging.
Parameters: e (QMouseEvent) – Mouse event
-
widgets.add_data_connection_widget
¶
Widget shown to user when a new Data Connection is created.
author: |
|
---|---|
date: | 19.1.2017 |
Module Contents¶
-
class
widgets.add_data_connection_widget.
AddDataConnectionWidget
(toolbox, x, y)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget that queries user’s preferences for a new item.
-
x
¶ X coordinate of new item
Type: int
-
y
¶ Y coordinate of new item
Type: int
-
widgets.add_data_interface_widget
¶
Contains the UI and the functionality for the widget that is shown to user when a new Data Interface is created.
author: |
|
---|---|
date: | 13.6.2019 |
Module Contents¶
-
class
widgets.add_data_interface_widget.
AddDataInterfaceWidget
(toolbox, x, y)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget that queries user’s preferences for a new item.
-
x
¶ X coordinate of new item
Type: int
-
y
¶ Y coordinate of new item
Type: int
-
widgets.add_data_store_widget
¶
Widget shown to user when a new Data Store is created.
author: |
|
---|---|
date: | 19.1.2017 |
Module Contents¶
-
class
widgets.add_data_store_widget.
AddDataStoreWidget
(toolbox, x, y)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget that queries user’s preferences for a new item.
-
x
¶ X coordinate of new item
Type: int
-
y
¶ Y coordinate of new item
Type: int
-
widgets.add_tool_widget
¶
Widget shown to user when a new Tool is created.
author: |
|
---|---|
date: | 19.1.2017 |
Module Contents¶
-
class
widgets.add_tool_widget.
AddToolWidget
(toolbox, x, y)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget that queries user’s preferences for a new item.
-
x
¶ X coordinate of new item
Type: int
-
y
¶ Y coordinate of new item
Type: int
-
update_args
(self, row)[source]¶ Show Tool template command line arguments in text input.
Parameters: row (int) – Selected row number
-
widgets.add_view_widget
¶
Widget shown to user when a new View is created.
author: |
|
---|---|
date: | 19.1.2017 |
Module Contents¶
-
class
widgets.add_view_widget.
AddViewWidget
(toolbox, x, y)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget to query user’s preferences for a new item.
-
x
¶ X coordinate of new item
Type: int
-
y
¶ Y coordinate of new item
Type: int
-
widgets.custom_delegates
¶
Custom item delegates.
author: |
|
---|---|
date: | 1.9.2018 |
Module Contents¶
-
class
widgets.custom_delegates.
ComboBoxDelegate
(parent, choices)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
-
class
widgets.custom_delegates.
LineEditDelegate
[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A delegate that places a fully functioning QLineEdit.
-
parent
¶ either data store or spine datapackage widget
Type: QMainWindow
-
-
class
widgets.custom_delegates.
CheckBoxDelegate
(parent, centered=True)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A delegate that places a fully functioning QCheckBox.
-
parent
¶ either toolbox or spine datapackage widget
Type: QMainWindow
-
centered
¶ whether or not the checkbox should be center-aligned in the widget
Type: bool
-
createEditor
(self, parent, option, index)[source]¶ Important, otherwise an editor is created if the user clicks in this cell. ** Need to hook up a signal to the model.
-
editorEvent
(self, event, model, option, index)[source]¶ Change the data in the model and the state of the checkbox when user presses left mouse button and this cell is editable. Otherwise do nothing.
-
-
class
widgets.custom_delegates.
ParameterDelegate
(parent)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A custom delegate for the parameter models and views in TreeViewForm.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
-
class
widgets.custom_delegates.
ObjectParameterValueDelegate
[source]¶ Bases:
widgets.custom_delegates.ParameterDelegate
A delegate for the object parameter value model and view in TreeViewForm.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
-
class
widgets.custom_delegates.
ObjectParameterDefinitionDelegate
[source]¶ Bases:
widgets.custom_delegates.ParameterDelegate
A delegate for the object parameter definition model and view in TreeViewForm.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
-
class
widgets.custom_delegates.
RelationshipParameterValueDelegate
[source]¶ Bases:
widgets.custom_delegates.ParameterDelegate
A delegate for the relationship parameter value model and view in TreeViewForm.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
-
class
widgets.custom_delegates.
RelationshipParameterDefinitionDelegate
[source]¶ Bases:
widgets.custom_delegates.ParameterDelegate
A delegate for the object parameter definition model and view in TreeViewForm.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
-
class
widgets.custom_delegates.
ManageItemsDelegate
(parent)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A custom delegate for the model in {Add/Edit}ItemDialogs.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ManageObjectClassesDelegate
(parent)[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in {Add/Edit}ObjectClassesDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ManageObjectsDelegate
[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in {Add/Edit}ObjectsDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ManageRelationshipClassesDelegate
[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in {Add/Edit}RelationshipClassesDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ManageRelationshipsDelegate
[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in {Add/Edit}RelationshipsDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
RemoveTreeItemsDelegate
[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in RemoveTreeItemsDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ManageParameterTagsDelegate
[source]¶ Bases:
widgets.custom_delegates.ManageItemsDelegate
A delegate for the model and view in ManageParameterTagsDialog.
-
parent
¶ parent dialog
Type: ManageItemsDialog
-
-
class
widgets.custom_delegates.
ForeignKeysDelegate
(parent)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A QComboBox delegate with checkboxes.
-
parent
¶ spine datapackage widget
Type: SpineDatapackageWidget
-
widgets.custom_editors
¶
Custom editors for model/view programming.
author: |
|
---|---|
date: | 2.9.2018 |
Module Contents¶
-
class
widgets.custom_editors.
CustomLineEditor
[source]¶ Bases:
PySide2.QtWidgets.QLineEdit
A custom QLineEdit to handle data from models.
-
parent
¶ the widget that wants to edit the data
Type: QWidget
-
-
class
widgets.custom_editors.
CustomComboEditor
[source]¶ Bases:
PySide2.QtWidgets.QComboBox
A custom QComboBox to handle data from models.
-
parent
¶ the widget that wants to edit the data
Type: QWidget
-
-
class
widgets.custom_editors.
CustomLineEditDelegate
(parent)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A delegate for placing a CustomLineEditor on the first row of SearchBarEditor.
-
parent
¶ search bar editor
Type: SearchBarEditor
-
-
class
widgets.custom_editors.
SearchBarEditor
(parent, elder_sibling=None, is_json=False)[source]¶ Bases:
PySide2.QtWidgets.QTableView
A Google-like search bar, implemented as a QTableView with a CustomLineEditDelegate in the first row.
-
parent
¶ the parent for this widget
Type: QWidget
-
elder_sibling
¶ another widget which is used to find this widget’s position.
Type: QWidget or NoneType
-
update_geometry
(self)[source]¶ Update geometry. Resize the widget to optimal size, then adjust its position.
-
_proxy_model_filter_accepts_row
(self, source_row, source_parent)[source]¶ Overridden method to always accept first row.
-
-
class
widgets.custom_editors.
SearchBarDelegate
(parent)[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A custom delegate to place a SearchBarEditor on each cell of a MultiSearchBarEditor.
-
parent
¶ multi search bar editor
Type: MultiSearchBarEditor
-
-
class
widgets.custom_editors.
MultiSearchBarEditor
(parent, elder_sibling=None)[source]¶ Bases:
PySide2.QtWidgets.QTableView
A table view made of several Google-like search bars.
-
class
widgets.custom_editors.
CheckListEditor
(parent, elder_sibling=None)[source]¶ Bases:
PySide2.QtWidgets.QTableView
A check list editor.
-
class
widgets.custom_editors.
JSONEditor
(parent, elder_sibling, popup=False)[source]¶ Bases:
PySide2.QtWidgets.QTabWidget
A double JSON editor, featuring: - A QTextEdit for editing arbitrary json. - A QTableView for editing json array.
-
_view_key_press_event
(self, event)[source]¶ Accept key events on the view to avoid weird behaviour, when trying to navigate outside of its limits.
-
eventFilter
(self, widget, event)[source]¶ Intercept events to text_edit and table_view to enable consistent behavior.
-
check_focus
(self)[source]¶ Called when either the text edit or the table view lose focus. Check if the focus is still on this widget (which would mean it was a tab change) otherwise emit signal so this is closed.
-
_handle_current_changed
(self, index)[source]¶ Update json data on text edit or table view, and set focus.
-
-
class
widgets.custom_editors.
IconPainterDelegate
[source]¶ Bases:
PySide2.QtWidgets.QItemDelegate
A delegate to highlight decorations in a QListWidget.
-
class
widgets.custom_editors.
IconColorEditor
(parent)[source]¶ Bases:
PySide2.QtWidgets.QDialog
An editor to let the user select an icon and a color for an object class.
widgets.custom_qdialog
¶
Classes for custom QDialogs to add and edit database items.
author: |
|
---|---|
date: | 13.5.2018 |
Module Contents¶
-
class
widgets.custom_qdialog.
ManageItemsDialog
(parent)[source]¶ Bases:
PySide2.QtWidgets.QDialog
A dialog with a CopyPasteTableView and a QDialogButtonBox, to be extended into dialogs to query user’s preferences for adding/editing/managing data items
-
parent
¶ data store widget
Type: TreeViewForm
-
-
class
widgets.custom_qdialog.
GetObjectClassesMixin
[source]¶ Provides a method to retrieve object classes for AddObjectsDialog and AddRelationshipClassesDialog.
-
class
widgets.custom_qdialog.
GetObjectsMixin
[source]¶ Provides a method to retrieve objects for AddRelationshipsDialog and EditRelationshipsDialog.
-
class
widgets.custom_qdialog.
ShowIconColorEditorMixin
[source]¶ Provides methods to show an IconColorEditor upon request.
-
class
widgets.custom_qdialog.
AddObjectClassesDialog
(parent)[source]¶ Bases:
widgets.custom_qdialog.AddItemsDialog
,widgets.custom_qdialog.ShowIconColorEditorMixin
A dialog to query user’s preferences for new object classes.
-
parent
¶ data store widget
Type: DataStoreForm
-
-
class
widgets.custom_qdialog.
AddObjectsDialog
(parent, class_name=None, force_default=False)[source]¶ Bases:
widgets.custom_qdialog.AddItemsDialog
,widgets.custom_qdialog.GetObjectClassesMixin
A dialog to query user’s preferences for new objects.
-
parent
¶ data store widget
Type: DataStoreForm
-
class_name
¶ default object class name
Type: str
-
force_default
¶ if True, defaults are non-editable
Type: bool
-
-
class
widgets.custom_qdialog.
AddRelationshipClassesDialog
(parent, object_class_one_name=None, force_default=False)[source]¶ Bases:
widgets.custom_qdialog.AddItemsDialog
,widgets.custom_qdialog.GetObjectClassesMixin
A dialog to query user’s preferences for new relationship classes.
-
parent
¶ data store widget
Type: DataStoreForm
-
object_class_one_name
¶ default object class name to put in first dimension
Type: str
-
force_default
¶ if True, defaults are non-editable
Type: bool
-
-
class
widgets.custom_qdialog.
AddRelationshipsDialog
(parent, relationship_class_key=None, object_class_name=None, object_name=None, force_default=False)[source]¶ Bases:
widgets.custom_qdialog.AddItemsDialog
,widgets.custom_qdialog.GetObjectsMixin
A dialog to query user’s preferences for new relationships.
-
parent
¶ data store widget
Type: DataStoreForm
-
relationship_class_key
¶ (class_name, object_class_name_list) for identifying the relationship class
Type: tuple
-
object_name
¶ default object name
Type: str
-
object_class_name
¶ default object class name
Type: str
-
force_default
¶ if True, defaults are non-editable
Type: bool
-
call_reset_model
(self, text)[source]¶ Called when relationship class’s combobox’s index changes. Update relationship_class attribute accordingly and reset model.
-
-
class
widgets.custom_qdialog.
EditObjectClassesDialog
(parent, db_map_dicts)[source]¶ Bases:
widgets.custom_qdialog.EditOrRemoveItemsDialog
,widgets.custom_qdialog.ShowIconColorEditorMixin
A dialog to query user’s preferences for updating object classes.
-
parent
¶ data store widget
Type: DataStoreForm
-
db_map_dicts
¶ list of dictionaries mapping dbs to object classes for editing
Type: list
-
-
class
widgets.custom_qdialog.
EditObjectsDialog
(parent, db_map_dicts)[source]¶ Bases:
widgets.custom_qdialog.EditOrRemoveItemsDialog
A dialog to query user’s preferences for updating objects.
-
parent
¶ data store widget
Type: DataStoreForm
-
db_map_dicts
¶ list of dictionaries mapping dbs to objects for editing
Type: list
-
-
class
widgets.custom_qdialog.
EditRelationshipClassesDialog
(parent, db_map_dicts)[source]¶ Bases:
widgets.custom_qdialog.EditOrRemoveItemsDialog
A dialog to query user’s preferences for updating relationship classes.
-
parent
¶ data store widget
Type: DataStoreForm
-
db_map_dicts
¶ list of dictionaries mapping dbs to relationship classes for editing
Type: list
-
-
class
widgets.custom_qdialog.
EditRelationshipsDialog
(parent, db_map_dicts, ref_class_key)[source]¶ Bases:
widgets.custom_qdialog.EditOrRemoveItemsDialog
,widgets.custom_qdialog.GetObjectsMixin
A dialog to query user’s preferences for updating relationships.
-
parent
¶ data store widget
Type: DataStoreForm
-
db_map_dicts
¶ list of dictionaries mapping dbs to relationships for editing
Type: list
-
ref_class_key
¶ (class_name, object_class_name_list) for identifying the relationship class
Type: tuple
-
-
class
widgets.custom_qdialog.
RemoveTreeItemsDialog
(parent, **kwargs)[source]¶ Bases:
widgets.custom_qdialog.EditOrRemoveItemsDialog
A dialog to query user’s preferences for removing tree items.
-
parent
¶ data store widget
Type: TreeViewForm
-
-
class
widgets.custom_qdialog.
ManageParameterTagsDialog
(parent)[source]¶ Bases:
widgets.custom_qdialog.ManageItemsDialog
A dialog to query user’s preferences for managing parameter tags.
-
parent
¶ data store widget
Type: TreeViewForm
-
-
class
widgets.custom_qdialog.
CommitDialog
(parent, *db_names)[source]¶ Bases:
PySide2.QtWidgets.QDialog
A dialog to query user’s preferences for new commit.
-
parent
¶ data store widget
Type: TreeViewForm
-
db_names
¶ database names
Type: Iterable
-
widgets.custom_qgraphicsscene
¶
Custom QGraphicsScene used in the Design View.
author: |
|
---|---|
date: | 13.2.2019 |
Module Contents¶
-
class
widgets.custom_qgraphicsscene.
CustomQGraphicsScene
(parent, toolbox)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsScene
A scene that handles drag and drop events of DraggableWidget sources.
-
resize_scene
(self)[source]¶ Resize scene to be at least the size of items bounding rectangle. Does not let the scene shrink.
-
set_bg_color
(self, color)[source]¶ Change background color when this is changed in Settings.
Parameters: color (QColor) – Background color
-
set_bg_grid
(self, bg)[source]¶ Enable or disable background grid.
Parameters: bg (boolean) – True to draw grid, False to fill background with a solid color
-
dragEnterEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not a DraggableWidget (from Add Item toolbar).
-
dragMoveEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not a DraggableWidget (from Add Item toolbar).
-
widgets.custom_qgraphicsviews
¶
Classes for custom QGraphicsViews for the Design and Graph views.
authors: |
|
---|---|
date: | 6.2.2018 |
Module Contents¶
-
class
widgets.custom_qgraphicsviews.
CustomQGraphicsView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsView
Super class for Design and Graph QGraphicsViews.
-
parent
¶ Parent widget
Type: QWidget
-
keyPressEvent
(self, event)[source]¶ Overridden method. Enable zooming with plus and minus keys (comma resets zoom). Send event downstream to QGraphicsItems if pressed key is not handled here.
Parameters: event (QKeyEvent) – Pressed key
-
enterEvent
(self, event)[source]¶ Overridden method. Do not show the stupid open hand mouse cursor.
Parameters: event (QEvent) – event
-
mousePressEvent
(self, event)[source]¶ Set rubber band selection mode if Control pressed. Enable resetting the zoom factor from the middle mouse button.
-
resizeEvent
(self, event)[source]¶ Updates zoom if needed when the view is resized.
Parameters: event (QResizeEvent) – a resize event
-
setScene
(self, scene)[source]¶ Sets a new scene to this view.
Parameters: scene (QGraphicsScene) – a new scene
-
-
class
widgets.custom_qgraphicsviews.
DesignQGraphicsView
(parent)[source]¶ Bases:
widgets.custom_qgraphicsviews.CustomQGraphicsView
QGraphicsView for the Design View.
-
parent
¶ Graph View Form’s (QMainWindow) central widget (self.centralwidget)
Type: QWidget
-
mousePressEvent
(self, event)[source]¶ Manage drawing of links. Handle the case where a link is being drawn and the user doesn’t hit a connector button.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
mouseMoveEvent
(self, event)[source]¶ Update line end position.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
init_scene
(self, empty=False)[source]¶ Resize scene and add a link drawer on scene. The scene must be cleared before calling this.
Parameters: empty (boolean) – True when creating a new project
-
add_link
(self, src_connector, dst_connector, index)[source]¶ Draws link between source and sink items on scene and appends connection model. Refreshes View references if needed.
Parameters: - src_connector (ConnectorButton) – Source connector button
- dst_connector (ConnectorButton) – Destination connector button
- index (QModelIndex) – Index in connection model
-
remove_link
(self, index)[source]¶ Removes link between source and sink items on scene and updates connection model. Refreshes View references if needed.
-
take_link
(self, index)[source]¶ Remove link, then start drawing another one from the same source connector.
-
restore_links
(self)[source]¶ Iterates connection model and draws links for each valid entry. Should be called only when a project is loaded from a save file.
-
connection_rows_removed
(self, index, first, last)[source]¶ Update view when connection model changes.
-
connection_columns_removed
(self, index, first, last)[source]¶ Update view when connection model changes.
-
draw_links
(self, connector)[source]¶ Draw links when slot button is clicked.
Parameters: connector (ConnectorButton) – Connector button that triggered the drawing
-
-
class
widgets.custom_qgraphicsviews.
GraphQGraphicsView
(parent)[source]¶ Bases:
widgets.custom_qgraphicsviews.CustomQGraphicsView
QGraphicsView for the Graph View.
-
dragLeaveEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
dragEnterEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
dragMoveEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
widgets.custom_qlineedit
¶
Classes for custom line edits.
author: |
|
---|---|
date: | 11.10.2018 |
widgets.custom_qlistview
¶
Classes for custom QListView.
author: |
|
---|---|
date: | 14.11.2018 |
widgets.custom_qtableview
¶
Custom QTableView classes that support copy-paste and the like.
author: |
|
---|---|
date: | 18.5.2018 |
Module Contents¶
-
class
widgets.custom_qtableview.
CopyPasteTableView
[source]¶ Bases:
PySide2.QtWidgets.QTableView
Custom QTableView class with copy and paste methods.
-
static
_read_pasted_text
(text)[source]¶ Parses a tab separated CSV text table.
Parameters: text (str) – a CSV formatted table Returns: a list of rows
-
static
-
class
widgets.custom_qtableview.
AutoFilterMenu
(parent)[source]¶ Bases:
PySide2.QtWidgets.QMenu
A widget to show the auto filter ‘menu’.
-
parent
¶ the parent widget.
Type: QTableView
-
_proxy_model_filter_accepts_row
(self, source_row, source_parent)[source]¶ Overridden method to always accept first row.
-
-
class
widgets.custom_qtableview.
AutoFilterCopyPasteTableView
(parent)[source]¶ Bases:
widgets.custom_qtableview.CopyPasteTableView
Custom QTableView class with autofilter functionality.
-
parent
¶ The parent of this view
Type: QWidget
-
setModel
(self, model)[source]¶ Disconnect sectionPressed signal, only connect it to show_filter_menu slot. Otherwise the column is selected when pressing on the header.
-
toggle_auto_filter
(self, logical_index)[source]¶ Called when user clicks on a horizontal section header. Show/hide the auto filter widget.
-
update_auto_filter
(self)[source]¶ Called when the user selects Ok in the auto filter menu. Set ‘filtered out values’ in auto filter model.
-
-
class
widgets.custom_qtableview.
FrozenTableView
(parent=None)[source]¶ Bases:
PySide2.QtWidgets.QTableView
-
class
widgets.custom_qtableview.
SimpleCopyPasteTableView
(parent=None)[source]¶ Bases:
PySide2.QtWidgets.QTableView
Custom QTableView class that copies and paste data in response to key press events.
-
parent
¶ The parent of this view
Type: QWidget
-
-
class
widgets.custom_qtableview.
IndexedParameterValueTableViewBase
[source]¶ Bases:
widgets.custom_qtableview.CopyPasteTableView
Custom QTableView base class with copy and paste methods for indexed parameter values.
-
class
widgets.custom_qtableview.
TimeSeriesFixedResolutionTableView
[source]¶ Bases:
widgets.custom_qtableview.IndexedParameterValueTableViewBase
A QTableView for fixed resolution time series table.
-
static
_read_pasted_text
(text)[source]¶ Parses the given CSV table.
Parsing is locale aware.
Parameters: text (str) – a CSV table containing numbers Returns: A list of floats
-
_paste_to_values_column
(self, values, first_row, paste_length)[source]¶ Pastes data to the Values column.
Parameters: - values (list) – a list of float values to paste
- first_row (int) – index of the first row where to paste
- paste_length (int) – length of the paste selection (can be different from len(values))
Returns: A tuple (list(pasted indexes), list(pasted values))
-
static
-
class
widgets.custom_qtableview.
IndexedValueTableView
[source]¶ Bases:
widgets.custom_qtableview.IndexedParameterValueTableViewBase
A QTableView class with for variable resolution time series and time patterns.
-
_paste_two_columns
(self, data_indexes, data_values, first_row, paste_length)[source]¶ Pastes data indexes and values.
Parameters: - data_indexes (list) – a list of data indexes (time stamps/durations)
- data_values (list) – a list of data values
- first_row (int) – first row index
- paste_length (int) – selection length for pasting
Returns: a tuple (modified model indexes, modified model values)
-
_paste_single_column
(self, values, first_row, first_column, paste_length)[source]¶ Pastes a single column of data
Parameters: - values (list) – a list of data to paste (data indexes or values)
- first_row (int) – first row index
- paste_length (int) – selection length for pasting
Returns: a tuple (modified model indexes, modified model values)
-
widgets.custom_qtextbrowser
¶
Class for a custom QTextBrowser for showing the logs and tool output.
author: |
|
---|---|
date: | 6.2.2018 |
Module Contents¶
-
class
widgets.custom_qtextbrowser.
CustomQTextBrowser
(parent)[source]¶ Bases:
PySide2.QtWidgets.QTextBrowser
Custom QTextBrowser class.
-
parent
¶ Parent widget
Type: QWidget
-
widgets.custom_qtreeview
¶
Classes for custom QTreeView.
author: |
|
---|---|
date: | 25.4.2018 |
Module Contents¶
-
class
widgets.custom_qtreeview.
CopyTreeView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QTreeView
Custom QTreeView class with copy support.
-
class
widgets.custom_qtreeview.
ObjectTreeView
(parent)[source]¶ Bases:
widgets.custom_qtreeview.CopyTreeView
Custom QTreeView class for object tree in TreeViewForm.
-
parent
¶ The parent of this view
Type: QWidget
-
-
class
widgets.custom_qtreeview.
ReferencesTreeView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QTreeView
Custom QTreeView class for ‘References’ in Data Connection properties.
-
parent
¶ The parent of this view
Type: QWidget
-
-
class
widgets.custom_qtreeview.
DataTreeView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QTreeView
Custom QTreeView class for ‘Data’ in Data Connection properties.
-
parent
¶ The parent of this view
Type: QWidget
-
-
class
widgets.custom_qtreeview.
SourcesTreeView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QTreeView
Custom QTreeView class for ‘Sources’ in Tool Template form.
-
parent
¶ The parent of this view
Type: QWidget
-
widgets.custom_qwidgets
¶
Custom QWidgets for Filtering and Zooming.
author: |
|
---|---|
date: | 4.12.2018 |
Module Contents¶
-
class
widgets.custom_qwidgets.
FilterWidget
(parent=None, show_empty=True)[source]¶ Bases:
PySide2.QtWidgets.QWidget
Filter widget class.
widgets.data_store_widget
¶
Contains the DataStoreForm class, parent class of TreeViewForm and GraphViewForm.
author: |
|
---|---|
date: | 26.11.2018 |
Module Contents¶
-
class
widgets.data_store_widget.
DataStoreForm
(project, ui, db_maps)[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
A widget to show and edit Spine objects in a data store.
-
project
¶ The project instance that owns this form
Type: SpineToolboxProject
-
ui
¶ UI definition of the form that is initialized
-
db_maps
¶ named DiffDatabaseMapping instances
Type: dict
-
add_message
(self, msg)[source]¶ Append regular message to status bar.
Parameters: msg (str) – String to show in QStatusBar
-
add_error_message
(self, msg)[source]¶ Show error message.
Parameters: msg (str) – String to show in QErrorMessage
Called when a parameter tag button is toggled. Compute selected parameter definition ids per object class ids. Then update set of selected object class ids. Finally, update filter.
-
show_commit_session_dialog
(self, checked=False)[source]¶ Query user for a commit message and commit changes to source database.
-
init_parameter_definition_models
(self)[source]¶ Initialize parameter (definition) models from source database.
-
init_parameter_value_list_model
(self)[source]¶ Initialize parameter value_list models from source database.
-
all_selected_object_class_ids
(self)[source]¶ Return object class ids selected in object tree and parameter tag toolbar.
-
all_selected_relationship_class_ids
(self)[source]¶ Return relationship class ids selected in relationship tree and parameter tag toolbar.
-
set_default_parameter_rows
(self, index=None)[source]¶ Set default rows for parameter models according to selection in object or relationship tree.
-
show_add_object_classes_form
(self, checked=False)[source]¶ Show dialog to let user select preferences for new object classes.
-
show_add_objects_form
(self, checked=False, class_name='')[source]¶ Show dialog to let user select preferences for new objects.
-
show_add_relationship_classes_form
(self, checked=False, object_class_one_name=None)[source]¶ Show dialog to let user select preferences for new relationship class.
-
show_add_relationships_form
(self, checked=False, relationship_class_key=(), object_class_name='', object_name='')[source]¶ Show dialog to let user select preferences for new relationships.
Add parameter tags.
Update parameter tags.
Remove parameter tags.
-
show_parameter_value_editor
(self, index, table_view, value=None)[source]¶ Shows the parameter value editor for the given index of given table view.
-
set_parameter_value_data
(self, index, new_value)[source]¶ Update (object or relationship) parameter value with newly edited data.
-
widgets.datetime_editor
¶
An editor widget for editing datetime database (relationship) parameter values.
author: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
widgets.datetime_editor.
_QDateTime_to_datetime
(dt)[source]¶ Converts a QDateTime object to Python’s datetime.datetime type.
-
widgets.datetime_editor.
_datetime_to_QDateTime
(dt)[source]¶ Converts Python’s datetime.datetime object to QDateTime.
widgets.duration_editor
¶
An editor widget for editing duration database (relationship) parameter values.
author: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
widgets.duration_editor.
_to_text
(value)[source]¶ Converts a Duration object to a string of comma separated time durations.
widgets.graph_view_widget
¶
Contains the TreeViewForm class.
author: |
|
---|---|
date: | 26.11.2018 |
Module Contents¶
-
class
widgets.graph_view_widget.
GraphViewForm
(project, db_maps, read_only=False)[source]¶ Bases:
widgets.data_store_widget.DataStoreForm
A widget to show the graph view.
-
project
¶ The project instance that owns this form
Type: SpineToolboxProject
-
db_maps
¶ named DiffDatabaseMapping instances
Type: dict
-
read_only
¶ Whether or not the form should be editable
Type: bool
-
init_parameter_definition_models
(self)[source]¶ Initialize parameter (definition) models from source database.
-
create_add_more_actions
(self)[source]¶ Create and ‘Add more’ action and button for the Item Palette views.
-
restore_dock_widgets
(self)[source]¶ Dock all floating and or hidden QDockWidgets back to the window at ‘factory’ positions.
-
_handle_zoom_widget_action_hovered
(self)[source]¶ Called when the zoom widget action is hovered. Hide the ‘Dock widgets’ submenu in case it’s being shown. This is the default behavior for hovering ‘normal’ ‘QAction’s, but for some reason it’s not the case for hovering ‘QWidgetAction’s.
Called when a menu from the menubar is about to show.
-
_handle_item_palette_dock_location_changed
(self, area)[source]¶ Called when the item palette dock widget location changes. Adjust splitter orientation accordingly.
-
static
shortest_path_matrix
(object_name_list, src_ind_list, dst_ind_list, spread)[source]¶ Return the shortest-path matrix.
-
static
vertex_coordinates
(matrix, heavy_positions=None, iterations=10, weight_exp=-2, initial_diameter=1000)[source]¶ Return x and y coordinates for each vertex in the graph, computed using VSGD-MS.
-
_handle_scene_changed
(self, region)[source]¶ Handle scene changed. Show usage message if no items other than the bg.
-
relationship_items
(self, object_name_list, object_class_name_list, extent, spread, label_color, object_class_id_list=None, relationship_class_id=None)[source]¶ Lists of object and arc items that form a relationship.
-
add_relationship_template
(self, scene, x, y, object_items, arc_items, dimension_at_origin=None)[source]¶ Add relationship parts into the scene to form a ‘relationship template’.
-
update_object
(self, object_item, name)[source]¶ Try and update object given an object item and a name.
-
add_relationship
(self, template_id, object_items)[source]¶ Try and add relationship given a template id and a list of object items.
Show context menu for graphics view.
Show hidden items.
Show context menu for object_item.
-
widgets.import_errors_widget
¶
Contains ImportErrorWidget class.
author: |
|
---|---|
date: | 1.6.2019 |
widgets.import_preview_widget
¶
Contains ImportPreviewWidget, and MappingTableMenu classes.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
widgets.import_preview_widget.
ImportPreviewWidget
(connector, parent=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A Widget for defining one or more Mappings associated to a data Source (CSV file, Excel file, etc). Currently it’s being embedded in ImportDialog and ImportPreviewWindow.
Parameters: connector (ConnectionManager) –
widgets.import_preview_window
¶
Contains DataInterface class.
authors: |
|
---|---|
date: | 10.6.2019 |
widgets.import_widget
¶
ImportDialog class.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
widgets.import_widget.
ImportDialog
(parent=None)[source]¶ Bases:
PySide2.QtWidgets.QDialog
A widget for importing data into a Spine db. Currently used by TreeViewForm. It embeds three widgets that alternate depending on user’s actions: - select_widget is a QWidget for selecting the source data type (CSV, Excel, etc.) - _import_preview is an ImportPreviewWidget for defining Mappings to associate with the source data - _error_widget is an ImportErrorWidget to show errors from import operations
widgets.julia_repl_widget
¶
Class for a custom RichJupyterWidget to use as julia REPL.
author: |
|
---|---|
date: | 22.5.2018 |
Module Contents¶
-
class
widgets.julia_repl_widget.
CustomQtKernelManager
[source]¶ Bases:
qtconsole.manager.QtKernelManager
A QtKernelManager with a custom restarter, and a means to override the –project argument.
-
class
widgets.julia_repl_widget.
JuliaREPLWidget
(toolbox)[source]¶ Bases:
qtconsole.rich_jupyter_widget.RichJupyterWidget
Class for a custom RichJupyterWidget.
-
julia_kernel_name
(self)[source]¶ Returns the name of the julia kernel specification, according to the selected julia interpreter in settings. Returns None if julia version cannot be determined.
-
start_jupyter_kernel
(self)[source]¶ Start a Julia Jupyter kernel if available.
Returns: True if the kernel is started, or in process of being started (installing/reconfiguring IJulia) False if the kernel cannot be started and the user chooses not to install/reconfigure IJulia
-
start_available_jupyter_kernel
(self)[source]¶ Start a Jupyter kernel which is available (from the attribute kernel_name)
Returns: True if the kernel is started, or in process of being started (reconfiguring IJulia) False if the kernel cannot be started and the user chooses not to reconfigure IJulia
-
check_ijulia
(self)[source]¶ Check if IJulia is installed, returns True, False, or None if unable to determine.
-
handle_repl_failed_to_start
(self)[source]¶ Prompt user to install IJulia if missing, or rebuild it otherwise.
Returns: Boolean value depending on whether or not the problem is being handled.
-
restart_jupyter_kernel
(self)[source]¶ Restart the julia jupyter kernel if it’s already started. Otherwise, or if the julia version has changed in settings, start a new jupyter kernel.
-
_handle_kernel_restarted
(self, died=True)[source]¶ Called when the kernel is restarted, i.e., when time to dead has elapsed.
-
_handle_kernel_left_dead
(self)[source]¶ Called when the kernel is finally declared dead, i.e., the restart limit has been reached.
-
handle_ijulia_installation_finished
(self, ret)[source]¶ Run when IJulia installation process finishes
-
check_ijulia_process
(self, ret)[source]¶ Check whether or not the IJulia process finished successfully
-
_handle_status
(self, msg)[source]¶ Handle status message. If we have a command in line and the kernel reports status ‘idle’, execute that command.
-
execute_instance
(self, command)[source]¶ Try and start the jupyter kernel. Execute command immediately if kernel is idle. If not, it will be executed as soon as the kernel becomes idle (see _handle_status method).
Reimplemented to add an action for (re)start REPL action.
-
widgets.mapping_widget
¶
MappingWidget and MappingOptionsWidget class.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
widgets.mapping_widget.
MappingWidget
(parent=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget for managing Mappings (add, remove, edit, visualize, and so on). Intended to be embeded in a ImportPreviewWidget.
widgets.options_widget
¶
Contains OptionsWidget class.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
widgets.options_widget.
OptionsWidget
(options, header='Options', parent=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget for handling simple options. Used by ConnectionManager.
widgets.parameter_value_editor
¶
An editor dialog for editing database (relationship) parameter values.
author: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
class
widgets.parameter_value_editor.
_Editor
[source]¶ Bases:
enum.Enum
Indexes for the specialized editors corresponding to the selector combo box and editor stack.
-
class
widgets.parameter_value_editor.
ParameterValueEditor
(parent_index, value_name='', value=None, parent_widget=None)[source]¶ Bases:
PySide2.QtWidgets.QDialog
Dialog for editing (relationship) parameter values.
The dialog takes the editable value from a parent model and shows a specialized editor corresponding to the value type in a stack widget. The user can change the value type by changing the specialized editor using a combo box. When the dialog is closed the value from the currently shown specialized editor is written back to the parent model.
-
parent_index
¶ an index to a parameter value in parent_model
Type: QModelIndex
-
value_name
¶ name of the value
Type: str
-
value
¶ parameter value or None if it should be loaded from parent_index
-
parent_widget
¶ a parent widget
Type: QWidget
-
accept
(self)[source]¶ Saves the parameter value shown in the currently selected editor widget back to the parent model.
-
_change_parameter_type
(self, selector_index)[source]¶ Handles switching between value types.
Does a rude conversion between fixed and variable resolution time series. In other cases, a default ‘empty’ value is used.
Parameters: selector_index (int) – an index to the selector combo box
-
widgets.plain_parameter_value_editor
¶
An editor widget for editing plain number database (relationship) parameter values.
author: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
class
widgets.plain_parameter_value_editor.
_ValueModel
(value)[source]¶ A model to handle the parameter value in the editor.
Mostly useful because of the handy conversion of strings to floats or booleans.
-
value
[source] Returns the value held by the model.
-
widgets.plot_canvas
¶
A Qt widget to use as a matplotlib backend.
author: |
|
---|---|
date: | 3.6.2019 |
widgets.plot_widget
¶
A Qt widget showing a toolbar and a matplotlib plotting canvas.
author: |
|
---|---|
date: | 27.6.2019 |
widgets.project_form_widget
¶
Widget shown to user when a new project is created.
authors: |
|
---|---|
date: | 10.1.2018 |
widgets.python_repl_widget
¶
Class for a custom RichJupyterWidget to use as Python REPL.
author: |
|
---|---|
date: | 14.3.2019 |
Module Contents¶
-
class
widgets.python_repl_widget.
PythonReplWidget
(toolbox)[source]¶ Bases:
qtconsole.rich_jupyter_widget.RichJupyterWidget
Python Repl Widget class.
-
disconnect_signals
(self)[source]¶ Disconnect signals. Needed before switching to another Python kernel.
-
python_kernel_name
(self)[source]¶ Returns the name of the Python kernel specification and its display name according to the selected Python environment in Settings. Returns None if Python version cannot be determined.
-
launch_kernel
(self, k_name, k_display_name)[source]¶ Check if selected kernel exists or if it needs to be set up before launching.
-
check_and_install_requirements
(self)[source]¶ Prompts user to install IPython and ipykernel if they are missing. After installing the required packages, installs kernelspecs for the selected Python if they are missing.
Returns: Boolean value depending on whether or not the user chooses to proceed.
-
is_package_installed
(self, package_name)[source]¶ Checks if given package is installed to selected Python environment.
Parameters: package_name (str) – Package name Returns: True if installed, False if not Return type: (bool)
-
start_package_install_process
(self, package_name)[source]¶ Starts installing the given package using pip.
Parameters: package_name (str) – Package name to install using pip
-
package_install_process_finished
(self, retval)[source]¶ Installing package finished.
Parameters: retval (int) – Process return value. 0: success, !0: failure
-
start_kernelspec_install_process
(self)[source]¶ Install kernel specifications for the selected Python environment.
-
kernelspec_install_process_finished
(self, retval)[source]¶ Installing package finished.
Parameters: retval (int) – Process return value. 0: success, !0: failure
-
start_python_kernel
(self)[source]¶ Starts kernel manager and client and attaches the client to the Python Console.
-
execute_instance
(self, commands)[source]¶ Start executing the first command in the command queue in Python Console.
-
execution_in_progress
(self, code)[source]¶ Slot for handling the ‘executing’ signal. Signal is emitted when a user visible ‘execute_request’ has been submitted to the kernel from the FrontendWidget.
Parameters: code (str) – Code to be executed (actually not ‘str’ but ‘object’)
-
execution_done
(self, msg)[source]¶ Slot for handling the ‘executed’ signal. Signal is emitted when a user-visible ‘execute_reply’ has been received from the kernel and processed by the FrontendWidget.
Parameters: msg (dict) – Response message (actually not ‘dict’ but ‘object’)
-
iopub_msg_received
(self, msg)[source]¶ Message received from the IOPUB channel. Note: We are only monitoring when the kernel has started successfully and ready for action here. Alternatively, this could be done in the Slot for the ‘executed’ signal. However, this Slot could come in handy at some point. See ‘Messaging in Jupyter’ for details: https://jupyter-client.readthedocs.io/en/latest/messaging.html
Parameters: msg (dict) – Received message from IOPUB channel
-
push_vars
(self, var_name, var_value)[source]¶ Push a variable to Python Console session. Simply executes command ‘var_name=var_value’.
Parameters: - var_name (str) – Variable name
- var_value (object) – Variable value
Returns: True if succeeded, False otherwise
Return type: (bool)
Reimplemented to add custom actions.
-
widgets.report_plotting_failure
¶
Functions to report failures in plotting to the user.
author: |
|
---|---|
date: | 10.7.2019 |
widgets.settings_widget
¶
Widget for controlling user settings.
author: |
|
---|---|
date: | 17.1.2018 |
Module Contents¶
-
class
widgets.settings_widget.
SettingsWidget
(toolbox)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget to change user’s preferred settings.
-
browse_gams_path
(self, checked=False)[source]¶ Open file browser where user can select a GAMS program.
-
browse_julia_path
(self, checked=False)[source]¶ Open file browser where user can select a Julia executable (i.e. julia.exe on Windows).
-
browse_julia_project_path
(self, checked=False)[source]¶ Open file browser where user can select a Julia project path.
-
browse_python_path
(self, checked=False)[source]¶ Open file browser where user can select a python interpreter (i.e. python.exe on Windows).
-
browse_work_path
(self, checked=False)[source]¶ Open file browser where user can select the path to wanted work directory.
-
show_color_dialog
(self, checked=False)[source]¶ Let user pick the bg color.
Parameters: checked (boolean) – Value emitted with clicked signal
-
update_bg_color
(self)[source]¶ Set tool button icon as the selected color and update Design View scene background color.
-
update_scene_bg
(self, checked)[source]¶ Draw background on scene depending on radiobutton states.
Parameters: checked (boolean) – Toggle state
-
read_settings
(self)[source]¶ Read saved settings from app QSettings instance and update UI to display them.
-
read_project_settings
(self)[source]¶ Read project settings from config object and update settings widgets accordingly.
-
ok_clicked
(self)[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.
-
check_if_python_env_changed
(self, new_path)[source]¶ Checks if Python environment was changed. This indicates that the Python Console may need a restart.
-
file_is_valid
(self, file_path, msgbox_title)[source]¶ Checks that given path is not a directory and it’s a file that actually exists. Needed because the QLineEdits are editable.
-
dir_is_valid
(self, dir_path, msgbox_title)[source]¶ Checks that given path is a directory. Needed because the QLineEdits are editable.
-
keyPressEvent
(self, e)[source]¶ Close settings form when escape key is pressed.
Parameters: e (QKeyEvent) – Received key press event.
-
closeEvent
(self, event=None)[source]¶ Handle close window.
Parameters: event (QEvent) – Closing event if ‘X’ is clicked.
-
mousePressEvent
(self, e)[source]¶ Save mouse position at the start of dragging.
Parameters: e (QMouseEvent) – Mouse event
-
widgets.spine_datapackage_widget
¶
Widget shown to user when opening a ‘datapackage.json’ file in Data Connection item.
author: |
|
---|---|
date: | 7.7.2018 |
Module Contents¶
-
class
widgets.spine_datapackage_widget.
SpineDatapackageWidget
(data_connection)[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
A widget to allow user to edit a datapackage and convert it to a Spine database in SQLite.
-
data_connection
¶ Data Connection associated to this widget
Type: DataConnection
-
show
(self)[source]¶ Called when the form shows. Init datapackage (either from existing datapackage.json or by inferring a new one from sources) and update ui.
-
infer_datapackage
(self, checked=False)[source]¶ Called when the user triggers the infer action. Infer datapackage from sources and update ui.
-
load_datapackage
(self)[source]¶ Load datapackage from ‘datapackage.json’ file in data directory, or infer one from CSV files in that directory.
Called when a menu from the menubar is about to show. Adjust infer action depending on whether or not we have a datapackage. Adjust copy paste actions depending on which widget has the focus. TODO Enable/disable action to save datapackage depending on status.
-
add_message
(self, msg)[source]¶ Prepend regular message to status bar.
Parameters: msg (str) – String to show in QStatusBar
-
add_process_message
(self, msg)[source]¶ Show process message in status bar. This messages stays until replaced.
Parameters: msg (str) – String to show in QStatusBar
-
save_datapackage
(self, checked=False)[source]¶ Write datapackage to file ‘datapackage.json’ in data directory.
-
show_export_to_spine_dialog
(self, checked=False)[source]¶ Show dialog to allow user to select a file to export.
-
reset_resource_models
(self, current, previous)[source]¶ Reset resource data and schema models whenever a new resource is selected.
-
reset_resource_data_model
(self)[source]¶ Reset resource data model with data from newly selected resource.
-
_handle_resource_name_data_committed
(self, index, new_name)[source]¶ Called when line edit delegate wants to edit resource name data. Update resources model and descriptor with new resource name.
-
_handle_field_name_data_committed
(self, index, new_name)[source]¶ Called when line edit delegate wants to edit field name data. Update name in fields_model, resource_data_model’s header and datapackage descriptor.
-
_handle_primary_key_data_committed
(self, index)[source]¶ Called when checkbox delegate wants to edit primary key data. Add or remove primary key field accordingly.
-
_handle_foreign_keys_data_changed
(self, top_left, bottom_right, roles=None)[source]¶ Called when foreign keys data is updated in model. Update descriptor accordingly.
Create button to remove foreign keys row.
-
-
class
widgets.spine_datapackage_widget.
CustomPackage
(descriptor=None, base_path=None, strict=False, storage=None)[source]¶ Bases:
datapackage.Package
Custom datapackage class.
-
set_primary_key
(self, resource, *primary_key)[source]¶ Set primary key for a given resource in the package
-
insert_foreign_key
(self, row, resource_name, field_names, reference_resource_name, reference_field_names)[source]¶ Insert foreign key to a given resource in the package at a given row.
-
remove_primary_key
(self, resource, *primary_key)[source]¶ Remove the primary key for a given resource in the package
-
widgets.tabular_view_widget
¶
Contains TabularViewForm class and some related constants.
author: |
|
---|---|
date: | 1.11.2018 |
Module Contents¶
-
class
widgets.tabular_view_widget.
TabularViewForm
(data_store, db_map, database)[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
A widget to show and edit Spine objects in a data store.
-
db_map
¶ The object relational database mapping
Type: DatabaseMapping
-
database
¶ The database name
Type: str
-
pivot_table_edit
(self, index, trigger, event)[source]¶ Starts editing the item at index from pivot_table. If the index contains some ‘complex’ parameter value, we open the parameter value editor window instead.
Checks if session can commit or rollback and updates session menu actions
-
update_class_list
(self)[source]¶ update list_select_class with all object classes and relationship classes
-
widgets.time_pattern_editor
¶
An editor widget for editing a time pattern type (relationship) parameter values.
author: |
|
---|---|
date: | 28.6.2019 |
widgets.time_series_fixed_resolution_editor
¶
Contains logic for the fixed step time series editor widget.
author: |
|
---|---|
date: | 14.6.2019 |
Module Contents¶
-
widgets.time_series_fixed_resolution_editor.
_resolution_to_text
(resolution)[source]¶ Converts a list of durations into a string of comma-separated durations.
-
widgets.time_series_fixed_resolution_editor.
_text_to_resolution
(text)[source]¶ Converts a comma-separated string of durations into a resolution array.
widgets.time_series_variable_resolution_editor
¶
Contains logic for the variable resolution time series editor widget.
author: |
|
---|---|
date: | 31.5.2019 |
widgets.tool_configuration_assistant_widget
¶
Widget for assisting the user in configuring tools, such as SpineModel.
author: |
|
---|---|
date: | 9.1.2019 |
Module Contents¶
-
class
widgets.tool_configuration_assistant_widget.
ToolConfigurationAssistantWidget
(toolbox, autorun=True)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget to assist the user in configuring external tools such as SpineModel.
-
autorun
¶ whether or not to start configuration process at form load
Type: bool
-
add_spine_model_msg
(self, msg)[source]¶ Append message to SpineModel log.
Parameters: msg (str) – String written to QTextBrowser
-
add_spine_model_error_msg
(self, msg)[source]¶ Append error message to SpineModel log.
Parameters: msg (str) – String written to QTextBrowser
-
add_spine_model_success_msg
(self, msg)[source]¶ Append success message to SpineModel log.
Parameters: msg (str) – String written to QTextBrowser
-
_handle_spine_model_version_check_finished
(self, ret)[source]¶ Run when the Spine Model configuration assistant has finished checking SpineModel version. Install SpineModel if not found, otherwise check the python program used by PyCall.
-
_handle_spine_model_installation_finished
(self, ret)[source]¶ Run when the Spine Model configuration assistant has finished installing SpineModel. Check the python program used by PyCall.
-
_handle_py_call_program_check_finished
(self, ret)[source]¶ Run when the Spine Model configuration assistant has finished checking the python program used by PyCall. Install PyCall if not found, otherwise reconfigure PyCall to use same python as Spine Toolbox if it’s not the case.
-
_handle_py_call_installation_finished
(self, ret)[source]¶ Run when the Spine Model configuration assistant has finished installing PyCall. Check the python program used by PyCall.
-
_handle_py_call_reconfiguration_finished
(self, ret)[source]¶ Run when the Spine Model configuration assistant has finished reconfiguring PyCall. End Spine Model configuration.
-
widgets.tool_template_widget
¶
QWidget that is used to create or edit Tool Templates. In the former case it is presented empty, but in the latter it is filled with all the information from the template being edited.
author: |
|
---|---|
date: | 12.4.2018 |
Module Contents¶
-
class
widgets.tool_template_widget.
ToolTemplateWidget
(toolbox, tool_template=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
A widget to query user’s preferences for a new tool template.
-
tool_template
¶ If given, the form is pre-filled with this template
Type: ToolTemplate
-
populate_sourcefile_list
(self, items)[source]¶ List source files in QTreeView. If items is None or empty list, model is cleared.
-
populate_inputfiles_list
(self, items)[source]¶ List input files in QTreeView. If items is None or empty list, model is cleared.
-
populate_inputfiles_opt_list
(self, items)[source]¶ List optional input files in QTreeView. If items is None or empty list, model is cleared.
-
populate_outputfiles_list
(self, items)[source]¶ List output files in QTreeView. If items is None or empty list, model is cleared.
-
browse_main_program
(self, checked=False)[source]¶ Open file browser where user can select the path of the main program file.
-
new_main_program_file
(self)[source]¶ Create a new blank main program file. Let user decide the file name and location.
-
new_main_program_file
(self)[source] Creates a new blank main program file. Let’s user decide the file name and path. Alternative version using only one getSaveFileName dialog.
-
show_add_source_files_dialog
(self, checked=False)[source]¶ Let user select source files for this tool template.
-
show_add_source_dirs_dialog
(self, checked=False)[source]¶ Let user select a source directory for this tool template. All files and sub-directories will be added to the source files.
-
remove_source_files
(self, checked=False)[source]¶ Remove selected source files from include list. Do not remove anything if there are no items selected.
-
remove_inputfiles
(self, checked=False)[source]¶ Remove selected input files from list. Do not remove anything if there are no items selected.
-
add_inputfiles_opt
(self, checked=False)[source]¶ Let user select optional input files for this tool template.
-
remove_inputfiles_opt
(self, checked=False)[source]¶ Remove selected optional input files from list. Do not remove anything if there are no items selected.
-
remove_outputfiles
(self, checked=False)[source]¶ Remove selected output files from list. Do not remove anything if there are no items selected.
-
ok_clicked
(self)[source]¶ Check that everything is valid, create definition dictionary and add template to project.
-
call_add_tool_template
(self)[source]¶ Add or update Tool Template according to user’s selections. If the name is the same as an existing tool template, it is updated and auto-saved to the definition file. (User is editing an existing tool template.) If the name is not in the tool template model, create a new tool template and offer to save the definition file. (User is creating a new tool template from scratch or spawning from an existing one).
-
widgets.toolbars
¶
Functions to make and handle QToolBars.
author: |
|
---|---|
date: | 19.1.2018 |
Module Contents¶
-
class
widgets.toolbars.
ItemToolBar
(parent)[source]¶ Bases:
PySide2.QtWidgets.QToolBar
A toolbar to add items using drag and drop actions.
-
remove_all
(self, checked=False)[source]¶ Slot for handling the remove all tool button clicked signal. Calls ToolboxUI remove_all_items() method.
-
execute_project
(self, checked=False)[source]¶ Slot for handling the Execute project tool button clicked signal.
-
-
class
widgets.toolbars.
DraggableWidget
(parent, pixmap, text)[source]¶ Bases:
PySide2.QtWidgets.QLabel
A draggable QLabel.
-
parent
¶ Parent widget
Type: QWidget
-
pixmap
¶ Picture for the label
Type: QPixMap
-
text
¶ Item type
Type: str
-
-
class
widgets.toolbars.
ParameterTagToolBar
(parent)[source]¶ Bases:
PySide2.QtWidgets.QToolBar
A toolbar to add items using drag and drop actions.
-
parent
¶ tree or graph view form
Type: DataStoreForm
-
widgets.tree_view_widget
¶
Contains the TreeViewForm class.
author: |
|
---|---|
date: | 26.11.2018 |
Module Contents¶
-
class
widgets.tree_view_widget.
TreeViewForm
(project, db_maps)[source]¶ Bases:
widgets.data_store_widget.DataStoreForm
A widget to show and edit Spine objects in a data store.
-
project
¶ The project instance that owns this form
Type: SpineToolboxProject
-
db_maps
¶ named DiffDatabaseMapping instances
Type: dict
-
restore_dock_widgets
(self)[source]¶ Dock all floating and or hidden QDockWidgets back to the window at ‘factory’ positions.
-
update_copy_and_remove_actions
(self)[source]¶ Update copy and remove actions according to selections across the widgets.
-
_handle_object_parameter_definition_selection_changed
(self, selected, deselected)[source]¶ Enable/disable the option to remove rows.
-
_handle_object_parameter_value_selection_changed
(self, selected, deselected)[source]¶ Enable/disable the option to remove rows.
-
_handle_relationship_parameter_definition_selection_changed
(self, selected, deselected)[source]¶ Enable/disable the option to remove rows.
-
_handle_relationship_parameter_value_selection_changed
(self, selected, deselected)[source]¶ Enable/disable the option to remove rows.
-
_handle_parameter_value_list_selection_changed
(self, selected, deselected)[source]¶ Enable/disable the option to remove rows.
-
show_import_file_dialog
(self, checked=False)[source]¶ Show dialog to allow user to select a file to import.
-
_select_database
(self)[source]¶ Lets user select a database from available databases.
Shows a dialog from which user can select a single database. If there is only a single database it is selected automatically and no dialog is shown.
Returns: the database map of the database or None if no database was selected
-
find_next_leaf
(self, index)[source]¶ If object tree index corresponds to a relationship, then expand the next ocurrence of it.
-
clear_other_selections
(self, *skip_widgets)[source]¶ Clear selections in all widgets except skip_widgets.
-
_handle_object_tree_selection_changed
(self, selected, deselected)[source]¶ Called when the object tree selection changes. Set default rows and apply filters on parameter models.
-
_handle_relationship_tree_selection_changed
(self, selected, deselected)[source]¶ Called when the relationship tree selection changes. Set default rows and apply filters on parameter models.
-
update_filter
(self)[source]¶ Update filters on parameter models according to selected and deselected object tree indexes.
Context menu for object tree.
Parameters: pos (QPoint) – Mouse position
Context menu for relationship tree.
Parameters: pos (QPoint) – Mouse position
-
edit_object_tree_items
(self)[source]¶ Called when F2 is pressed while the object tree has focus. Call the appropriate method to show the edit form, depending on the current index.
-
edit_relationship_tree_items
(self)[source]¶ Called when F2 is pressed while the relationship tree has focus. Call the appropriate method to show the edit form, depending on the current index.
-
show_remove_relationship_tree_items_form
(self)[source]¶ Show form to remove items from relationship treeview.
Context menu for object parameter value table view.
Parameters: pos (QPoint) – Mouse position
Context menu for relationship parameter value table view.
Parameters: pos (QPoint) – Mouse position
Context menu for object parameter table view.
Parameters: pos (QPoint) – Mouse position
Context menu for relationship parameter table view.
Parameters: pos (QPoint) – Mouse position
Show a context menu for parameter tables.
Parameters: - position (QPoint) – local mouse position in the table view
- table_view (QTableView) – the table view where the context menu was triggered
- value_column_header (str) – column header for editable/plottable values
Context menu for relationship parameter table view.
Parameters: pos (QPoint) – Mouse position
-
remove_object_parameter_values
(self)[source]¶ Remove selected rows from object parameter value table.
-
remove_relationship_parameter_values
(self)[source]¶ Remove selected rows from relationship parameter value table.
-
_remove_parameter_values
(self, table_view)[source]¶ Remove selected rows from parameter value table.
Parameters: table_view (QTableView) – a table view from which to remove
-
remove_object_parameter_definitions
(self)[source]¶ Remove selected rows from object parameter definition table.
-
remove_relationship_parameter_definitions
(self)[source]¶ Remove selected rows from relationship parameter definition table.
-
_remove_parameter_definitions
(self, table_view, value_model, class_id_header)[source]¶ Remove selected rows from parameter table.
Parameters: - table_view (QTableView) – the table widget from which to remove
- value_model (QAbstractTableModel) – a value model corresponding to the definition model of table_view
- class_id_header (str) – header of the class id column
-
[1] | Created with sphinx-autoapi |