From ca4dfea0af6c34de399a26d334c24bbaddc80f75 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 29 Oct 2012 16:14:28 +0100 Subject: [PATCH] settings: add Settings.create_json_panel(), and use it in Settings.add_json_panel() --- kivy/uix/settings.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/kivy/uix/settings.py b/kivy/uix/settings.py index ee7a0febb..c342f837d 100644 --- a/kivy/uix/settings.py +++ b/kivy/uix/settings.py @@ -654,12 +654,12 @@ class Settings(BoxLayout): ''' self._types[tp] = cls - def add_json_panel(self, title, config, filename=None, data=None): - '''Create and add a new :class:`SettingsPanel` using the configuration - `config`, with the JSON definition `filename`. + def create_json_panel(self, title, config, filename=None, data=None): + '''Create new :class:`SettingsPanel`. - Check the :ref:`settings_json` section in the documentation for more - information about JSON format, and the usage of this function. + .. versionadded:: 1.5.0 + + Check the documentation of :meth:`add_json_panel` for more information. ''' if filename is None and data is None: raise Exception('You must specify either the filename or data') @@ -671,7 +671,6 @@ class Settings(BoxLayout): if type(data) != list: raise ValueError('The first element must be a list') panel = SettingsPanel(title=title, settings=self, config=config) - self.add_widget(panel) for setting in data: # determine the type and the class to use @@ -696,6 +695,16 @@ class Settings(BoxLayout): return panel + def add_json_panel(self, title, config, filename=None, data=None): + '''Create and add a new :class:`SettingsPanel` using the configuration + `config`, with the JSON definition `filename`. + + Check the :ref:`settings_json` section in the documentation for more + information about JSON format, and the usage of this function. + ''' + panel = self.create_json_panel(title, config, filename, data) + self.add_widget(panel) + def add_kivy_panel(self): '''Add a panel for configuring Kivy. This panel acts directly on the kivy configuration. Feel free to include or exclude it in your