straditize.widgets package

The straditizer widgets

This module contains widgets to digitize the straditizer diagrams through a GUI

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

EnableButton

A QPushButton that emits a signal when enabled

InfoButton(parent[, fname, rst, name])

A button to display help informations in the help explorer

StraditizerControlBase

A base class for the straditizer widget

StraditizerWidgets(*args, **kwargs)

A widget that contains widgets to control the straditization in a GUI

Functions

get_doc_file(fname)

Return the path to a documentation file

get_icon(fname)

Return the path of an icon

get_straditizer_widgets([mainwindow])

Get the StraditizerWidgets from the psyplot GUI mainwindow

read_doc_file(fname)

Return the content of a rst documentation file

class straditize.widgets.EnableButton[source]

Bases: PyQt5.QtWidgets.QPushButton

A QPushButton that emits a signal when enabled

Attributes

enabled(*args, **kwargs)

A signal that is emitted with a boolean whether if the button is

Methods

setEnabled(b)

Reimplemented to emit the enabled signal

enabled(*args, **kwargs)

A signal that is emitted with a boolean whether if the button is enabled or disabled

setEnabled(b)[source]

Reimplemented to emit the enabled signal

class straditize.widgets.InfoButton(parent, fname=None, rst=None, name=None)[source]

Bases: PyQt5.QtWidgets.QToolButton

A button to display help informations in the help explorer

Parameters
  • parent (QWidget) – The parent widget

  • fname (str) – The name of the rst file. If None, specify the rst directly

  • rst (str) – The restructured text to render when this button is clicked. If None, the fname has to be provided

  • name (str) – The name to use for the document in the help_explorer

Methods

show_docs()

Show the docs

show_docs()[source]

Show the docs

Shows the docs in the in the help_explorer

class straditize.widgets.StraditizerControlBase[source]

Bases: object

A base class for the straditizer widget

Methods

add_info_button(child[, fname, rst, name, …])

Add an info button to the given QTreeWidgetItem

connect2apply(*funcs)

Connect the functions to the apply_button

connect2cancel(*funcs)

Connect the functions to the cancel_button

enable_or_disable_widgets(b)

Enable or disable the widgets in this control

init_straditizercontrol(straditizer_widgets)

Initialize the straditizer control widget

refresh()

Refresh from the straditizer

setup_children(item)

Setup the children for this control

should_be_enabled(w)

Check if a widget should be enabled

Attributes

apply_button

The apply button of the straditizer_widgets

cancel_button

The cancel button of the straditizer_widgets

help_explorer

The psyplot_gui.help_explorer.HelpExplorer of the

straditizer

The current straditizer from the straditizer_widgets

straditizer_widgets

The StraditizierWidgets control

widgets2disable

A list of widgets to disable or enable if the apply_button is enabled

add_info_button(child, fname=None, rst=None, name=None, connections=[])[source]

Add an info button to the given QTreeWidgetItem

Parameters

child (QTreeWidgetItem) – The item to which to add the infobutton

property apply_button

The apply button of the straditizer_widgets

property cancel_button

The cancel button of the straditizer_widgets

connect2apply(*funcs)[source]

Connect the functions to the apply_button

Parameters

*funcs – The callables that should be connected to the apply_button

connect2cancel(*funcs)[source]

Connect the functions to the cancel_button

Parameters

*funcs – The callables that should be connected to the cancel_button

enable_or_disable_widgets(b)[source]

Enable or disable the widgets in this control

This method enables or disables the widgets2disable if the should_be_enabled() method evaluates to True

Parameters

b (bool) – If True, enable the widgets, if False, disable them

property help_explorer

The psyplot_gui.help_explorer.HelpExplorer of the psyplot_gui.main.mainwindow

init_straditizercontrol(straditizer_widgets, item=None)[source]

Initialize the straditizer control widget

This method should be called by every subclass when initializing. It sets the straditizer_widgets, connects the enable_or_disable_widgets() method and adds a new item to the StraditizerWidgets.tree

Parameters
refresh()[source]

Refresh from the straditizer

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

should_be_enabled(w)[source]

Check if a widget should be enabled

This function checks if a given widget w from the widgets2disable attribute should be enabled or not

Parameters

w (QWidget) – The widget to check

Returns

True, if the widget should be enabled

Return type

bool

property straditizer

The current straditizer from the straditizer_widgets

straditizer_widgets = None

The StraditizierWidgets control

widgets2disable = []

A list of widgets to disable or enable if the apply_button is enabled

class straditize.widgets.StraditizerWidgets(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget, psyplot_gui.common.DockMixin

A widget that contains widgets to control the straditization in a GUI

This widget is the basis of the straditize GUI and implemented as a plugin into the psyplot gui. The open straditizers are handled in the _straditizer attribute.

The central parts of this widget are

  • The combobox to manage the open straditizers

  • The QTreeWidget in the tree attribute that contains all the controls to interface the straditizer

  • the tutorial area

  • the Apply and Cancel button

Methods

add_info_button(child[, fname, rst, name, …])

Add an infobutton to the tree widget

add_straditizer(stradi)

Add a straditizer to the list of open straditizers

autosave()

Autosave the current straditizer

close_all_straditizers()

Close all straditizers

close_straditizer()

Close the current straditizer

create_straditizer_from_args(fnames[, …])

Create a straditizer from the given file name

disable_apply_button()

Method that is called when the cancel_button is clicked

edit_attrs()

Edit the attributes of the current straditizer

get_attr(stradi, attr)

raise_figures()

Raise the figures of the current straditizer in the GUI

refresh()

Refresh from the straditizer

reload_autosaved()

Reload the autosaved straditizer and close the old one

reset_control()

Reset the GUI of straditize

set_current_stradi(i)

Set the i-th straditizer to the current one

show_or_hide_toolbar()

Show or hide the toolbar depending on the visibility of this widget

start_tutorial(state[, tutorial_cls])

Start or stop the tutorial

switch_to_straditizer_layout()

Switch to the straditizer layout

to_dock(main, *args, **kwargs)

Attributes

always_yes

Boolean that is True if all dialogs should be answered with Yes

apply_button

The apply button

attrs_button

The button to edit the straditizer attributes

autosaved

Auto-saved straditizers

axes_translations

The straditize.widgets.axes_translations.AxesTranslations to

btn_close_stradi

A button to close the current straditizer

btn_open_stradi

A button to open a new straditizer

btn_reload_autosaved

A button to reload the last autosaved state

cancel_button

The cancel button

colnames_manager

The straditize.widgets.colnames.ColumnNamesManager to interface

digitizer

The straditize.widgets.data.DigitizingControl to interface

hidden

bool(x) -> bool

image_rescaler

The straditize.widgets.image_correction.ImageRescaler class to

image_rotator

The straditize.widgets.image_correction.ImageRotator class to

info_button

An InfoButton to display the docs

marker_control

The straditize.widgets.marker_control.MarkerControl to modify

open_external(*args, **kwargs)

plot_control

The straditize.widgets.plots.PlotControl to display additional

progress_widget

The straditize.widgets.progress_widget.ProgressWidget to

selection_toolbar

The straditize.widgets.selection_toolbar.SelectionToolbar to

stradi_combo

A QComboBox to select the current straditizer

straditizer

The straditize.straditizer.Straditizer instance

title

str(object=’’) -> str

tree

The QTreeWidget that contains the different widgets for the digitization

tutorial

The straditize.widgets.tutorial.Tutorial class

tutorial_button

The button to start a tutorial

add_info_button(child, fname=None, rst=None, name=None, connections=[])[source]

Add an infobutton to the tree widget

Parameters
  • child (QTreeWidgetItem) – The item to which to add the infobutton

  • connections (list of QPushButtons) – Buttons that should be clicked when the info button is clicked

add_straditizer(stradi)[source]

Add a straditizer to the list of open straditizers

always_yes = False

Boolean that is True if all dialogs should be answered with Yes

apply_button = None

The apply button

attrs_button = None

The button to edit the straditizer attributes

autosave()[source]

Autosave the current straditizer

autosaved = []

Auto-saved straditizers

axes_translations = None

The straditize.widgets.axes_translations.AxesTranslations to handle the y- and x-axis conversions

btn_close_stradi = None

A button to close the current straditizer

btn_open_stradi = None

A button to open a new straditizer

btn_reload_autosaved = None

A button to reload the last autosaved state

cancel_button = None

The cancel button

close_all_straditizers()[source]

Close all straditizers

close_straditizer()[source]

Close the current straditizer

colnames_manager = None

The straditize.widgets.colnames.ColumnNamesManager to interface the :straditize.straditizer.Straditizer.colnames_reader`

create_straditizer_from_args(fnames, project=None, xlim=None, ylim=None, full=False, reader_type='area')[source]

Create a straditizer from the given file name

This method is called when the psyplot_gui.main.mainwindow receives a ‘straditize’ callback

digitizer = None

The straditize.widgets.data.DigitizingControl to interface the :straditize.straditizer.Straditizer.data_reader`

disable_apply_button()[source]

Method that is called when the cancel_button is clicked

dock_position = 1
edit_attrs()[source]

Edit the attributes of the current straditizer

This creates a new dataframe editor to edit the straditize.straditizer.Straditizer.attrs meta informations

get_attr(stradi, attr)[source]
hidden = True
image_rescaler = None

The straditize.widgets.image_correction.ImageRescaler class to rescale the image

image_rotator = None

The straditize.widgets.image_correction.ImageRotator class to rotate the image

info_button = None

An InfoButton to display the docs

marker_control = None

The straditize.widgets.marker_control.MarkerControl to modify the appearance of the marks of the current straditizer

open_external(*args, **kwargs)
plot_control = None

The straditize.widgets.plots.PlotControl to display additional information on the diagram

progress_widget = None

The straditize.widgets.progress_widget.ProgressWidget to display the progress of the straditization

raise_figures()[source]

Raise the figures of the current straditizer in the GUI

refresh()[source]

Refresh from the straditizer

reload_autosaved()[source]

Reload the autosaved straditizer and close the old one

reset_control()[source]

Reset the GUI of straditize

selection_toolbar = None

The straditize.widgets.selection_toolbar.SelectionToolbar to select features in the stratigraphic diagram

set_current_stradi(i)[source]

Set the i-th straditizer to the current one

show_or_hide_toolbar()[source]

Show or hide the toolbar depending on the visibility of this widget

start_tutorial(state, tutorial_cls=None)[source]

Start or stop the tutorial

Parameters
stradi_combo = None

A QComboBox to select the current straditizer

straditizer = None

The straditize.straditizer.Straditizer instance

switch_to_straditizer_layout()[source]

Switch to the straditizer layout

This method makes this widget visible and stacks it with the psyplot content widget

title = 'Stratigraphic diagram digitization'
to_dock(main, *args, **kwargs)[source]
tree = None

The QTreeWidget that contains the different widgets for the digitization

tutorial = None

The straditize.widgets.tutorial.Tutorial class

tutorial_button = None

The button to start a tutorial

window_layout_action = None
straditize.widgets.get_doc_file(fname)[source]

Return the path to a documentation file

straditize.widgets.get_icon(fname)[source]

Return the path of an icon

straditize.widgets.get_straditizer_widgets(mainwindow=None)[source]

Get the StraditizerWidgets from the psyplot GUI mainwindow

Parameters

psyplot_gui.main.MainWindow – The mainwindow to use. If None, the psyplot_gui.main.mainwindow is used.

Returns

The straditizer widgets of the given mainwindow

Return type

StraditizerWidgets

straditize.widgets.read_doc_file(fname)[source]

Return the content of a rst documentation file