Preferences widget for psyplot_gui
This module defines the Preferences
widget that creates an interface
to the rcParams of psyplot and psyplot_gui
Classes:
An abstract base class for configuration pages |
|
|
The config page for the |
|
Preferences dialog |
|
The config page for the |
|
A QTreeWidget that can be used to display a RcParams instance |
|
A configuration page for RcParams instances |
- class psyplot_gui.preferences.ConfigPage[source]
Bases:
object
An abstract base class for configuration pages
Methods:
Apply the planned changes
Initialize the page
Attributes:
bool
that is True, if the changes in this ConfigPage are set immediatelyCheck whether the preferences will change
The icon of the page
Check whether the page is valid
propose_changes
(*args, **kwargs)A signal that is emitted if changes are propsed.
The title for the config page
validChanged
(*args, **kwargs)A signal that shall be emitted if the validation state changes
- property changed
Check whether the preferences will change
- icon = None
The icon of the page
- property is_valid
Check whether the page is valid
- propose_changes(*args, **kwargs)
A signal that is emitted if changes are propsed. The signal should be emitted with the instance of the page itself
- title = None
The title for the config page
- validChanged(*args, **kwargs)
A signal that shall be emitted if the validation state changes
- class psyplot_gui.preferences.GuiRcParamsWidget(*args, **kwargs)[source]
Bases:
RcParamsWidget
The config page for the
psyplot_gui.config.rcsetup.rcParams
Attributes:
the rcParams to use (must be implemented by subclasses)
The title for the config page
- default_path = '/root/.config/psyplot/psyplotguirc.yml'
- rc = {'backend': 'psyplot', 'console.auto_set_mp': True, 'console.auto_set_sp': True, 'console.connect_to_help': True, 'console.start_channels': True, 'content.load_tooltips': True, 'fmt.sort_by_key': True, 'help_explorer.online': None, 'help_explorer.render_docs_parallel': True, 'help_explorer.use_intersphinx': None, 'help_explorer.use_webengineview': True, 'main.listen_to_port': True, 'main.open_files_port': 30124, 'main.opengl': 'software', 'plugins.exclude': [], 'plugins.include': None}
the rcParams to use (must be implemented by subclasses)
- title = 'GUI defaults'
The title for the config page
- class psyplot_gui.preferences.Prefences(main=None)[source]
Bases:
QDialog
Preferences dialog
Methods:
accept
()Reimplement Qt method
add_page
(widget)Add a new page to the preferences dialog
check_changes
(configpage)Enable the apply button if there are changes to the settings
current_page_changed
(index)get_page
([index])Return page widget
Load the rcParams for the plugins in separate pages
set_current_index
(index)Set current page index
Attributes:
- add_page(widget)[source]
Add a new page to the preferences dialog
- Parameters:
widget (ConfigPage) – The page to add
- property bt_apply
- property pages
- class psyplot_gui.preferences.PsyRcParamsWidget(*args, **kwargs)[source]
Bases:
RcParamsWidget
The config page for the
psyplot.config.rcsetup.rcParams
Attributes:
the rcParams to use (must be implemented by subclasses)
The title for the config page
- default_path = '/root/.config/psyplot/psyplotrc.yml'
- rc = {'auto_draw': True, 'auto_show': False, 'colors.cmaps': {}, 'datapath': None, 'decoder.interp_kind': 'linear', 'decoder.t': {'time'}, 'decoder.x': {}, 'decoder.y': {}, 'decoder.z': {}, 'gridweights.use_cdo': None, 'lists.auto_update': True, 'plotter.bar.alpha': 1.0, 'plotter.bar.categorical': None, 'plotter.bar.coord': None, 'plotter.bar.plot': 'bar', 'plotter.bar.widths': 'equal', 'plotter.baseplotter.background': 'rc', 'plotter.baseplotter.figtitle': '', 'plotter.baseplotter.figtitleprops': {}, 'plotter.baseplotter.figtitlesize': 12.0, 'plotter.baseplotter.figtitleweight': None, 'plotter.baseplotter.mask': None, 'plotter.baseplotter.maskbetween': None, 'plotter.baseplotter.maskgeq': None, 'plotter.baseplotter.maskgreater': None, 'plotter.baseplotter.maskleq': None, 'plotter.baseplotter.maskless': None, 'plotter.baseplotter.text': [], 'plotter.baseplotter.tight': False, 'plotter.baseplotter.title': '', 'plotter.baseplotter.titleprops': {}, 'plotter.baseplotter.titlesize': 'large', 'plotter.baseplotter.titleweight': None, 'plotter.combinedsimple.plot': 'mesh', 'plotter.combinedsimple.vbounds': [BoundsMethod.rounded, None, 0.0, 100.0, None, None], 'plotter.combinedsimple.vcbar': {'b'}, 'plotter.combinedsimple.vcbarspacing': 'uniform', 'plotter.combinedsimple.vclabel': '', 'plotter.combinedsimple.vclabelprops': {}, 'plotter.combinedsimple.vclabelsize': 'medium', 'plotter.combinedsimple.vclabelweight': None, 'plotter.combinedsimple.vcmap': 'white_blue_red', 'plotter.combinedsimple.vcticklabels': None, 'plotter.combinedsimple.vctickprops': {}, 'plotter.combinedsimple.vcticks': None, 'plotter.combinedsimple.vcticksize': 'medium', 'plotter.combinedsimple.vctickweight': None, 'plotter.combinedsimple.vplot': 'quiver', 'plotter.density.bins': 10, 'plotter.density.coord': None, 'plotter.density.density': 'hist', 'plotter.density.normed': None, 'plotter.density.precision': 0.0, 'plotter.density.xrange': ('minmax', 'minmax'), 'plotter.density.yrange': ('minmax', 'minmax'), 'plotter.fldmean.err_calc': 'std', 'plotter.fldmean.mean': 'mean', 'plotter.line.coord': None, 'plotter.line.error': 'fill', 'plotter.line.erroralpha': 0.15, 'plotter.line.linewidth': None, 'plotter.line.marker': None, 'plotter.line.markersize': None, 'plotter.line.plot': '-', 'plotter.plot2d.bounds': [BoundsMethod.rounded, None, 0.0, 100.0, None, None], 'plotter.plot2d.cbar': {'b'}, 'plotter.plot2d.cbarspacing': 'uniform', 'plotter.plot2d.clabel': '', 'plotter.plot2d.clabelprops': {}, 'plotter.plot2d.clabelsize': 'medium', 'plotter.plot2d.clabelweight': None, 'plotter.plot2d.cmap': 'white_blue_red', 'plotter.plot2d.cticklabels': None, 'plotter.plot2d.ctickprops': {}, 'plotter.plot2d.cticks': None, 'plotter.plot2d.cticksize': 'medium', 'plotter.plot2d.ctickweight': None, 'plotter.plot2d.datagrid': None, 'plotter.plot2d.extend': 'neither', 'plotter.plot2d.interp_bounds': None, 'plotter.plot2d.levels': None, 'plotter.plot2d.mask_datagrid': True, 'plotter.plot2d.miss_color': None, 'plotter.plot2d.plot': 'mesh', 'plotter.plot2d.plot.min_circle_ratio': 0.05, 'plotter.simple.axiscolor': {'bottom': None, 'left': None, 'right': None, 'top': None}, 'plotter.simple.color': None, 'plotter.simple.grid': False, 'plotter.simple.labelprops': {'x': {}, 'y': {}}, 'plotter.simple.labelsize': {'x': 'medium', 'y': 'medium'}, 'plotter.simple.labelweight': {'x': None, 'y': None}, 'plotter.simple.legend': {'loc': 1}, 'plotter.simple.legendlabels': '%(arr_name)s', 'plotter.simple.sym_lims': [None, None], 'plotter.simple.ticksize': {'major': 'medium'}, 'plotter.simple.tickweight': {'major': None}, 'plotter.simple.transpose': False, 'plotter.simple.xlabel': '', 'plotter.simple.xlim': ('rounded', 'rounded'), 'plotter.simple.xrotation': 0.0, 'plotter.simple.xticklabels': {'major': None}, 'plotter.simple.xtickprops': {'major': {}, 'minor': {}}, 'plotter.simple.xticks': {'major': None, 'minor': None}, 'plotter.simple.ylabel': '', 'plotter.simple.ylim': ('rounded', 'rounded'), 'plotter.simple.yrotation': 0.0, 'plotter.simple.yticklabels': {'major': None}, 'plotter.simple.ytickprops': {'major': {}, 'minor': {}}, 'plotter.simple.yticks': {'major': None, 'minor': None}, 'plotter.user': {}, 'plotter.vector.arrowsize': None, 'plotter.vector.arrowstyle': '-|>', 'plotter.vector.color': 'k', 'plotter.vector.density': 1.0, 'plotter.vector.linewidth': None, 'plotter.vector.plot': 'quiver', 'plotter.violin.plot': True, 'presets.trusted': [], 'project.auto_import': False, 'project.import_seaborn': None, 'project.plotters': {'barplot': {'default_slice': None, 'module': 'psy_simple.plotters', 'plotter_name': 'BarPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': True, 'summary': 'Make a bar plot of one-dimensional data'}, 'combined': {'default_dims': {'x': slice(None, None, None), 'y': slice(None, None, None)}, 'default_slice': 0, 'example_call': "filename, name=[['my_variable', ['u_var', 'v_var']]], ...", 'module': 'psy_simple.plotters', 'plotter_name': 'CombinedSimplePlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': True, 'summary': 'Plot a 2D scalar field with an overlying vector field'}, 'density': {'default_slice': None, 'module': 'psy_simple.plotters', 'plotter_name': 'DensityPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': False, 'summary': 'Make a density plot of point data'}, 'fldmean': {'default_slice': None, 'module': 'psy_simple.plotters', 'plotter_name': 'FldmeanPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': True, 'summary': 'Calculate and plot the mean over x- and y-dimensions'}, 'lineplot': {'default_slice': None, 'module': 'psy_simple.plotters', 'plotter_name': 'LinePlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': True, 'summary': 'Make a line plot of one-dimensional data'}, 'plot2d': {'default_dims': {'x': slice(None, None, None), 'y': slice(None, None, None)}, 'default_slice': 0, 'module': 'psy_simple.plotters', 'plotter_name': 'Simple2DPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': False, 'summary': 'Make a simple plot of a 2D scalar field'}, 'simple': {'module': 'psy_simple.plotters', 'plot_func': False, 'plotter_name': 'SimplePlotterBase', 'plugin': 'psy_simple.plugin', 'summary': 'All plotters that are visualized by the psy-simple package'}, 'vector': {'default_dims': {'x': slice(None, None, None), 'y': slice(None, None, None)}, 'default_slice': 0, 'example_call': "filename, name=[['u_var', 'v_var']], ...", 'module': 'psy_simple.plotters', 'plotter_name': 'SimpleVectorPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': False, 'summary': 'Make a simple plot of a 2D vector field'}, 'violinplot': {'default_slice': None, 'module': 'psy_simple.plotters', 'plotter_name': 'ViolinPlotter', 'plugin': 'psy_simple.plugin', 'prefer_list': True, 'summary': 'Make a violin plot of your data'}}, 'project.plotters.user': {}, 'texts.default_position': [1.0, 1.0], 'texts.delimiter': ', ', 'texts.labels': {'desc': '%(long_name)s [%(units)s]', 'dinfo': '%B %d, %Y', 'dtinfo': '%B %d, %Y. %H:%M', 'sdesc': '%(name)s [%(units)s]', 'tinfo': '%H:%M'}, 'ticks.which': 'major', 'widgets.colors.cmaps': ['viridis', 'Reds', 'Blues', 'Greens', 'binary', 'RdBu', 'coolwarm', 'red_white_blue', 'winter', 'jet', 'white_blue_red', 'gist_ncar', 'gist_earth', 'Paired', 'gnuplot', 'gnuplot2']}
the rcParams to use (must be implemented by subclasses)
- title = 'psyplot defaults'
The title for the config page
- class psyplot_gui.preferences.RcParamsTree(rcParams, validators, descriptions, *args, **kwargs)[source]
Bases:
QTreeWidget
A QTreeWidget that can be used to display a RcParams instance
This widget is populated by a
psyplot.config.rcsetup.RcParams
instance and displays whether the values are valid or notMethods:
Update the
rc
with the proposed changeschanged_rc
([use_items])Iterate over the changed rcParams
Fill the items of the
rc
into the treeopen_menu
(position)Open a menu to expand and collapse all items in the tree
Select all the items that changed comparing to the current rcParams
selected_rc
([use_items])Iterate over the selected rcParams
set_icon_func
(i, item, validator)Create a function to change the icon of one topLevelItem
set_valid
(i, b)Set the validation status
Attributes:
True if all the proposed values in this tree are valid
propose_changes
(*args, **kwargs)A signal that is emitted if changes are propsed.
The
RcParams
to displayAn iterator over the topLevelItems in this tree
list of
bool
.validChanged
(*args, **kwargs)A signal that shall be emitted if the validation state changes
- changed_rc(use_items=False)[source]
Iterate over the changed rcParams
- Parameters:
use_items (bool) – If True, the topLevelItems are used instead of the keys
- Yields:
QTreeWidgetItem or str – The item identifier
object – The proposed value
- property is_valid
True if all the proposed values in this tree are valid
Open a menu to expand and collapse all items in the tree
- Parameters:
position (QPosition) – The position where to open the menu
- propose_changes(*args, **kwargs)
A signal that is emitted if changes are propsed. It is either emitted with the parent of this instance (if this is not None) or with the instance itself
- selected_rc(use_items=False)[source]
Iterate over the selected rcParams
- Parameters:
use_items (bool) – If True, the topLevelItems are used instead of the keys
- Yields:
QTreeWidgetItem or str – The item identifier
object – The proposed value
- set_icon_func(i, item, validator)[source]
Create a function to change the icon of one topLevelItem
This method creates a function that can be called when the value of an item changes to display it’s valid state. The returned function changes the icon of the given topLevelItem depending on whether the proposed changes are valid or not and it modifies the
valid
attribute accordingly- Parameters:
i (int) – The index of the topLevelItem
item (QTreeWidgetItem) – The topLevelItem
validator (func) – The validation function
- Returns:
The function that can be called to set the correct icon
- Return type:
function
- set_valid(i, b)[source]
Set the validation status
If the validation status changed compared to the old one, the
validChanged
signal is emitted
- property top_level_items
An iterator over the topLevelItems in this tree
- valid = []
list of
bool
. A boolean for each rcParams key that states whether the proposed value is valid or not
- validChanged(*args, **kwargs)
A signal that shall be emitted if the validation state changes
- value_col = 2
- class psyplot_gui.preferences.RcParamsWidget(*args, **kwargs)[source]
Bases:
ConfigPage
,QWidget
A configuration page for RcParams instances
This page displays the
psyplot.config.rcsetup.RcParams
instance in therc
attribute and let’s the user modify it.Notes
After the initialization, you have to call the
initialize()
methodMethods:
Apply the changes in the config page
initialize
([rcParams, validators, descriptions])Initialize the config page
save_settings_action
([update, target])Create an action to save the selected settings in the
tree
Attributes:
True if any changes are proposed by this config page
The icon of this instance in the
Preferences
dialogTrue if all the settings are valid
A signal that is emitted if the user changes the values in the rcParams
the rcParams to use (must be implemented by subclasses)
the
RcParamsTree
that is used to display the rcParamsA signal that is emitted if the user changes the valid state of this page
- property changed
True if any changes are proposed by this config page
- property icon
The icon of this instance in the
Preferences
dialog
- initialize(rcParams=None, validators=None, descriptions=None)[source]
Initialize the config page
- Parameters:
rcParams (dict) – The rcParams to use. If None, the
rc
attribute of this instance is usedvalidators (dict) – A mapping from the rcParams key to the corresponding validation function for the value. If None, the
validate
attribute of therc
attribute is useddescriptions (dict) – A mapping from the rcParams key to it’s description. If None, the
descriptions
attribute of therc
attribute is used
- property is_valid
True if all the settings are valid
- property propose_changes
A signal that is emitted if the user changes the values in the rcParams
- rc = None
the rcParams to use (must be implemented by subclasses)
- save_settings_action(update=False, target=None)[source]
Create an action to save the selected settings in the
tree
- Parameters:
update (bool) – If True, it is expected that the file already exists and it will be updated. Otherwise, existing files will be overwritten
- tree = None
the
RcParamsTree
that is used to display the rcParams
- property validChanged
A signal that is emitted if the user changes the valid state of this page