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

buttons

alias of StandardButton

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

choices = 81920
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: 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.

class dialogs.ChartDialog(parent, key, size=(1000, 700))[source]

Bases: 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: 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: QIntValidator

Returns column validator

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

Returns tuple of initial values

property _row_validator: QIntValidator

Returns row validator

property _validator

Returns int validator for positive numbers

property area: SinglePageArea | MultiPageArea

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

Returns None if the dialog is canceled.

area_cls

alias of SinglePageArea

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

Returns list of validators for dialog

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

Bases: 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: Dialect

Default dialect for export based on excel-tab

maxrows = 10
reset()[source]

Button event handler, resets parameter_groupbox and csv_preview

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

Bases: 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: QDialog

Modal dialog for importing csv files

Parameters:
  • parent (QWidget) – Parent window

  • filepath (Path) – Path to csv file

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

_sniff_dialect()[source]

Sniff the dialect of self.filepath`

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: 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_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'
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: 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 (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: 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 (Sequence[str]) – Initial values to be displayed in the dialog

  • validators (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.

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

buttons

alias of StandardButton

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

choices = 12584960
default_choice = 2048
text = 'There are unsaved changes.\nDo you want to save?'
title = 'Unsaved changes'
class dialogs.DiscardDataDialog(main_window, text)[source]

Bases: DiscardChangesDialog

Modal dialog that asks if the user wants to discard data

Parameters:
  • main_window (QMainWindow) – Application main window

  • text (str) – Message text

buttons

alias of StandardButton

choices = 12582912
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

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

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

Bases: 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

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

Bases: 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: 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: QDialog

Find dialog that is launched from the main menu

Parameters:

main_window (QMainWindow) – Application main window

_create_widgets()[source]

Create find dialog widgets

Parameters:

results_checkbox – Show find results checkbox

_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: QPoint
regex: bool
results: bool
start: bool
word: bool
class dialogs.GridShapeDialog(parent, shape, title='Create a new Grid')[source]

Bases: 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.

class dialogs.ImageFileOpenDialog(main_window)[source]

Bases: 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 = [PyQt6.QtCore.QByteArray(b'bmp'), PyQt6.QtCore.QByteArray(b'cur'), PyQt6.QtCore.QByteArray(b'ico'), PyQt6.QtCore.QByteArray(b'jpeg'), PyQt6.QtCore.QByteArray(b'jpg'), PyQt6.QtCore.QByteArray(b'pbm'), PyQt6.QtCore.QByteArray(b'pgm'), PyQt6.QtCore.QByteArray(b'png'), PyQt6.QtCore.QByteArray(b'ppm'), PyQt6.QtCore.QByteArray(b'xbm'), PyQt6.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: 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: SinglePageArea

Holds multi page area boundaries e.g. for printing

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

Bases: 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.

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

Bases: 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

property _table_validator: QIntValidator

Returns column validator

area_cls

alias of MultiPageArea

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

Returns list of validators for dialog

class dialogs.PrintPreviewDialog(printer)[source]

Bases: 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: 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.SvgExportAreaDialog(parent, grid, title)[source]

Bases: CsvExportAreaDialog

Modal dialog for entering svg 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

groupbox_title = 'SVG export area'
class dialogs.TutorialDialog(parent)[source]

Bases: 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: 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'