traits.etsconfig Package

Supports sharing settings across projects or programs on the same system. Part of the EnthoughtBase project.

traits.etsconfig.etsconfig Module

Enthought Tool Suite configuration information.

class traits.etsconfig.etsconfig.ETSConfigType[source]

Enthought Tool Suite configuration information.

Instances of this class record state useful for ETS-using applications, including the current GUI toolkit in use, and data and home directory setttings.

Users typically shouldn’t make use of this class directly. Instead, use the module-level ETSConfig instance of this class, which is shared between the various ETS packages.

get_application_data(create=False)[source]

Return the application data directory path.

Parameters:

create (bool) – Create the corresponding directory or not.

Notes

  • This is a directory that applications and packages can safely write non-user accessible data to i.e. configuration information, preferences etc.

  • Do not put anything in here that the user might want to navigate to e.g. projects, user data files etc.

  • The actual location differs between operating systems.

property application_data

Property getter, see get_application_data’s docstring.

get_application_home(create=False)[source]

Return the application home directory path.

Parameters:

create (bool) – Create the corresponding directory or not.

Note

  • This is a directory named after the current, running application that imported this module that applications and packages can safely write non-user accessible data to i.e. configuration information, preferences etc. It is a sub-directory of self.application_data, named after the directory that contains the “main” python script that started the process. For example, if application foo is started with a script named “run.py” in a directory named “foo”, then the application home would be: <ETSConfig.application_data>/foo, regardless of if it was launched with “python <path_to_foo>/run.py” or “cd <path_to_foo>; python run.py”

  • This is useful for library modules used in apps that need to store state, preferences, etc. for the specific app only, and not for all apps which use that library module. If the library module uses ETSConfig.application_home, they can store prefs for the app all in one place and do not need to know the details of where each app might reside.

  • Do not put anything in here that the user might want to navigate to e.g. projects, user home files etc.

  • The actual location differs between operating systems.

property application_home

Property getter, see get_application_home’s docstring.

property company

Property getter.

provisional_toolkit(toolkit)[source]

Perform an operation with toolkit provisionally set

This sets the toolkit attribute of the ETSConfig object to the provided value. If the operation fails with an exception, the toolkit is reset to nothing.

This method should only be called if the toolkit is not currently set.

Parameters:

toolkit (string) – The name of the toolkit to provisionally use.

Raises:

ETSToolkitError – If the toolkit attribute is already set, then an ETSToolkitError will be raised when entering the context manager.

property toolkit

Property getter for the GUI toolkit. The value returned is, in order of preference: the value set by the application; the value specified by the ‘ETS_TOOLKIT’ environment variable; otherwise the empty string.

property enable_toolkit

This property is no longer used.

Property getter for the Enable backend. The value returned is, in order of preference: the value set by the application; the value specified by the ‘ENABLE_TOOLKIT’ environment variable; otherwise the empty string.

Type:

Deprecated

property kiva_backend

Property getter for the Kiva backend. The value returned is dependent on the value of the toolkit property. If toolkit specifies a kiva backend using the extended syntax: <enable toolkit>[.<kiva backend>] then the value of the property will be whatever was specified. Otherwise the value will be a reasonable default for the given enable backend.

property user_data

Property getter.

This is a directory that users can safely write user accessible data to i.e. user-defined functions, edited functions, etc.

The actual location differs between operating systems.

traits.etsconfig.etsconfig.ETSConfig = <traits.etsconfig.etsconfig.ETSConfigType object>

This single instance of ETSConfigType is shared between the various ETS packages, and used to store global state relevant to ETS-using applications.

See https://github.com/enthought/traits/discussions/1666 for a discussion of writing tests that depend on ETSConfig state.