straditize.widgets.menu_actions module

The main control widget for a straditizer

Disclaimer

Copyright (C) 2018-2019 Philipp S. Sommer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Classes

ExportDfDialog(df, straditizer[, fname])

A QDialog to export a pandas.DataFrame to Excel or CSV

StraditizerMenuActions(straditizer_widgets)

An object to control the main functionality of a Straditizer

class straditize.widgets.menu_actions.ExportDfDialog(df, straditizer, fname=None, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QDialog

A QDialog to export a pandas.DataFrame to Excel or CSV

Parameters

Methods

accept(self)

cancel()

export_df(parent, df, straditizer[, fname, …])

Open a dialog for exporting a DataFrame

get_open_file_name()

Ask the user for a filename for saving the data frame

accept(self)[source]
cancel()[source]
classmethod export_df(parent, df, straditizer, fname=None, exec_=True)[source]

Open a dialog for exporting a DataFrame

Parameters

parent (QWidget) – The parent widget

get_open_file_name()[source]

Ask the user for a filename for saving the data frame

class straditize.widgets.menu_actions.StraditizerMenuActions(straditizer_widgets)[source]

Bases: straditize.widgets.StraditizerControlBase

An object to control the main functionality of a Straditizer

This object is creates menu actions to load the straditizer

Attributes

all_actions

save_actions, data_actions and text_actions

data_actions

The QActions to save the exported DataFrames and data images

save_actions

The QActions to save the straditizer, straditizer image, etc.

text_actions

The QActions to save the column names images

window_layout_action

The action to

Methods

create_sliders(stradi)

Create sliders to navigate in the given axes

export_final([fname])

Export the final results

export_full([fname])

Export the full digitized data

finish_loading(stradi)

Finish the opening of a straditizer

from_clipboard()

Open a straditizer from an Image in the clipboard

import_binary_image([fname])

Import the binary data reader image from an external file

import_data_image([fname])

Import the data reader image from an external file

import_full_image([fname])

Import the straditizer image from an external file

import_text_image(fname)

Import the column names reader image from an external file

open_straditizer([fname])

Open a straditizer from an image or project file

refresh()

Refresh from the straditizer

save_data_image([fname])

Save the binary image of the data reader

save_full_image([fname])

Save the image of the straditizer

save_straditizer()

Save the straditizer to a file

save_straditizer_as([fname])

Save the straditizer to a file

save_text_image([fname])

Save the image of the colnames reader

set_ax_xlim(ax_ref)

Define a function to update xlim from a given centered value

set_ax_ylim(ax_ref)

Define a function to update ylim from a given centered value

set_stradi_in_console()

Set the straditizer in the console of the GUI mainwindow

setup_children(item)

Setup the children for this control

setup_menu_actions(main)

Create the actions for the file menu

setup_shortcuts(main)

Setup the shortcuts when switched to the straditizer layout

stack_zoom_window()

Stack the magnifier image above the help explorer

update_x_navigation_sliders(ax)

Update the horizontal navigation slider for the given ax`

update_y_navigation_sliders(ax)

Update the vertical navigation slider for the given ax`

property all_actions

save_actions, data_actions and text_actions

create_sliders(stradi)[source]

Create sliders to navigate in the given axes

Parameters

stradi (straditize.straditizer.Straditizer) – The straditizer that just has been opened

data_actions = []

The QActions to save the exported DataFrames and data images

export_final(fname=None)[source]

Export the final results

This method exports the straditize.straditizer.Straditizer.final_df of the current straditizer

Parameters

fname (str or None) – The path of the target filename where to save the df (see the ExportDialog.export_df())

export_full(fname=None)[source]

Export the full digitized data

This method exports the straditize.straditizer.Straditizer.full_df of the current straditizer

Parameters

fname (str or None) – The path of the target filename where to save the df (see the ExportDialog.export_df())

finish_loading(stradi)[source]

Finish the opening of a straditizer

This method sets the straditizer.widgets.StraditizerWidgets.straditizer, shows the straditizer image, creates the navigation sliders and sets the straditizer in the console

Parameters

stradi (straditize.straditizer.Straditizer) – The straditizer that just has been opened

from_clipboard()[source]

Open a straditizer from an Image in the clipboard

This method uses the PIL.ImageGrab.grabclipboard() function to open a new straditizer from the clipboard.

import_binary_image(fname=None)[source]

Import the binary data reader image from an external file

This method imports the straditize.binary.DataReader.binary from an external file and sets it to the current data_reader.

Parameters

fname (str, PIL.Image.Image or None) – The path of the image file or the PIL.Image.Image. If None, a QFileDialog is opened to request the file from the user.

import_data_image(fname=None)[source]

Import the data reader image from an external file

This method imports the straditize.binary.DataReader.image from an external file and sets it to the current data_reader.

Parameters

fname (str, PIL.Image.Image or None) – The path of the image file or the PIL.Image.Image. If None, a QFileDialog is opened to request the file from the user.

See also

import_binary_image()

To import the binary file

import_full_image(fname=None)[source]

Import the straditizer image from an external file

This method imports the straditize.straditizer.Straditizer.image from an external file and sets it to the current straditizer.

Parameters

fname (str, PIL.Image.Image or None) – The path of the image file or the PIL.Image.Image. If None, a QFileDialog is opened to request the file from the user.

import_text_image(fname)[source]

Import the column names reader image from an external file

This method imports the straditize.colnames.ColNamesReader.highres_image from an external file and sets it to the current colnames_reader.

Parameters

fname (str, PIL.Image.Image or None) – The path of the image file or the PIL.Image.Image. If None, a QFileDialog is opened to request the file from the user.

open_straditizer(fname=None, *args, **kwargs)[source]

Open a straditizer from an image or project file

Parameters

fname (str, PIL.Image.Image or None) –

The path to the file to import. If None, a QFileDialog is opened and the user is asked for a file name. The action then depends on the ending of fname:

'.nc' or '.nc4'

we expect a netCDF file and open it with xarray.open_dataset() and load the straditizer with the straditize.straditizer.Straditizer.from_dataset() constructor

'.pkl'

We expect a pickle file and load the straditizer with pickle.load()

any other ending

We expect an image file and use the PIL.Image.open() function

At the end, the loading is finished with the finish_loading() method

refresh()[source]

Refresh from the straditizer

save_actions = []

The QActions to save the straditizer, straditizer image, etc.

save_data_image(fname=None)[source]

Save the binary image of the data reader

Save the straditize.binary.DataReader.binary of the current data_reader

Parameters

%(StraditizerMenuActions._save_image.parameters.fname)s

save_full_image(fname=None)[source]

Save the image of the straditizer

Save the straditize.straditizer.Straditizer.image of the current straditizer

Parameters

%(StraditizerMenuActions._save_image.parameters.fname)s

save_straditizer()[source]

Save the straditizer to a file

save_straditizer_as(fname=None)[source]

Save the straditizer to a file

Parameters

fname (str or None) –

If None, a QFileDialog is opened and the user has to provide a filename. The final action then depends on the ending of the chose file:

'.pkl'

We save the straditizer with pickle.dump()

else

We use the straditize.straditizer.Straditizer.to_dataset() method and save the resulting dataset using the xarray.Dataset.to_netcdf() method

save_text_image(fname=None)[source]

Save the image of the colnames reader

Save the straditize.colnames.ColNamesReader.image of the current colnames_reader

Parameters

fname (str or None) – The path of the target filename where to save the image. If None, A QFileDialog is opened and we ask the user for a filename

static set_ax_xlim(ax_ref)[source]

Define a function to update xlim from a given centered value

Parameters

ax_ref (matplotlib.axes.Axes) – The axes whose x-limits to update when the returned function is called

Returns

The function that can be called with a val to set the x-center of the ax_ref

Return type

callable

static set_ax_ylim(ax_ref)[source]

Define a function to update ylim from a given centered value

Parameters

ax_ref (matplotlib.axes.Axes) – The axes whose y-limits to update when the returned function is called

Returns

The function that can be called with a val to set the y-center of the ax_ref

Return type

callable

set_stradi_in_console()[source]

Set the straditizer in the console of the GUI mainwindow

This sets the current straditizer in psyplots console as the stradi variable

setup_children(item)[source]

Setup the children for this control

This method is called to setup the children in the StraditizerWidgets.tree. By default, it just creates a child QTreeWidgetItem and sets this control as it’s widget

Parameters

item (QTreeWidgetItem) – The top level item in the StraditizerWidgets.tree

setup_menu_actions(main)[source]

Create the actions for the file menu

Parameters

main (psyplot_gui.main.MainWindow) – The mainwindow whose menubar shall be adapted

setup_shortcuts(main)[source]

Setup the shortcuts when switched to the straditizer layout

Parameters

main (psyplot_gui.main.MainWindow) – The psyplot mainwindow

stack_zoom_window()[source]

Stack the magnifier image above the help explorer

text_actions = []

The QActions to save the column names images

static update_x_navigation_sliders(ax)[source]

Update the horizontal navigation slider for the given ax`

Set the horizontal slider of the straditizer figure depending on the x-limits of it’s corresponding axes

Parameters

ax (matplotlib.axes.Axes) – The straditize.straditizer.Straditizer.ax attribute of a straditizer

static update_y_navigation_sliders(ax)[source]

Update the vertical navigation slider for the given ax`

Set the vertical slider of the straditizer figure depending on the y-limits of it’s corresponding axes

Parameters

ax (matplotlib.axes.Axes) – The straditize.straditizer.Straditizer.ax attribute of a straditizer

window_layout_action = None

The action to switch_to_straditizer_layout()