예제 #1
0
    def __init__(self, *args, **kwargs):
        self.callback = kwargs.pop("callback", None)
        self.pages = kwargs.pop("pages",
                                ["general", "synchronisation", "kivy"])
        self.title = "Paramètres"
        self.size_hint = (0.9, 0.9)

        config = ConfigParser()
        config.read(os.path.join(UTILS_Divers.GetRepData(), "config.cfg"))

        self.settings = Settings()
        self.settings.register_type('password', SettingPassword)
        self.settings.register_type('chaine', SettingChaine)

        if "general" in self.pages:
            self.settings.add_json_panel("Généralités",
                                         config,
                                         data=json.dumps(JSON_GENERAL))
        if "synchronisation" in self.pages:
            self.settings.add_json_panel("Synchronisation",
                                         config,
                                         data=json.dumps(JSON_SYNCHRONISATION))
        if "kivy" in self.pages: self.settings.add_kivy_panel()

        self.settings.interface.menu.close_button.text = "Fermer"

        self.content = self.settings
        self.settings.bind(on_close=self.OnBoutonFermer)
        self.bind(on_dismiss=self.on_dismiss)
        super(Popup, self).__init__(*args, **kwargs)
예제 #2
0
    def generate_settings(self):

        settings_panel = Settings() #create instance of Settings

#        def add_one_panel(from_instance):
#            panel = SettingsPanel(title="I like trains", settings=self)
#            panel.add_widget(AsyncImage(source="http://i3.kym-cdn.com/entries/icons/original/000/004/795/I-LIKE-TRAINS.jpg"))
#            settings_panel.add_widget(panel)
#            print "Hello World from ", from_instance

        panel = SettingsPanel(title="Engine") #create instance of left side panel
        item1 = SettingItem(panel=panel, title="Board") #create instance of one item in left side panel
        item2 = SettingItem(panel=panel, title="Level") #create instance of one item in left side panel

    #        item2 = SettingTitle(title="Level") #another widget in left side panel
#        button = Button(text="Add one more panel")

#        item1.add_widget(button) #add widget to item1 in left side panel
#        button.bind(on_release=add_one_panel) #bind that button to function

        panel.add_widget(item1) # add item1 to left side panel
        panel.add_widget(item2) # add item2 to left side panel
        settings_panel.add_widget(panel) #add left side panel itself to the settings menu
        def go_back():
            self.root.current = 'main'
        settings_panel.on_close=go_back

        return settings_panel # show the settings interface
예제 #3
0
class TestApp(App):
    def build_settings(self, settings):
        self.config = ConfigParser()
        self.settings = Settings()
        self.settings.add_json_panel('Preferences', self.config, data=SETTINGS)

    def build(self):
        return sm
예제 #4
0
class TestApp(App):
    def build_settings(self, settings):
        self.config = ConfigParser()
        self.settings = Settings()
        self.settings.add_json_panel('Preferences', self.config, data=SETTINGS)

    def build(self):
        return sm
예제 #5
0
파일: main.py 프로젝트: btrent/qflash
    def generate_settings(self):
        config = ConfigParser()
        if not config.has_section("root"):
            self.build_config(config)

        settings_panel = Settings() #create instance of Settings
        settings_panel.add_json_panel('QFlash Settings', config, 'settings.json')

        return settings_panel # show the settings interface
예제 #6
0
 def build(self):
     self.config.read(self.get_application_config())
     h = Home()
     th = TabbedPanelHeader(text='Settings')
     h.add_widget(th)
     sett = Settings()
     th.content = sett.create_json_panel('Fractal Entropy',
                                         self.config,
                                         data=mysettings.json)
     return h
예제 #7
0
    def build_settings(self, settings: Settings) -> None:
        """Builds and adds custom setting pannels to original settings,
        called when the user open settings for the first time.

        [requires]: isinstance(self.config, kivy.config.Config)
                    [see [ensures] of build_config]
        """
        if not asserts(isinstance(self.config, ConfigParser),
                       "self.config is not initialized."):
            return
        settings.add_json_panel("Sira", self.config, filename="res/sira.json")
        settings.add_json_panel("Jira", self.config, filename="res/jira.json")
예제 #8
0
    def ConfigDownLoadSettings(self, *,
                               oSetting: KivySettings) -> KivySettings:
        """  Creates the settings tab for download """
        self.oSetting = oSetting
        self.bForce = False
        uSettingsJSONResources: str = u'[{"type": "title","title": "$lvar(694)" },\n'
        iNumber: int = 0
        uURL: str
        uSubRep: str

        RegisterSettingTypes(oSetting)

        for uURL in Globals.aRepositories:
            if not uURL == '':
                uSettingsJSONResources += u'{"type": "bool","title": "$lvar(695) %s","desc": "%s","section": "ORCA","key": "repository_state%s"},\n' % (
                    str(iNumber), uURL, str(iNumber))
            iNumber += 1

        uSettingsJSONResources += u'{"type": "buttons","title": "$lvar(696)","desc": "$lvar(697)","section": "ORCA","key": "button_load_resources","buttons":[{"title":"$lvar(5016)","id":"button_load_resources"}]}]\n'

        aSubList2: List = sorted(oRepository.aRepEntries,
                                 key=lambda entry: entry.uName)

        for uSubRep in self.aSubReps:
            aSubList = [
                oEntry for oEntry in aSubList2 if oEntry.uRepType == uSubRep[1]
            ]
            if len(aSubList) > 0:
                uSettingsJSON = u'['
                for oEntry in aSubList:
                    uDescription: str = ''
                    if len(oEntry.oDescriptions.dDescriptions) > 0:
                        uDescription = oEntry.oDescriptions.dDescriptions.get(
                            Globals.uLanguage)
                        if uDescription is None:
                            uDescription = oEntry.oDescriptions.dDescriptions.get(
                                'English')
                        if uDescription is None:
                            for uKey in oEntry.oDescriptions.dDescriptions:
                                uDescription = oEntry.oDescriptions.dDescriptions[
                                    uKey]
                                break
                    uSettingsJSON += u'{"type": "buttons","title": "%s ","desc": "%s %s:%s","section": "ORCA","key": "button_add_resource","buttons":[{"title":"$lvar(5016)","id":"button:%s:%s"}]},' % (
                        oEntry.uName, uDescription, '$lvar(673)',
                        oEntry.uVersion, uSubRep[1], oEntry.uName)
                uSettingsJSON: str = uSettingsJSON[:-1] + u']'
                oSetting.add_json_panel(ReplaceVars(uSubRep[0]),
                                        None,
                                        data=ReplaceVars(uSettingsJSON))

        oSetting.add_json_panel("Resources",
                                Globals.oOrcaConfigParser,
                                data=ReplaceVars(uSettingsJSONResources))
        oSetting.bind(on_close=self.On_SettingsClose)
        oSetting.bind(on_config_change=self.On_ConfigChange)

        return oSetting
예제 #9
0
 def test_build_settings(self):
     config = ConfigParser()
     self.app.build_config(config)
     reglages = Settings()
     self.app.build_settings(reglages)
     panels = reglages.children[0].content.panels
     for panel in SETTING_PANELS:
         assert any(p.title == panel[0] for p in panels.values())
예제 #10
0
파일: app.py 프로젝트: edthedev/kivy
 def _create_settings(self):
     from kivy.uix.settings import Settings
     if self._app_settings is None:
         self._app_settings = s = Settings()
         self.build_settings(s)
         if self.use_kivy_settings:
             s.add_kivy_panel()
         s.bind(on_close=self.close_settings,
                on_config_change=self._on_config_change)
     return self._app_settings
예제 #11
0
def _setup_panel(settings: Settings, section_name: str,
                 panel_options: List[Dict[str, Any]]):
    processed_options = []

    for option in panel_options:
        processed_options.append(
            {k: option[k]
             for k in _ORIGINAL_KEYS_KEYS if k in option})

        if "section" not in option or "key" not in option:
            continue

        assert option["section"] == section_name

        _OPTION_BY_KEY[(section_name, option["key"])] = option

    settings.add_json_panel("Light Controls",
                            Config,
                            data=json.dumps(processed_options))
예제 #12
0
 def settings_func(self, p):
     s = Settings()
     config = ConfigParser()
     try:
         config.setdefaults('EVM', {'school': self.school, 'names': self.temp, 'post': self.post, 'p_col': self.color, 'im_path': self.im_path, "code1": self.code1, "code2": self.code2, 'number':self.number})
     except:
         config.setdefaults('EVM', {'school': 'Unknown', 'names': self.temp, 'post': "Unknown", 'p_col': 'FFFFFF', 'im_path': self.im_path, "code1": "voting", "code2": "results", 'number':self.number})
     s.add_json_panel('EVM', config, data = self.json)
     s.bind(on_config_change = self.settings_change)
     setting = Popup(title = "Settings", content = s)
     s.bind(on_close = lambda *func: self.save_settings(s))
     setting.open()
예제 #13
0
    def build(self):
        Window.clearcolor = (228. / 255., 228. / 255., 228. / 255., 1)
        self.title = "GrunwaldCalc"

        Window.minimum_width = 300
        Window.minimum_height = 200

        self.config = ConfigParser()
        self.config.read("config.ini")
        self.config.adddefaultsection("Settings")

        self.config.setdefault("Settings", "Language",
                               locale.getdefaultlocale()[0])
        self.language = self.config.getdefault("Settings", "Language",
                                               locale.getdefaultlocale()[0])
        self.settings = Settings()
        self.day_calc = DayCalc.Calculate()
        self.date_finder = DateFinder.WikiScrape()
        self.day_calc.changeLanguage(self.language)
        self.date_finder.changeLanguage(self.language)
        self.container = BoxLayout(orientation="vertical")
        self.search_layout = BoxLayout(orientation="horizontal",
                                       size_hint=(1, 0.25),
                                       height=100)
        self.results_layout = AnchorLayout(anchor_y="top")
        self.container.add_widget(self.search_layout)
        self.container.add_widget(self.results_layout)

        try:
            with open("./languages/" + self.language + ".lang",
                      encoding="UTF-8") as language_file:
                self.language_file = json.load(language_file)
        except FileNotFoundError:
            self.language = "en_US"
            with open("./languages/" + self.language + ".lang",
                      encoding="UTF-8") as language_file:
                self.language_file = json.load(language_file)

        self.search_box = TextInput(hint_text=(self.language_file["hint"]),
                                    size_hint=(0.7, None),
                                    height=50,
                                    multiline=False)
        self.search_button = Button(text=self.language_file["button-text"],
                                    size_hint=(0.3, None),
                                    height=50)
        self.search_layout.add_widget(self.search_box)
        self.search_layout.add_widget(self.search_button)

        self.search_box.bind(on_text_validate=self.start_main)
        self.search_button.bind(on_press=self.start_main)

        return self.container
예제 #14
0
파일: t4app.py 프로젝트: ww4u/t4app-kivy
    def build(self):

        self.frame = MainFrame()
        self._trash_can = self.frame.ids.sm.screens[
            0].ids.rightborder.ids.trash_can

        parser = ConfigParser()
        parser.read("jointbtn.ini")

        # parser.

        self._cfg = parser

        s = Settings()
        s.add_json_panel('config', parser, data=config_json)
        s.on_close = partial(self.on_screen_n, 'script', 0)

        self.frame.ids.sm.screens[1].add_widget(s)

        self.coord = 'Both'

        return self.frame
예제 #15
0
파일: main.py 프로젝트: bulli92/mytrip
    def draw(self):

        config = self.update()

        #--- specify settings screen from file
        self.settings = Settings()
        self.settings.add_json_panel('Settings', config, filename='setting_market.json') #todo: do not read this from file, but from string

        #--- add widget ---
        self.add_widget(self.settings)

        btn_close = self.settings.children[1].children[0] #todo this is not so good if it is hardwired like this!
        btn_close.bind(on_press=self.close)
예제 #16
0
파일: main.py 프로젝트: sunetos/fetcher
  def show_settings(self):
    self.settings = Settings()
    self.settings.add_json_panel('put.io', self.config, data=self.settings_json)
    self.resize(640, 250)
    self.settings.remove_widget(self.settings.menu)
    self.root.add_widget(self.settings)

    def on_close(wgt):
      self.apply_config()
      self.root.remove_widget(self.settings)
      self.settings = None
      self.autosize()

    self.settings.bind(on_close=on_close)
예제 #17
0
파일: main.py 프로젝트: Arias800/exode
    def __init__(self, **kwargs):
        super(ListParam, self).__init__(**kwargs)

        from kivy.uix.settings import Settings, SettingsWithSpinner, SettingsPanel
        from kivy.config import ConfigParser

        print("parammmmmmmm")

        #json param
        #graphics
        conf_graphics = [
            #{"type": "title", "title": "Windows"},
            {
                "type": "bool",
                "title": "Fullscreen",
                "desc": "Set the window in windowed or fullscreen",
                "section": "graphics",
                "key": "fullscreen"
            }
        ]

        #theme
        conf_theme = [{
            "type": "options",
            "title": "Style",
            "desc": "Style des fenêtres",
            "section": "theme",
            "key": "Style",
            'options': ['Light', 'Dark']
        }, {
            "type":
            "options",
            "title":
            "Palette",
            "desc":
            "Couleurs des fenêtres",
            "section":
            "theme",
            "key":
            "Palette",
            'options': [
                "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue",
                "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime",
                "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Gray",
                "BlueGray"
            ]
        }]

        config = ConfigParser()
        config.read('config.ini')

        s = Settings()
        #s.add_json_panel('My custom panel', config, 'settings_custom.json')
        #s.add_json_panel('Another panel', config, 'settings_test2.json')
        s.add_json_panel('Graphics', config, data=json.dumps(conf_graphics))
        s.add_json_panel('Theme', config, data=json.dumps(conf_theme))
        self.ids.grid_id.add_widget(s)
예제 #18
0
    def ConfigureKivySettingsForDiscoverParameter(
            self, oKivySetting: KivySettings,
            uConfigName: str) -> Union[KivyConfigParser, None]:
        """
        Create the JSON string for all discover scripts and applies it to a kivy settings object

        :param setting oKivySetting:
        :param string uConfigName:
        :return: The KivySetting object
        """

        uSettingsJSON: str
        uKey: str
        uDictKey: str

        SetVar(uVarName=u'ObjectConfigSection', oVarValue=uConfigName)
        self.uConfigName = uConfigName
        RegisterSettingTypes(oKivySetting)
        oSetting: cBaseInterFaceSettings = self.oInterFace.GetSettingObjectForConfigName(
            uConfigName=uConfigName)
        dSettingsJSON: Dict[str, Dict] = self.CreateSettingJsonCombined(
            oSetting=oSetting)
        if len(dSettingsJSON) == 0:
            return None
            # return self.On_SettingsClose(None)

        # add the jSon to the Kivy Setting

        dTarget: Dict[str, Dict] = {}
        for uKey in dSettingsJSON:
            uDictKey = dSettingsJSON[uKey]['scriptsection']
            if dTarget.get(uDictKey) is None:
                dTarget[uDictKey] = {}
            dTarget[uDictKey][uKey] = dSettingsJSON[uKey]

        for uKey in dTarget:
            if not uKey.startswith('discover'):
                uSettingsJSON = SettingDictToString2(dTarget[uKey])
                uSettingsJSON = ReplaceVars(uSettingsJSON)
                if uSettingsJSON != u'[]':
                    oKivySetting.add_json_panel(ReplaceVars(uKey),
                                                self.oConfigParser,
                                                data=uSettingsJSON)

        for uKey in dTarget:
            if uKey.startswith('discover'):
                if uKey in GetVar("DISCOVERSCRIPTLIST"):
                    uSettingsJSON = SettingDictToString2(dTarget[uKey])
                    uSettingsJSON = ReplaceVars(uSettingsJSON)
                    if uSettingsJSON != u'[]':
                        oKivySetting.add_json_panel(uKey[9:].upper(),
                                                    self.oConfigParser,
                                                    data=uSettingsJSON)

        # Adds the action handler
        oKivySetting.bind(on_config_change=self.On_ConfigChange)
        return oKivySetting
예제 #19
0
    def on_enter(self):
        root = App.get_running_app().root

        s = Settings(on_close=self.close)

        s.add_json_panel('Network', root.config, 'panels/network.json')
        s.add_json_panel('Stream', root.config, 'panels/stream.json')

        self.add_widget(s)
예제 #20
0
    def generate_settings(self):

        settings_panel = Settings()  #create instance of Settings

        #        def add_one_panel(from_instance):
        #            panel = SettingsPanel(title="I like trains", settings=self)
        #            panel.add_widget(AsyncImage(source="http://i3.kym-cdn.com/entries/icons/original/000/004/795/I-LIKE-TRAINS.jpg"))
        #            settings_panel.add_widget(panel)
        #            print "Hello World from ", from_instance

        panel = SettingsPanel(
            title="Engine")  #create instance of left side panel
        item1 = SettingItem(
            panel=panel,
            title="Board")  #create instance of one item in left side panel
        item2 = SettingItem(
            panel=panel,
            title="Level")  #create instance of one item in left side panel

        #        item2 = SettingTitle(title="Level") #another widget in left side panel
        #        button = Button(text="Add one more panel")

        #        item1.add_widget(button) #add widget to item1 in left side panel
        #        button.bind(on_release=add_one_panel) #bind that button to function

        panel.add_widget(item1)  # add item1 to left side panel
        panel.add_widget(item2)  # add item2 to left side panel
        settings_panel.add_widget(
            panel)  #add left side panel itself to the settings menu

        def go_back():
            self.root.current = 'main'

        settings_panel.on_close = go_back

        return settings_panel  # show the settings interface
예제 #21
0
파일: main.py 프로젝트: bulli92/mytrip
    def draw(self):

        config = self.update()

        #--- specify settings screen from file
        self.settings = Settings()
        self.settings.add_json_panel('Settings', config, filename='setting_place.json') #todo: do not read this from file, but from string

        cat_widget = self._get_category_widget()
        cat_widget.options = self._get_catname_list() #get list of category names from DB

        #--- add widget ---
        self.add_widget(self.settings)

        btn_close = self.settings.children[1].children[0] #todo this is not so good if it is hardwired like this!
        btn_close.bind(on_press=self.close)
예제 #22
0
    def __init__(self, *args, **kwargs):
        self.callback = kwargs.pop("callback", None)
        self.pages = kwargs.pop("pages", ["general", "synchronisation", "kivy"])
        self.title = "Paramètres"
        self.size_hint = (0.9, 0.9)
        
        config = ConfigParser()
        config.read(UTILS_Divers.GetRepData() + "config.cfg")

        self.settings = Settings()
        self.settings.register_type('password', SettingPassword)
        self.settings.register_type('chaine', SettingChaine)
        
        if "general" in self.pages : self.settings.add_json_panel("Généralités", config, data=json.dumps(JSON_GENERAL, encoding="utf-8"))
        if "synchronisation" in self.pages : self.settings.add_json_panel("Synchronisation", config, data=json.dumps(JSON_SYNCHRONISATION, encoding="utf-8"))
        if "kivy" in self.pages : self.settings.add_kivy_panel()
        
        self.settings.interface.menu.close_button.text = "Fermer"
        
        self.content = self.settings
        self.settings.bind(on_close=self.OnBoutonFermer)
        self.bind(on_dismiss=self.on_dismiss)
        super(Popup, self).__init__(*args, **kwargs)		
예제 #23
0
class Popup_parametres(Popup):
    def __init__(self, *args, **kwargs):
        self.callback = kwargs.pop("callback", None)
        self.pages = kwargs.pop("pages",
                                ["general", "synchronisation", "kivy"])
        self.title = "Paramètres"
        self.size_hint = (0.9, 0.9)

        config = ConfigParser()
        config.read(os.path.join(UTILS_Divers.GetRepData(), "config.cfg"))

        self.settings = Settings()
        self.settings.register_type('password', SettingPassword)
        self.settings.register_type('chaine', SettingChaine)

        if "general" in self.pages:
            self.settings.add_json_panel("Généralités",
                                         config,
                                         data=json.dumps(JSON_GENERAL))
        if "synchronisation" in self.pages:
            self.settings.add_json_panel("Synchronisation",
                                         config,
                                         data=json.dumps(JSON_SYNCHRONISATION))
        if "kivy" in self.pages: self.settings.add_kivy_panel()

        self.settings.interface.menu.close_button.text = "Fermer"

        self.content = self.settings
        self.settings.bind(on_close=self.OnBoutonFermer)
        self.bind(on_dismiss=self.on_dismiss)
        super(Popup, self).__init__(*args, **kwargs)

    def AfficherPage(self, nom="Synchronisation"):
        for button in self.settings.interface.menu.buttons_layout.children:
            if button.text == nom:
                button.selected = True
                self.settings.interface.menu.selected_uid = button.uid
                #settings.interface.menu.on_selected_uid()

    def OnBoutonFermer(self, *args):
        self.dismiss()

    def on_dismiss(self, *arg):
        if self.callback != None:
            self.callback()
예제 #24
0
파일: main.py 프로젝트: sunetos/fetcher
class ControllerApp(App):
  title = 'Fetcher'
  directory = './gui'

  def build(self):
    # Can't import Window at the top or it will open early with default config.
    from kivy.core.window import Window
    Window.bind(on_key_down=self.on_key_down)

    access_token = self.config.get('put.io', 'access_token')
    if not access_token:
      Clock.schedule_once(lambda dt: self.show_settings(), 0)
      open_path('http://fetcher.codi.st/api/auth')

    Clock.schedule_once(lambda dt: self.apply_config(), 0)

  def on_key_down(self, src, key, scancode, char, mods):
    from kivy.base import stopTouchApp
    if is_quit_key(char, mods):
      stopTouchApp()
    elif char == ',' and 'meta' in mods:
      self.show_settings()

  def resize(self, width, height):
    from kivy.core.window import Window
    Window.size = (width, height)

  def autosize(self):
    if self.settings: return
    downloads = self.root.downloads.children
    if downloads:
      row_height = downloads[0].height
      new_height = 15 + (row_height + self.root.downloads.spacing)*len(downloads)
      self.resize(320, new_height)
    else:
      self.resize(320, 20)

  def build_config(self, config):
    self.settings = None
    config.setdefaults('put.io', {
        'access_token': '',
        'download_path': '~/Movies/TV Shows',
    })
    with open('gui/settings.yml', 'r') as settings_yaml:
      settings_data = yaml.load(settings_yaml)
    self.settings_json = json.dumps(settings_data)


  def apply_config(self):
    fetcher.CFG.putio.access_token = self.config.get('put.io', 'access_token')
    fetcher.CFG.download.local = self.config.get('put.io', 'download_path')
    fetcher.load_api()
    fetcher.check_now.set()

  def show_settings(self):
    self.settings = Settings()
    self.settings.add_json_panel('put.io', self.config, data=self.settings_json)
    self.resize(640, 250)
    self.settings.remove_widget(self.settings.menu)
    self.root.add_widget(self.settings)

    def on_close(wgt):
      self.apply_config()
      self.root.remove_widget(self.settings)
      self.settings = None
      self.autosize()

    self.settings.bind(on_close=on_close)
예제 #25
0
    def ConfigureKivySettings(self,
                              *,
                              oKivySetting: KivySettings,
                              uConfig: str = "") -> KivySettings:
        """
        Create the JSON string for all sections and applies it to a kivy settings object
        Discover settings are excluded

        :param setting oKivySetting:
        :param str uConfig: If we want a specific section, this is the name to provide
        :return: The KivySetting object
        """

        oSetting: cBaseSettings
        bFoundSetting: bool = False
        RegisterSettingTypes(oKivySetting)
        self.GetSectionList()
        SetVar(uVarName=u'SettingSectionList',
               oVarValue=self.CreateSectionsJSONString())

        if self.uType == "interface":
            # The Codeset List could be applied as a orca var, so set it to the list
            SetVar(uVarName=u'InterfaceCodesetList',
                   oVarValue=self.oObject.CreateCodesetListJSONString())

        for uSection in self.aSections:
            if uConfig == "" or uConfig == uSection:
                # the Section list should be applied as an orca var
                SetVar(uVarName=u'ObjectConfigSection', oVarValue=uSection)
                # Let create a new temporary cSetting object to not harm the existing ones
                oSetting = self.oObject.GetNewSettingObject()
                # Read the ini file for this section
                oSetting.ReadConfigFromIniFile(uConfigName=uSection)
                # Create the setting string
                dSettingsJSON: Dict[str,
                                    Dict] = self.CreateSettingJsonCombined(
                                        oSetting=oSetting,
                                        bIncludeDiscoverSettings=False)
                uSettingsJSON = SettingDictToString(dSettingList=dSettingsJSON)
                uSettingsJSON = ReplaceVars(uSettingsJSON)

                if uSettingsJSON != u'[]':
                    bFoundSetting = True
                    # add the jSon to the Kivy Setting
                    oKivySetting.add_json_panel(uSection,
                                                self.oConfigParser,
                                                data=uSettingsJSON)

        # if there is nothing to configure, then return
        if not bFoundSetting:
            if self.uType == "interface":
                Globals.oNotifications.SendNotification(
                    uNotification='closesetting_interface')
            else:
                Globals.oNotifications.SendNotification(
                    uNotification='closesetting_script')
            return oKivySetting

        # Adds the action handler
        oKivySetting.bind(on_config_change=self.On_ConfigChange)
        return oKivySetting
예제 #26
0
def Build_Settings(oSettings: KivySettings) -> None:
    """
    will be called, when showing the settings dialog
    We add a further panel for the orca.ini settings
    If we had a successful init, lets build the default full settings view
    otherwise just build a very minimalistic settings dialog, where the user can just change the ini path
    """
    RegisterSettingTypes(oSettings)
    if Globals.bInit:

        uOrcaSettingsJSON: str = BuildSettingsString()
        oSettings.add_json_panel(u'ORCA',
                                 Globals.oOrcaConfigParser,
                                 data=uOrcaSettingsJSON)

        uBuildSettingsStringDefinitionList: str = BuildSettingsStringDefinitionList(
        )
        if uBuildSettingsStringDefinitionList != '':
            oSettings.add_json_panel(ReplaceVars('$lvar(580)'),
                                     Globals.oDefinitionConfigParser,
                                     data=uBuildSettingsStringDefinitionList)

        # Add the Info panel
        oSettings.add_json_panel(ReplaceVars('$lvar(585)'),
                                 Globals.oOrcaConfigParser,
                                 data=BuildSettingsStringInfo())

        # add the tools settings
        # and pass to kivy
        oSettings.add_json_panel(ReplaceVars('$lvar(572)'),
                                 Globals.oOrcaConfigParser,
                                 data=BuildSettingsStringTools())

        # add the Online  settings
        # and pass to kivy
        oSettings.add_json_panel(ReplaceVars('$lvar(699)'),
                                 Globals.oOrcaConfigParser,
                                 data=BuildSettingsStringOnlineResources())

    else:
        # just build the small settings
        oSettings.add_json_panel(u'ORCA',
                                 Globals.oOrcaConfigParser,
                                 data=BuildSmallSettingsString())
예제 #27
0
 def build_settings(self, settings: Settings):
     settings.add_json_panel("Kivy Creator", self.config, "settings.json")
예제 #28
0
def CreateConfigPanel():
    from kivy.uix.settings import SettingsWithTabbedPanel as Settings
    settings = Settings(name='Settings')
    settings.add_json_panel('BGM', CP, filename='params.json')
    settings.add_kivy_panel()
    return settings
예제 #29
0
파일: widgets.py 프로젝트: ckazzku/taski
 def show_settings(self):
     settings = Settings()
     settings.add_json_panel(
         'My custom panel', self.config, 'settings.json')
     settings.bind(on_close=self.remove_widget)
     self.add_widget(settings)
예제 #30
0
파일: main.py 프로젝트: bulli92/mytrip
class MarketSettingScreen(Screen):
    marketid = NumericProperty(0)
    data  = ObjectProperty(None)
    def __init__(self, marketid, **kwargs):
        super(MarketSettingScreen,self).__init__(**kwargs)
        self.marketid = marketid
        x = self.data
        self.draw()


    def _str2ranking(self,s):
        return len(s)


    def update(self):
        """
        add data to Category settings

        retrieves data from database for a particular 'catid'
        """
        #/// add data ///

        self.clear_widgets()

        #define structure of fields (like an INI file)
        config = ConfigParser()
        config.add_section('market')
        config.add_section('location')

        #--- set values (needs to come from database)
        #config.set('category','category_name','TestnameID: ' + str(self.catid))
        if self.data == None:
            config.set('market','day','Enter the market DAY here')
            config.set('location','lon','enter longitude here')
            config.set('location','lat','enter latitude here')
            config.set('location','place_name','enter place name here')
            config.set('location','ranking','Ranking here')
            config.set('location','visited',False)
        else:
            config.set('market','day',self.data['day'])

        return config


    def draw(self):

        config = self.update()

        #--- specify settings screen from file
        self.settings = Settings()
        self.settings.add_json_panel('Settings', config, filename='setting_market.json') #todo: do not read this from file, but from string

        #--- add widget ---
        self.add_widget(self.settings)

        btn_close = self.settings.children[1].children[0] #todo this is not so good if it is hardwired like this!
        btn_close.bind(on_press=self.close)


    def close(self,touch):
        #save results in database
        self._save()

        #update category list in main category screen
        s = sm.get_screen('marketscreen')
        s.data = db.get_markets()
        s.update()

        #set focus
        sm.current = 'marketscreen'

    def _get_panel(self):
        k = self.settings._panels.keys()
        if len(k) != 1:
            raise ValueError, 'Expecting a single entry here!'
        panel = self.settings._panels[k[0]][0]
        return panel

    def _save(self):
        """
        save current setting to database
        """
        panel = self._get_panel()

        lat  = panel.get_value('location','lat')
        lon  = panel.get_value('location','lon')
        name = panel.get_value('location','place_name')
        ranking = panel.get_value('location','ranking')
        stars = self._str2ranking(ranking)
        status = panel.get_value('location','visited') #todo this might cuase trouble if the same Location is used for markets and other things !!!

        #--- save Location information ---
        if self.marketid < 1:  #new market
            placeid = None
        else:
            placeid = self.placeid
        L = Location(placeid,lat,lon,name,stars,status)
        db.save_location(L)
        if placeid is None:
            L.id = db._get_last_key('Location')[0] #id of location

        #--- save Category information
        db.save_place(L.id,0) #todo: might cause trouble when using same Location data for different categories !!!


        db.save_market(panel.get_value('market','day'),self.marketid, L.id)
예제 #31
0
파일: main.py 프로젝트: bulli92/mytrip
class CategorySettingScreen(Screen):
    catid = NumericProperty(0)
    data  = ObjectProperty(None)
    def __init__(self, catid, **kwargs):
        super(CategorySettingScreen,self).__init__(**kwargs)
        self.catid = catid
        x = self.data
        self.draw()

    def update(self):
        """
        add data to Category settings

        retrieves data from database for a particular 'catid'
        """
        #/// add data ///

        self.clear_widgets()

        #define structure of fields (like an INI file)
        config = ConfigParser()
        config.add_section('category')
        config.add_section('icon_file')

        #--- set values (needs to come from database)
        #config.set('category','category_name','TestnameID: ' + str(self.catid))
        if self.data == None:
            config.set('category','category_name','Enter your category name here')
        else:
            config.set('category','category_name',self.data['name'])
        config.set('icon_file','icon_file','Testpath') #todo:how to deal with image data ???

        return config


    def draw(self):

        config = self.update()

        #--- specify settings screen from file
        self.settings = Settings()
        self.settings.add_json_panel('Settings', config, filename='setting_category.json') #todo: do not read this from file, but from string

        #--- add widget ---
        self.add_widget(self.settings)

        btn_close = self.settings.children[1].children[0] #todo this is not so good if it is hardwired like this!
        btn_close.bind(on_press=self.close)


    def close(self,touch):
        #save results in database
        self._save()

        #update category list in main category screen
        s = sm.get_screen('catscreen')
        s.data = db.get_categories()
        s.update()

        #set focus
        sm.current = 'catscreen'

    def _get_panel(self):
        k = self.settings._panels.keys()
        if len(k) != 1:
            raise ValueError, 'Expecting a single entry here!'
        panel = self.settings._panels[k[0]][0]
        return panel

    def _save(self):
        """
        save current setting to database
        """
        panel = self._get_panel()
        db.save_category(panel.get_value('category','category_name'),self.catid)
예제 #32
0
def RegisterSettingTypes(oSetting: Settings):
    """ Register ORCA "homemade" settings widgets """
    # Button to have buttons on the settings
    oSetting.register_type('buttons', SettingButtons)
    # For more convinient input of numbers
    oSetting.register_type('numericslider', SettingNumericSlider)
    # Bypass a "bug" in kivy, that you can't scroll the original options popup
    oSetting.register_type('scrolloptions', SettingScrollOptions)
    # An extension to have options on options
    oSetting.register_type('scrolloptionsoptions',
                           SettingScrollOptionsWithOptions)
    # Having a colorpicker (for later use)
    oSetting.register_type('colorpicker', SettingColorPicker)
    # Info widget
    oSetting.register_type('info', SettingInfo)
    # File Picker
    oSetting.register_type('file', SettingFile)
    #Pictures
    oSetting.register_type('picture', SettingPicture)
    # Action List
    oSetting.register_type('actions', SettingActions)
    # For more convinient input of numbers
    oSetting.register_type('numericfloat', SettingNumericFloat)
    # To replace vars in strings
    oSetting.register_type('varstring', SettingVarString)
예제 #33
0
 def build(self):
     s = Settings()
     s.add_json_panel('Test Panel', self.config, data=data)
     return s
예제 #34
0
 def build_settings(self, settings):
     self.config = ConfigParser()
     self.settings = Settings()
     self.settings.add_json_panel('Preferences', self.config, data=SETTINGS)
예제 #35
0
 def build(self):
     s = Settings()
     s.add_json_panel('Test Panel', self.config, data=data)
     return s
예제 #36
0
파일: main.py 프로젝트: bulli92/mytrip
class PlaceSettingScreen(Screen):
    placeid = NumericProperty(0)
    def __init__(self, placeid, **kwargs):
        super(PlaceSettingScreen,self).__init__(**kwargs)
        self.data = None
        self.placeid = placeid

        self.draw()


    def update(self):

        self.clear_widgets()

        #define structure of fields (like an INI file)
        config = ConfigParser()
        config.add_section('general')
        config.add_section('location')
        config.add_section('icon_file')

        #--- set values (needs to come from database) todo
        #config.set('general','place_name','Name of the place: ' + str(self.placeid))
        if self.data == None:
            config.set('location','lat','Enter lat here')
            config.set('location','lon','This is a dummy lon.')

            config.set('general','place_name','This is a dummy which should never be seen')
            config.set('general','category_name','This is a dummy which should never be seen')
            config.set('general','ranking','This is a dummy which should never be seen')
            config.set('general','visited','This is a dummy which should never be seen')
            config.set('icon_file','icon_file','This is a dummy which should never be seen')
        else:
            place = self.data
            config.set('location','lat',place.lat)
            config.set('location','lon',place.lon)

            config.set('general','place_name',place.name)

            config.set('general','category_name',place.cat_name )
            config.set('general','ranking', self._ranking2str(place.stars))
            config.set('general','visited',place.status)
            config.set('icon_file','icon_file','Testpath') #todo:how to deal with image data ???

        return config

    def _ranking2str(self,n):
        """
        convert the ranking from DB into a string
        """
        s = ''
        if n <= 0:
            s = 'unspecified'
        else:
            for i in range(n):
                s += '*'
        return s

    def _str2ranking(self,s):
        return len(s)


    def _get_category_widget(self):
        #return widget which contains category information
        panel=self._get_panel()

        for c in panel.children:
            print c
            if isinstance(c,SettingOptions):
                if c.key == 'category_name':
                    return c
        return None


    def _get_catname_list(self):
        """
        get a name of categories as a list
        """
        cl = db.get_categories()
        res = []
        for id in cl.keys():
            res.append(cl[id]['name'])
        res.sort()
        return res



    def draw(self):

        config = self.update()

        #--- specify settings screen from file
        self.settings = Settings()
        self.settings.add_json_panel('Settings', config, filename='setting_place.json') #todo: do not read this from file, but from string

        cat_widget = self._get_category_widget()
        cat_widget.options = self._get_catname_list() #get list of category names from DB

        #--- add widget ---
        self.add_widget(self.settings)

        btn_close = self.settings.children[1].children[0] #todo this is not so good if it is hardwired like this!
        btn_close.bind(on_press=self.close)


    def close(self,touch):
        self._save()

        s = sm.get_screen('mainscreen')
        s.data = db.get_places()
        s.update()

        sm.current = 'mainscreen'

    def _get_panel(self):
        k = self.settings._panels.keys()
        if len(k) != 1:
            raise ValueError, 'Expecting a single entry here!'
        panel = self.settings._panels[k[0]][0]
        return panel

    def _save(self):
        """
        save current setting to database
        """
        panel = self._get_panel()

        lat  = panel.get_value('location','lat')
        lon  = panel.get_value('location','lon')
        name = panel.get_value('general','place_name')
        ranking = panel.get_value('general','ranking')
        stars = self._str2ranking(ranking)

        status = panel.get_value('general','visited')
        cat_name = panel.get_value('general','category_name')

        #--- save Location information ---
        if self.placeid < 1:
            placeid = None
        else:
            placeid = self.placeid
        L = Location(placeid,lat,lon,name,stars,status)
        db.save_location(L)
        if placeid is None:
            L.id = db._get_last_key('Location')[0] #id of location

        #--- save Category information
        db.save_place(L.id,self._categoryname2id(cat_name))

    def _categoryname2id(self,name):
        c = db.get_categories()
        for k in c.keys():
            if c[k]['name'] == name:
                return k

        return 0
예제 #37
0
 def build_settings(self, settings):
     self.config = ConfigParser()
     self.settings = Settings()
     self.settings.add_json_panel('Preferences', self.config, data=SETTINGS)
 def build(self):
     from kivy.uix.settings import Settings
     s = Settings()
     s.add_json_panel('Test Panel', self.config, data=data)
     return s
예제 #39
0
 def build_settings(self, settings):
     Setting = Settings()
     settings.register_type('scrolloptions', SettingScrollOptions)        
     settings.add_json_panel('Main Settings',
                             self.config,
                             data=settings_json)
예제 #40
0
class Popup_parametres(Popup):
    def __init__(self, *args, **kwargs):
        self.callback = kwargs.pop("callback", None)
        self.pages = kwargs.pop("pages", ["general", "synchronisation", "kivy"])
        self.title = "Paramètres"
        self.size_hint = (0.9, 0.9)
        
        config = ConfigParser()
        config.read(UTILS_Divers.GetRepData() + "config.cfg")

        self.settings = Settings()
        self.settings.register_type('password', SettingPassword)
        self.settings.register_type('chaine', SettingChaine)
        
        if "general" in self.pages : self.settings.add_json_panel("Généralités", config, data=json.dumps(JSON_GENERAL, encoding="utf-8"))
        if "synchronisation" in self.pages : self.settings.add_json_panel("Synchronisation", config, data=json.dumps(JSON_SYNCHRONISATION, encoding="utf-8"))
        if "kivy" in self.pages : self.settings.add_kivy_panel()
        
        self.settings.interface.menu.close_button.text = "Fermer"
        
        self.content = self.settings
        self.settings.bind(on_close=self.OnBoutonFermer)
        self.bind(on_dismiss=self.on_dismiss)
        super(Popup, self).__init__(*args, **kwargs)		

    def AfficherPage(self, nom="Synchronisation"):
        for button in self.settings.interface.menu.buttons_layout.children:
            if button.text == nom :
                button.selected = True
                self.settings.interface.menu.selected_uid = button.uid
                #settings.interface.menu.on_selected_uid() 

    def OnBoutonFermer(self, *args):
        self.dismiss()
        
    def on_dismiss(self, *arg):
        if self.callback != None :
            self.callback()