dialogs.*

Modal dialogs

class dialogs.ApproveWarningDialog(parent)[source]

Bases: object

Modal warning dialog for approving files to be evaled

The modal dialog is shown on accessing the property choice.

Parameters

parent (QWidget) – Parent widget, e.g. main window

property choice: bool

User choice

Returns True iif the user approves leaving safe_mode. Returns False iif the user chooses to stay in safe_mode Returns None if the user chooses to abort the operation

Return type

bool

choices = <PyQt5.QtWidgets.QMessageBox.StandardButtons object>
default_choice = 65536
text = 'You are going to approve and trust a file that you have not created yourself. After proceeding, the file is executed.\n \nIt may harm your system as any program can. Please check all cells thoroughly before proceeding.\n \nProceed and sign this file as trusted?'
title = 'Security warning'
class dialogs.CellKeyDialog(parent, shape)[source]

Bases: dialogs.DataEntryDialog

Modal dialog for entering a cell key, i.e. row, column, table

Parameters
  • parent (QWidget) – Parent widget, e.g. main window

  • shape (Tuple[int, int, int]) – Grid shape

property key: Tuple[int, int, int]

Executes the dialog and returns rows, columns, tables

Returns None if the dialog is canceled.

Return type

Tuple[int, int, int]

class dialogs.ChartDialog(parent, key, size=(800, 600))[source]

Bases: PyQt5.QtWidgets.QDialog

The chart dialog

Parameters
  • parent (QWidget) – Parent window

  • key (Tuple[int, int, int]) – Target cell for chart

  • size (Tuple[int, int]) – Initial dialog size

apply()[source]

Executes the code in the dialog and updates the canvas

create_buttonbox()[source]

Returns a QDialogButtonBox with Ok and Cancel

dialog_ui()[source]

Sets up dialog UI

on_template()[source]

Event handler for pressing a template toolbar button

class dialogs.CsvExportAreaDialog(parent, grid, title)[source]

Bases: dialogs.DataEntryDialog

Modal dialog for entering csv export area

Initially, this dialog is filled with the selection bounding box if present or with the visible area of <= 1 cell is selected.

Parameters
  • parent (QWidget) – Parent widget, e.g. main window

  • grid (QTableView) – The main grid widget

  • title (str) – Dialog title

property _column_validator: PyQt5.QtGui.QIntValidator

Returns column validator

Return type

QIntValidator

property _initial_values: Tuple[int, int, int, int]

Returns tuple of initial values

Return type

Tuple[int, int, int, int]

property _row_validator: PyQt5.QtGui.QIntValidator

Returns row validator

Return type

QIntValidator

property _validator

Returns int validator for positive numbers

property area: Union[dialogs.SinglePageArea, dialogs.MultiPageArea]

Executes the dialog and returns top, left, bottom, right

Returns None if the dialog is canceled.

Return type

Union[SinglePageArea, MultiPageArea]

area_cls

alias of dialogs.SinglePageArea

groupbox_title = 'Page area'
labels = ['Top', 'Left', 'Bottom', 'Right']
property validator_list: List[PyQt5.QtGui.QIntValidator]

Returns list of validators for dialog

Return type

List[QIntValidator]

class dialogs.CsvExportDialog(parent, csv_area)[source]

Bases: PyQt5.QtWidgets.QDialog

Modal dialog for exporting csv files

Parameters
  • parent (QWidget) – Parent window

  • csv_area (SinglePageArea) – Grid area to be exported

accept()[source]

Button event handler, starts csv import

apply()[source]

Button event handler, applies parameters to csv_preview

create_buttonbox()[source]

Returns button box with Reset, Apply, Ok, Cancel

Return type

QDialogButtonBox

property default_dialect: csv.Dialect

Default dialect for export based on excel-tab

Return type

Dialect

maxrows = 10
reset()[source]

Button event handler, resets parameter_groupbox and csv_preview

title = 'CSV export'
class dialogs.CsvFileImportDialog(main_window)[source]

Bases: dialogs.FileDialogBase

Modal dialog for importing csv files

Parameters

main_window (QMainWindow) – Application main window

filters_list = ['CSV file (*.*)']
show_dialog()[source]

Present dialog and update values

property suffix

Do not offer suffix for filepath

title = 'Import data'
class dialogs.CsvImportDialog(parent, filepath, digest_types=None)[source]

Bases: PyQt5.QtWidgets.QDialog

Modal dialog for importing csv files

Parameters
  • parent (QWidget) – Parent window

  • filepath (Path) – Path to csv file

  • digest_types (Optional[List[str]]) – Names of preprocessing functions for csv values

accept()[source]

Button event handler, starts csv import

apply()[source]

Button event handler, applies parameters to csv_table

create_buttonbox()[source]

Returns a QDialogButtonBox

reset()[source]

Button event handler, resets parameter_groupbox and csv_table

title = 'CSV import'
class dialogs.CsvParameterGroupBox(parent)[source]

Bases: PyQt5.QtWidgets.QGroupBox

QGroupBox that holds parameter widgets for the csv import dialog

Parameters

parent (QWidget) – Parent window

_create_widgets()[source]

Create widgets for all parameters

_layout()[source]

Layout widgets

adjust_csvdialect(dialect)[source]

Adjusts csv dialect from widget settings

Note that the dialect has two extra attributes encoding and hasheader

Parameters

dialect (Dialect) – Attributes class for csv reading and writing

Return type

Dialect

default_delimiter = ','
default_encoding = 'utf-8'
default_quotechar = '"'
default_quoting = 'QUOTE_MINIMAL'
delimiter_tooltip = 'A one-character string used to separate fields.'
doublequote_tooltip = 'Controls how instances of quotechar appearing inside a field should be themselves be quoted. When True, the character is doubled. When False, the escapechar is used as a prefix to the quotechar.'
encoding_widget_tooltip = 'CSV file encoding'
encodings = ('ascii', 'big5', 'big5hkscs', 'cp037', 'cp424', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865', 'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006', 'cp1026', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc-jp', 'euc-jis-2004', 'euc-jisx0213', 'euc-kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'iso2022-jp-2004', 'iso2022-jp-3', 'iso2022-jp-ext', 'iso2022-kr', 'latin-1', 'iso8859-2', 'iso8859-3', 'iso8859-4', 'iso8859-5', 'iso8859-6', 'iso8859-7', 'iso8859-8', 'iso8859-9', 'iso8859-10', 'iso8859-13', 'iso8859-14', 'iso8859-15', 'iso8859-16', 'johab', 'koi8-r', 'koi8-u', 'mac-cyrillic', 'mac-greek', 'mac-iceland', 'mac-latin2', 'mac-roman', 'mac-turkish', 'ptcp154', 'shift-jis', 'shift-jis-2004', 'shift-jisx0213', 'utf-32', 'utf-32-be', 'utf-32-le', 'utf-16', 'utf-16-be', 'utf-16-le', 'utf-7', 'utf-8', 'utf-8-sig')
escapechar_tooltip = 'A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if doublequote is False. On reading, the escapechar removes any special meaning from the following character.'
hasheader_tooltip = 'Analyze the CSV file and treat the first row as strings if it appears to be a series of column headers.'
keepheader_tooltip = 'Import header labels as str in the first row'
on_hasheader_toggled(toggled)[source]

Disables keep_header if hasheader is not toggled

quotechar_tooltip = 'A one-character string used to quote fields containing special characters, such as the delimiter or quotechar, or which contain new-line characters.'
quoting_widget_tooltip = 'Controls when quotes should be generated by the writer and recognised by the reader.'
quotings = ('QUOTE_ALL', 'QUOTE_MINIMAL', 'QUOTE_NONNUMERIC', 'QUOTE_NONE')
set_csvdialect(dialect)[source]

Update widgets from given csv dialect

Parameters

dialect (Dialect) – Attributes class for csv reading and writing

skipinitialspace_tooltip = 'When True, whitespace immediately following the delimiter is ignored.'
title = 'Parameters'
class dialogs.CsvTable(parent)[source]

Bases: PyQt5.QtWidgets.QTableView

Table for previewing csv file content

Parameters

parent (QWidget) – Parent window

add_choice_row(length)[source]

Adds row with comboboxes for digest choice

Parameters

length (int) – Number of columns in row

fill(filepath, dialect, digest_types=None)[source]

Fills the csv table with values from the csv file

Parameters
  • filepath (Path) – Path to csv file

  • dialect (Dialect) – Attributes class for csv reading and writing

  • digest_types (Optional[List[str]]) – Names of preprocessing functions for csv values

get_digest_types()[source]

Returns list of digest types from comboboxes

Return type

List[str]

no_rows = 9
update_comboboxes(digest_types)[source]

Updates the cono boxes to show digest_types

Parameters

digest_types (List[str]) – Names of preprocessing functions for csv values

class dialogs.DataEntryDialog(parent, title, labels, initial_data=None, groupbox_title=None, validators=None)[source]

Bases: PyQt5.QtWidgets.QDialog

Modal dialog for entering multiple values

Parameters
  • parent (QWidget) – Parent widget, e.g. main window

  • title (str) – Dialog title

  • labels (Sequence[str]) – Labels for the values in the dialog

  • initial_data (Optional[Sequence[str]]) – Initial values to be displayed in the dialog

  • validators (Optional[Sequence[Union[QValidator, bool, None]]]) – Validators for the editors of the dialog

len(initial_data), len(validators) and len(labels) must be equal

create_buttonbox()[source]

Returns a QDialogButtonBox with Ok and Cancel

Return type

QDialogButtonBox

create_form()[source]

Returns form inside a QGroupBox

Return type

QGroupBox

property data: Tuple[str]

Executes the dialog and returns input as a tuple of strings

Returns None if the dialog is canceled.

Return type

Tuple[str]

class dialogs.DiscardChangesDialog(main_window)[source]

Bases: object

Modal dialog that asks if the user wants to discard or save unsaved data

The modal dialog is shown on accessing the property choice.

Parameters

main_window (QMainWindow) – Application main window

property choice: bool

User choice

Returns True if the user confirms in a user dialog that unsaved changes will be discarded if conformed. Returns False if the user chooses to save the unsaved data Returns None if the user chooses to abort the operation

Return type

bool

choices = <PyQt5.QtWidgets.QMessageBox.StandardButtons object>
default_choice = 2048
text = 'There are unsaved changes.\nDo you want to save?'
title = 'Unsaved changes'
class dialogs.DiscardDataDialog(main_window, text)[source]

Bases: dialogs.DiscardChangesDialog

Modal dialog that asks if the user wants to discard data

Parameters
  • main_window (QMainWindow) – Application main window

  • text (str) – Message text

choices = <PyQt5.QtWidgets.QMessageBox.StandardButtons object>
default_choice = 4194304
title = 'Data to be discarded'
class dialogs.FileDialogBase(main_window)[source]

Bases: object

Base class for modal file dialogs

The chosen filename is stored in the file_path attribute The chosen name filter is stored in the chosen_filter attribute If the dialog is aborted then both filepath and chosen_filter are None

_get_filepath must be overloaded

Parameters

main_window (QMainWindow) – Application main window

file_path = None
property filters: str

Formatted filters for qt

Return type

str

filters_list = ['Pyspread un-compressed (*.pysu)', 'Pyspread compressed (*.pys)']
selected_filter = None
show_dialog()[source]

Sublasses must overload this method

property suffix: str

Suffix for filepath

Return type

str

title = 'Choose file'
class dialogs.FileExportDialog(main_window, filters_list)[source]

Bases: dialogs.FileDialogBase

Modal dialog for exporting csv files

Parameters
  • main_window (QMainWindow) – Application main window

  • filters_list (List[str]) – List of filter strings

show_dialog()[source]

Present dialog and update values

property suffix: str

Suffix for filepath

Return type

str

title = 'Export data'
class dialogs.FileOpenDialog(main_window)[source]

Bases: dialogs.FileDialogBase

Modal dialog for opening a pyspread file

Parameters

main_window (QMainWindow) – Application main window

show_dialog()[source]

Present dialog and update values

title = 'Open'
class dialogs.FileSaveDialog(main_window)[source]

Bases: dialogs.FileDialogBase

Modal dialog for saving a pyspread file

Parameters

main_window (QMainWindow) – Application main window

show_dialog()[source]

Present dialog and update values

title = 'Save'
class dialogs.FindDialog(main_window)[source]

Bases: PyQt5.QtWidgets.QDialog

Find dialog that is launched from the main menu

Parameters

main_window (QMainWindow) – Application main window

_create_widgets()[source]

Create find dialog widgets

_layout()[source]

Find dialog layout

_order()[source]

Find dialog tabOrder

closeEvent(event)[source]

Store state for next invocation and close

Parameters

event (QEvent) – Close event

restore(state)[source]

Restores state from FindDialogState

class dialogs.FindDialogState(pos, case, results, more, backward, word, regex, start)[source]

Bases: object

Dataclass for FindDialog state storage

backward: bool
case: bool
more: bool
pos: PyQt5.QtCore.QPoint
regex: bool
results: bool
start: bool
word: bool
class dialogs.GridShapeDialog(parent, shape, title='Create a new Grid')[source]

Bases: dialogs.DataEntryDialog

Modal dialog for entering the number of rows, columns and tables

Parameters
  • parent (QWidget) – Parent widget, e.g. main window

  • shape (Tuple[int, int, int]) – Initial shape to be displayed in the dialog

property shape: Tuple[int, int, int]

Executes the dialog and returns an rows, columns, tables

Returns None if the dialog is canceled.

Return type

Tuple[int, int, int]

class dialogs.ImageFileOpenDialog(main_window)[source]

Bases: dialogs.FileDialogBase

Modal dialog for inserting an image

Parameters

main_window (QMainWindow) – Application main window

img_format_string = '*.bmp *.cur *.ico *.jpeg *.jpg *.pbm *.pgm *.png *.ppm *.xbm *.xpm'
img_format_strings = <generator object ImageFileOpenDialog.<genexpr>>
img_formats = [PyQt5.QtCore.QByteArray(b'bmp'), PyQt5.QtCore.QByteArray(b'cur'), PyQt5.QtCore.QByteArray(b'ico'), PyQt5.QtCore.QByteArray(b'jpeg'), PyQt5.QtCore.QByteArray(b'jpg'), PyQt5.QtCore.QByteArray(b'pbm'), PyQt5.QtCore.QByteArray(b'pgm'), PyQt5.QtCore.QByteArray(b'png'), PyQt5.QtCore.QByteArray(b'ppm'), PyQt5.QtCore.QByteArray(b'xbm'), PyQt5.QtCore.QByteArray(b'xpm')]
name_filter = 'Images (*.bmp *.cur *.ico *.jpeg *.jpg *.pbm *.pgm *.png *.ppm *.xbm *.xpm);;Scalable Vector Graphics (*.svg *.svgz)'
show_dialog()[source]

Present dialog and update values

title = 'Insert image'
class dialogs.ManualDialog(parent)[source]

Bases: dialogs.TutorialDialog

Dialog for browsing the pyspread manual

Parameters

parent (QWidget) – Parent window

_create_widgets()[source]

Creates tabbar and dialog browser

_layout()[source]

Dialog layout management

size_hint = (1000, 800)
title2path = {'Advanced topics': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/advanced_topics.md'), 'Concepts': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/basic_concepts.md'), 'Edit': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/edit_menu.md'), 'File': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/file_menu.md'), 'Format': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/format_menu.md'), 'Macro': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/macro_menu.md'), 'Overview': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/overview.md'), 'View': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/view_menu.md'), 'Workspace': PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/manual/workspace.md')}
window_title = 'pyspread manual'
class dialogs.MultiPageArea(top, left, bottom, right, first, last)[source]

Bases: dialogs.SinglePageArea

Holds multi page area boundaries e.g. for printing

first: int
last: int
class dialogs.PreferencesDialog(parent)[source]

Bases: dialogs.DataEntryDialog

Modal dialog for entering pyspread preferences

Parameters

parent (QWidget) – Parent widget, e.g. main window

property data: dict

Executes the dialog and returns a dict containing preferences data

Returns None if the dialog is canceled.

Return type

dict

class dialogs.PrintAreaDialog(parent, grid, title)[source]

Bases: dialogs.CsvExportAreaDialog

Modal dialog for entering print area

Initially, this dialog is filled with the selection bounding box if present or with the visible area of <= 1 cell is selected. Initially, the current table is selected.

Parameters
  • parent (QWidget) – Parent widget, e.g. main window

  • grid (QTableView) – The main grid widget

  • title (str) – Dialog title

property _initial_values: Tuple[int, int, int, int, int, int]

Returns tuple of initial values

Return type

Tuple[int, int, int, int, int, int]

property _table_validator: PyQt5.QtGui.QIntValidator

Returns column validator

Return type

QIntValidator

area_cls

alias of dialogs.MultiPageArea

labels = ['Top', 'Left', 'Bottom', 'Right', 'First table', 'Last table']
property validator_list: List[PyQt5.QtGui.QIntValidator]

Returns list of validators for dialog

Return type

List[QIntValidator]

class dialogs.PrintPreviewDialog(printer)[source]

Bases: PyQt5.QtPrintSupport.QPrintPreviewDialog

Adds Mouse wheel functionality

Parameters

printer (QPrinter) – Target printer

wheelEvent(event)[source]

Overrides mouse wheel event handler

Parameters

event (QWheelEvent) – Mouse wheel event

class dialogs.ReplaceDialog(main_window)[source]

Bases: dialogs.FindDialog

Replace dialog that is launched from the main menu

Parameters

main_window (QMainWindow) – Application main window

class dialogs.SinglePageArea(top, left, bottom, right)[source]

Bases: object

Holds single page area boundaries e.g. for export

bottom: int
left: int
right: int
top: int
class dialogs.TutorialDialog(parent)[source]

Bases: PyQt5.QtWidgets.QDialog

Dialog for browsing the pyspread tutorial

Parameters

parent (QWidget) – Parent window

_create_widgets()[source]

Creates dialog widgets, e.g. the browser

_layout()[source]

Dialog layout management

path: pathlib.Path = PosixPath('/builds/pyspread/pyspread/pyspread/share/doc/tutorial/tutorial.md')
sizeHint()[source]

QDialog.sizeHint override

Return type

QSize

size_hint = (1000, 800)
window_title = 'pyspread tutorial'