User Tools

Site Tools


doc:appunti:prog:kivy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:prog:kivy [2025/11/30 10:05] – [The Settings module and Clipboard problem] niccolodoc:appunti:prog:kivy [2025/11/30 11:04] (current) – [Config and Settings] niccolo
Line 186: Line 186:
 Suppose that the **App** has two **Screen** objects, one called //MenuScreen// which is the main interface and one called **SettingsScreen** which allows the user to change the settings; several methods of the main App will be called automatically in this order: Suppose that the **App** has two **Screen** objects, one called //MenuScreen// which is the main interface and one called **SettingsScreen** which allows the user to change the settings; several methods of the main App will be called automatically in this order:
  
-  - App.build_config() +  - App.build_config(self, config
-  - App.build() +  - App.build(self
-  - MenuScreen.on_pre_enter() +  - MenuScreen.on_pre_enter(self
-  - App.build_settings() +  - App.build_settings(self, settings
-  - App.on_start()+  - App.on_start(self)
  
-The ''build_config()'' will explicitly execute ''config.setdefaults()'', which implicitly will execute a ''config.read()'' if the configuration file **my.ini** exists.+The ''build_config()'' should explicitly execute ''config.setdefaults()'', which implicitly will execute a ''config.read()'' if the configuration file **app_name.ini** exists. The name of the file is derived from the App instance name, e.g. if the class is named MyApp, the file will be called **my.ini**.
  
-The ''build()'' generally will execute the ''self.create_settings()'' which automatically launches ''build_settings()'', which in turn should call explicitly the ''settings.add_json_panel()'' function.+The ''build()'' should generally execute the ''self.create_settings()'' which automatically launches ''build_settings()'', which in turn should call explicitly the ''settings.add_json_panel()'' function.
  
-In this way, when the ''on_start()'' finally executes, the App can get or set config values:+In this way, when the ''on_start()'' finally executes, the App can get or set config values using the **self.config** object, automatically instantiated:
  
 <code python> <code python>
Line 209: Line 209:
 </code> </code>
  
-When the user enter the //SettingsScreen// and change some values, this function is called automatically:+When the user enters the //SettingsScreen// and changes some options, this function is called automatically:
  
   * App.on_config_change()   * App.on_config_change()
  
-In this function it should be called esplicitly the ''self.config.write()'', which is not handled automatically in every circumstances (e.g. backgrounding an Android app).+This function should call esplicitly the ''self.config.write()'', which is not handled automatically in every circumstances (e.g. if the app crashes, etc.). The config.write() is called automatically only on graceful app shutdown, only if the app detects a config change, etc. So better to stay safe and call it explicitly on config change. 
  
doc/appunti/prog/kivy.1764493540.txt.gz · Last modified: by niccolo