doc:appunti:prog:kivy
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:prog:kivy [2023/10/06 11:04] – [Logging] niccolo | doc:appunti:prog:kivy [2025/11/30 11:04] (current) – [Config and Settings] niccolo | ||
|---|---|---|---|
| Line 149: | Line 149: | ||
| < | < | ||
| / | / | ||
| + | </ | ||
| + | |||
| + | In older Android versions (e.g. Android 8) the app home directory will be something like: | ||
| + | |||
| + | < | ||
| + | / | ||
| </ | </ | ||
| Every time that the Kivy environment is initializated, | Every time that the Kivy environment is initializated, | ||
| + | |||
| + | ===== The Settings module and Clipboard problem ===== | ||
| + | |||
| + | Importing **Settings** or **SettingsWithNoMenu** from the **kivy.uix.settings** module, you may get the following error when editing a string option: | ||
| + | |||
| + | < | ||
| + | [INFO | ||
| + | ' | ||
| + | [CRITICAL] [Cutbuffer] Unable to find any valuable Cutbuffer provider. Please enable debug | ||
| + | | ||
| + | log level in the config) and re-run your app to identify potential | ||
| + | | ||
| + | </ | ||
| + | |||
| + | In Linux/X11 environment you have to install the **xclip** and **xsel** packages. In Android the error is displayed, but the program continues. | ||
| + | |||
| + | ===== Config and Settings ===== | ||
| + | |||
| + | To build a complete config system including default values, persisten configuration file and a setting screen, you can import the following modules: | ||
| + | |||
| + | <code python> | ||
| + | from kivy.config import Config | ||
| + | from kivy.uix.settings import Settings, SettingsWithNoMenu | ||
| + | </ | ||
| + | |||
| + | Suppose that the **App** has two **Screen** objects, one called // | ||
| + | |||
| + | - App.build_config(self, | ||
| + | - App.build(self) | ||
| + | - MenuScreen.on_pre_enter(self) | ||
| + | - App.build_settings(self, | ||
| + | - App.on_start(self) | ||
| + | |||
| + | The '' | ||
| + | |||
| + | The '' | ||
| + | |||
| + | In this way, when the '' | ||
| + | |||
| + | <code python> | ||
| + | self.config.getint(' | ||
| + | </ | ||
| + | |||
| + | Outside the App scope, it is possibile to access the config in this way: | ||
| + | |||
| + | <code python> | ||
| + | app = App.get_running_app() | ||
| + | app.config.getint(' | ||
| + | </ | ||
| + | |||
| + | When the user enters the // | ||
| + | |||
| + | * App.on_config_change() | ||
| + | |||
| + | This function should call esplicitly the '' | ||
doc/appunti/prog/kivy.1696583085.txt.gz · Last modified: by niccolo
