straditize.widgets.colnames module

Widget for handling column names

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

ColumnNamesManager(straditizer_widgets[, item])

Manage the column names of the reader

DummyNavigationToolbar2(canvas)

Reimplemented NavigationToolbar2 just to add an _init_toolbar method

class straditize.widgets.colnames.ColumnNamesManager(straditizer_widgets, item=None, *args, **kwargs)[source]

Bases: straditize.widgets.StraditizerControlBase, psyplot_gui.common.DockMixin, PyQt5.QtWidgets.QSplitter

Manage the column names of the reader

Parameters
  • straditizer_widgets (StraditizerWidgets) – The main widget for the straditizer GUI

  • item (QTreeWidgetItem) – The parent item in the StraditizerWidgets.tree. If given, the setup_children() is called with this item

Attributes

NAVIGATION_LABEL

str(object=’’) -> str

SELECT_LABEL

str(object=’’) -> str

btn_find

A QPushButton to find column names in the visible part of the

btn_load_image

A QPushButton to load the highres image

btn_recognize

A QPushButton to recognize text in the colpic

btn_select_colpic

A checkable QPushButton to initialize a selector to select the

btn_select_names

The QPushButton in the straditize.widgets.StraditizerWidgets

cb_find_all_cols

A QCheckBox to find the column names (see btn_find) for all

cb_fliph

A QCheckBox to set the straditize.colnames.ColNamesReader.mirror

cb_flipv

A QCheckBox to set the straditize.colnames.ColNamesReader.flip

cb_ignore_data_part

A QCheckBox to ignore the part within the

colnames_reader

The straditize.straditizer.Straditizer.colnames_reader

colnames_table

A QTableWidget to display the column names

colpic

The PIL.Image.Image of the column name (see also

colpic_ax

The matplotlib.axes.Axes to display the colpic_im

colpic_canvas

The canvas to display the colpic_im

colpic_extents

The extents of the colpic in the im_rotated

colpic_im

The matplotlib image of the colpic

current_col

The currently selected column

fig_h

The original height of the main_canvas

fig_w

The original width of the main_canvas

im_rotated

The matplotlib image of the

main_ax

The matplotlib.axes.Axes to display the im_rotated

main_canvas

The canvas to display the im_rotated

rect

The rectangle to highlight a column (see highlight_selected_col())

refreshing

True if the widget is refreshing

selector

The matplotlib.widgets.RectangleSelector to select the

txt_rotate

A QLineEdit to set the straditize.colnames.ColNamesReader.rotate

Methods

adjust_lims()

Adjust the limits of the main_ax to fill the entire figure

adjust_lims_after_resize(event)

Adjust the limits of the main_ax after resize of the figure

cancel_colpic_selection()

Stop the colpic selection in the im_rotated

change_ignore_data_part(checked)

Change straditize.colnames.ColNamesReader.ignore_data_part

colname_changed(row, column)

Update the column name in the colnames_reader

create_selector()

Create the selector to enable colpic selection

enable_or_disable_btn_find(*args, **kwargs)

find_colnames([warn, full_image, all_cols])

Find the column names automatically

flip(checked)

TFlip the image

highlight_selected_col()

Highlight the column selected in the colnames_tables

load_image()

Load a high resolution image

maybe_tabify()

mirror(checked)

Mirror the image

plot_colpic()

Plot the colpic in the colpic_ax

read_colpic()

Recognize the text in the colpic

refresh()

Refresh from the straditizer

remove_images()

Remove the im_rotated and the colpic_im

remove_selector()

Remove and disconnect the selector

replot_figure()

Remove and replot the im_rotated

reset_control()

Reset the dialog

rotate(val)

Rotate the image

set_xc_yc()

Set the x- and y-center before rotating or flipping

setup_children(item)

Setup the children for this control

should_be_enabled(w)

Check if a widget should be enabled

to_dock(main[, title, position])

toggle_colpic_selection()

Enable or disable the colpic selection

toggle_dialog()

Close the dialog when the btn_select_names button is clicked

update_image(*args, **kwargs)

Update the colpic with the extents of the selector

NAVIGATION_LABEL = 'Use left-click of your mouse to move the image below and right-click to zoom in and out.'
SELECT_LABEL = 'Left-click and hold on the image to select the column name'
adjust_lims()[source]

Adjust the limits of the main_ax to fill the entire figure

adjust_lims_after_resize(event)[source]

Adjust the limits of the main_ax after resize of the figure

btn_find = None

A QPushButton to find column names in the visible part of the im_rotated

btn_load_image = None

A QPushButton to load the highres image

btn_recognize = None

A QPushButton to recognize text in the colpic

btn_select_colpic = None

A checkable QPushButton to initialize a selector to select the colpic

btn_select_names = None

The QPushButton in the straditize.widgets.StraditizerWidgets to toggle the column names dialog

cancel_colpic_selection()[source]

Stop the colpic selection in the im_rotated

cb_find_all_cols = None

A QCheckBox to find the column names (see btn_find) for all columns and not just the one selected in the colnames_table

cb_fliph = None

A QCheckBox to set the straditize.colnames.ColNamesReader.mirror

cb_flipv = None

A QCheckBox to set the straditize.colnames.ColNamesReader.flip

cb_ignore_data_part = None

A QCheckBox to ignore the part within the straditize.colnames.ColNamesReader.data_ylim

change_ignore_data_part(checked)[source]

Change straditize.colnames.ColNamesReader.ignore_data_part

colname_changed(row, column)[source]

Update the column name in the colnames_reader

This method is called when a cell in the colnames_table has been changed and updates the corresponding name in the colnames_reader

Parameters
property colnames_reader

The straditize.straditizer.Straditizer.colnames_reader of the current straditizer

colnames_table = None

A QTableWidget to display the column names

colpic = None

The PIL.Image.Image of the column name (see also straditize.colnames.ColNamesReader.colpics)

colpic_ax = None

The matplotlib.axes.Axes to display the colpic_im

colpic_canvas = None

The canvas to display the colpic_im

colpic_extents = None

The extents of the colpic in the im_rotated

colpic_im = None

The matplotlib image of the colpic

create_selector()[source]

Create the selector to enable colpic selection

property current_col

The currently selected column

enable_or_disable_btn_find(*args, **kwargs)[source]
fig_h = None

The original height of the main_canvas

fig_w = None

The original width of the main_canvas

find_colnames(warn=True, full_image=False, all_cols=None)[source]

Find the column names automatically

flip(checked)[source]

TFlip the image

highlight_selected_col()[source]

Highlight the column selected in the colnames_tables

im_rotated = None

The matplotlib image of the straditize.colnames.ColNamesReader.rotated_image

load_image()[source]

Load a high resolution image

main_ax = None

The matplotlib.axes.Axes to display the im_rotated

main_canvas = None

The canvas to display the im_rotated

maybe_tabify()[source]
mirror(checked)[source]

Mirror the image

plot_colpic()[source]

Plot the colpic in the colpic_ax

read_colpic()[source]

Recognize the text in the colpic

rect = None

The rectangle to highlight a column (see highlight_selected_col())

refresh()[source]

Refresh from the straditizer

property refreshing

True if the widget is refreshing

remove_images()[source]

Remove the im_rotated and the colpic_im

remove_selector()[source]

Remove and disconnect the selector

replot_figure()[source]

Remove and replot the im_rotated

reset_control()[source]

Reset the dialog

rotate(val)[source]

Rotate the image

Parameters

float – The angle for the rotation

selector = None

The matplotlib.widgets.RectangleSelector to select the colpic

set_xc_yc()[source]

Set the x- and y-center before rotating or flipping

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

to_dock(main, title=None, position=None, *args, **kwargs)[source]
toggle_colpic_selection()[source]

Enable or disable the colpic selection

toggle_dialog()[source]

Close the dialog when the btn_select_names button is clicked

txt_rotate = None

A QLineEdit to set the straditize.colnames.ColNamesReader.rotate

update_image(*args, **kwargs)[source]

Update the colpic with the extents of the selector

*args and **kwargs are ignored

class straditize.widgets.colnames.DummyNavigationToolbar2(canvas)[source]

Bases: matplotlib.backend_bases.NavigationToolbar2

Reimplemented NavigationToolbar2 just to add an _init_toolbar method

Methods

set_cursor(cursor)

Set the current cursor to one of the Cursors enums values.

set_cursor(cursor)[source]

Set the current cursor to one of the Cursors enums values.

If required by the backend, this method should trigger an update in the backend event loop after the cursor is set, as this method may be called e.g. before a long-running task during which the GUI is not updated.