Ejemplo n.º 1
0
    def load_settings(self, proj_dir):
        '''This function loads project settings
        :param proj_dir: project directory with buildozer.spec
        '''
        self.interface.menu.buttons_layout.clear_widgets()
        self.proj_dir = proj_dir
        self.SPEC_PATH = os.path.join(proj_dir, 'buildozer.spec')

        self.config_parser.read(self.SPEC_PATH)
        self.add_json_panel('Application', self.config_parser,
                            os.path.join(get_kd_data_dir(),
                            'settings', 'buildozer_spec_app.json'))
        self.add_json_panel('Android', self.config_parser,
                            os.path.join(get_kd_data_dir(),
                            'settings', 'buildozer_spec_android.json'))
        self.add_json_panel('iOS', self.config_parser,
                            os.path.join(get_kd_data_dir(),
                            'settings', 'buildozer_spec_ios.json'))
        self.add_json_panel('Buildozer', self.config_parser,
                            os.path.join(get_kd_data_dir(),
                            'settings', 'buildozer_spec_buildozer.json'))

        raw_spec = SpecCodeInput(spec_path=self.SPEC_PATH)
        raw_spec.bind(on_change=self.on_spec_changed)
        self.interface.add_panel(raw_spec, "buildozer.spec", raw_spec.uid)

        menu = self.interface.menu
        menu.selected_uid = menu.buttons_layout.children[-1].uid
    def load_settings(self, proj_dir):
        '''This function loads project settings
        :param proj_dir: project directory with buildozer.spec
        '''
        self.interface.menu.buttons_layout.clear_widgets()
        self.proj_dir = proj_dir
        self.SPEC_PATH = os.path.join(proj_dir, 'buildozer.spec')

        self.config_parser.read(self.SPEC_PATH)
        self.add_json_panel(
            'Application', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'buildozer_spec_app.json'))
        self.add_json_panel(
            'Android', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'buildozer_spec_android.json'))
        self.add_json_panel(
            'iOS', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'buildozer_spec_ios.json'))
        self.add_json_panel(
            'Buildozer', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'buildozer_spec_buildozer.json'))

        raw_spec = SpecCodeInput(spec_path=self.SPEC_PATH)
        raw_spec.bind(on_change=self.on_spec_changed)
        self.interface.add_panel(raw_spec, "buildozer.spec", raw_spec.uid)

        menu = self.interface.menu
        menu.selected_uid = menu.buttons_layout.children[-1].uid
Ejemplo n.º 3
0
    def load_settings(self):
        '''This function loads project settings
        '''
        self.config_parser = ConfigParser(name='DesignerSettings')
        DESIGNER_CONFIG = os.path.join(get_config_dir(),
                                       constants.DESIGNER_CONFIG_FILE_NAME)

        DEFAULT_CONFIG = os.path.join(get_kd_dir(),
                                      constants.DESIGNER_CONFIG_FILE_NAME)
        if not os.path.exists(DESIGNER_CONFIG):
            shutil.copyfile(DEFAULT_CONFIG,
                            DESIGNER_CONFIG)

        self.config_parser.read(DESIGNER_CONFIG)
        self.config_parser.upgrade(DEFAULT_CONFIG)

        # creates a panel before insert it to update code input theme list
        panel = self.create_json_panel('Kivy Designer Settings',
                                        self.config_parser,
                            os.path.join(get_kd_data_dir(),
                                         'settings', 'designer_settings.json'))
        uid = panel.uid
        if self.interface is not None:
            self.interface.add_panel(panel, 'Kivy Designer Settings', uid)

        # loads available themes
        for child in panel.children:
            if child.id == 'code_input_theme_options':
                child.items = styles.get_all_styles()

        # tries to find python and buildozer path if it's not defined
        path = self.config_parser.getdefault(
            'global', 'python_shell_path', '')

        if path.strip() == '':
            self.config_parser.set('global', 'python_shell_path',
                                   sys.executable)
            self.config_parser.write()

        buildozer_path = self.config_parser.getdefault('buildozer',
                                                       'buildozer_path', '')

        if buildozer_path.strip() == '':
            buildozer_path = find_executable('buildozer')
            if buildozer_path:
                self.config_parser.set('buildozer',
                                       'buildozer_path',
                                        buildozer_path)
                self.config_parser.write()

        self.add_json_panel('Buildozer', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'buildozer_settings.json'))
        self.add_json_panel('Hanga', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'hanga_settings.json'))
        self.add_json_panel('Keyboard Shortcuts', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'shortcuts.json'))
Ejemplo n.º 4
0
    def load_settings(self):
        '''This function loads project settings
        '''
        self.config_parser = ConfigParser(name='DesignerSettings')
        DESIGNER_CONFIG = os.path.join(get_config_dir(),
                                       constants.DESIGNER_CONFIG_FILE_NAME)

        DEFAULT_CONFIG = os.path.join(get_kd_dir(),
                                      constants.DESIGNER_CONFIG_FILE_NAME)
        if not os.path.exists(DESIGNER_CONFIG):
            shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG)

        self.config_parser.read(DESIGNER_CONFIG)
        self.config_parser.upgrade(DEFAULT_CONFIG)

        # creates a panel before insert it to update code input theme list
        panel = self.create_json_panel(
            'Kivy Designer Settings', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'designer_settings.json'))
        uid = panel.uid
        if self.interface is not None:
            self.interface.add_panel(panel, 'Kivy Designer Settings', uid)

        # loads available themes
        for child in panel.children:
            if child.id == 'code_input_theme_options':
                child.items = styles.get_all_styles()

        # tries to find python and buildozer path if it's not defined
        path = self.config_parser.getdefault('global', 'python_shell_path', '')

        if path.strip() == '':
            self.config_parser.set('global', 'python_shell_path',
                                   sys.executable)
            self.config_parser.write()

        buildozer_path = self.config_parser.getdefault('buildozer',
                                                       'buildozer_path', '')

        if buildozer_path.strip() == '':
            buildozer_path = find_executable('buildozer')
            if buildozer_path:
                self.config_parser.set('buildozer', 'buildozer_path',
                                       buildozer_path)
                self.config_parser.write()

        self.add_json_panel(
            'Buildozer', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings',
                         'buildozer_settings.json'))
        self.add_json_panel(
            'Hanga', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings', 'hanga_settings.json'))
        self.add_json_panel(
            'Keyboard Shortcuts', self.config_parser,
            os.path.join(get_kd_data_dir(), 'settings', 'shortcuts.json'))
Ejemplo n.º 5
0
    def load_proj_settings(self):
        """This function loads project settings
        """
        self.config_parser = ConfigParser()
        file_path = os.path.join(self.project.path, PROJ_CONFIG)
        if not os.path.exists(file_path):
            if not os.path.exists(os.path.dirname(file_path)):
                os.makedirs(os.path.dirname(file_path))

            CONFIG_TEMPLATE = """[proj_name]
name = Project

[arguments]
arg =

[env variables]
env =
"""
            f = open(file_path, "w")
            f.write(CONFIG_TEMPLATE)
            f.close()

        self.config_parser.read(file_path)

        settings_dir = os.path.join(get_kd_data_dir(), "settings")
        self.add_json_panel(
            "Shell Environment", self.config_parser, os.path.join(settings_dir, "proj_settings_shell_env.json")
        )
        self.add_json_panel(
            "Project Properties", self.config_parser, os.path.join(settings_dir, "proj_settings_proj_prop.json")
        )
Ejemplo n.º 6
0
    def update_panel(self):
        '''Update the MenuSidebar
        '''
        self.config_parsers = {}
        self.interface.menu.buttons_layout.clear_widgets()
        for _file in os.listdir(self.PROFILES_PATH):
            _file_path = os.path.join(self.PROFILES_PATH, _file)
            config_parser = ConfigParser()
            config_parser.read(_file_path)
            prof_name = config_parser.getdefault('profile', 'name', 'PROFILE')
            if not prof_name.strip():
                prof_name = 'PROFILE'
            self.config_parsers[
                str(prof_name) + '_' + _file_path] = config_parser

        for _file in sorted(self.config_parsers):
            prof_name = self.config_parsers[_file].getdefault('profile',
                                                              'name',
                                                              'PROFILE')
            if not prof_name.strip():
                prof_name = 'PROFILE'
            self.add_json_panel(prof_name,
                                self.config_parsers[_file],
                                os.path.join(
                                    get_kd_data_dir(),
                                    'settings',
                                    'build_profile.json')
                                )

        # force to show the first profile
        first_panel = self.interface.menu.buttons_layout.children[-1].uid
        self.interface.content.current_uid = first_panel
Ejemplo n.º 7
0
    def update_panel(self):
        '''Update the MenuSidebar
        '''
        self.config_parsers = {}
        self.interface.menu.buttons_layout.clear_widgets()
        for _file in os.listdir(self.PROFILES_PATH):
            _file_path = os.path.join(self.PROFILES_PATH, _file)
            config_parser = ConfigParser()
            config_parser.read(_file_path)
            prof_name = config_parser.getdefault('profile', 'name', 'PROFILE')
            if not prof_name.strip():
                prof_name = 'PROFILE'
            self.config_parsers[str(prof_name) + '_' +
                                _file_path] = config_parser

        for _file in sorted(self.config_parsers):
            prof_name = self.config_parsers[_file].getdefault(
                'profile', 'name', 'PROFILE')
            if not prof_name.strip():
                prof_name = 'PROFILE'
            self.add_json_panel(
                prof_name, self.config_parsers[_file],
                os.path.join(get_kd_data_dir(), 'settings',
                             'build_profile.json'))

        # force to show the first profile
        first_panel = self.interface.menu.buttons_layout.children[-1].uid
        self.interface.content.current_uid = first_panel
Ejemplo n.º 8
0
    def load_proj_settings(self):
        '''This function loads project settings
        '''
        self.config_parser = ConfigParser()
        file_path = os.path.join(self.project.path, PROJ_CONFIG)
        if not os.path.exists(file_path):
            if not os.path.exists(os.path.dirname(file_path)):
                os.makedirs(os.path.dirname(file_path))

            CONFIG_TEMPLATE = '''[proj_name]
name = Project

[arguments]
arg =

[env variables]
env =
'''
            f = open(file_path, 'w')
            f.write(CONFIG_TEMPLATE)
            f.close()

        self.config_parser.read(file_path)

        settings_dir = os.path.join(get_kd_data_dir(), 'settings')
        self.add_json_panel(
            'Shell Environment', self.config_parser,
            os.path.join(settings_dir, 'proj_settings_shell_env.json'))
        self.add_json_panel(
            'Project Properties', self.config_parser,
            os.path.join(settings_dir, 'proj_settings_proj_prop.json'))
Ejemplo n.º 9
0
 def update_template_preview(self, instance):
     '''Event handler for 'on_selection_change' event of adapter.
     '''
     name = instance.text.lower() + '.png'
     name = name.replace(' and ', '_')
     image_source = join(get_kd_data_dir(),
                         constants.NEW_TEMPLATE_IMAGE_PATH, name)
     self.template_preview.source = image_source
Ejemplo n.º 10
0
 def update_template_preview(self, instance):
     '''Event handler for 'on_selection_change' event of adapter.
     '''
     name = instance.text.lower() + '.png'
     name = name.replace(' and ', '_')
     image_source = join(get_kd_data_dir(),
                         constants.NEW_TEMPLATE_IMAGE_PATH, name)
     self.template_preview.source = image_source
Ejemplo n.º 11
0
    def _perform_create_spec(self, *args):
        '''Creates the default buildozer.spec file
        '''
        templates_dir = os.path.join(get_kd_data_dir(),
                                     constants.DIR_NEW_TEMPLATE)
        shutil.copy(os.path.join(templates_dir, 'default.spec'),
                    os.path.join(self.profiler.project_path, 'buildozer.spec'))

        self.designer.designer_content.update_tree_view(get_current_project())
        self.designer.close_popup()
        self.last_command()
Ejemplo n.º 12
0
    def _perform_create_spec(self, *args):
        '''Creates the default buildozer.spec file
        '''
        templates_dir = os.path.join(get_kd_data_dir(),
                                     constants.DIR_NEW_TEMPLATE)
        shutil.copy(os.path.join(templates_dir, 'default.spec'),
                    os.path.join(self.profiler.project_path, 'buildozer.spec'))

        self.designer.designer_content.update_tree_view(get_current_project())
        self.designer.close_popup()
        self.last_command()
Ejemplo n.º 13
0
 def on_adapter_selection_change(self, adapter):
     '''Event handler for 'on_selection_change' event of adapter.
     '''
     name = adapter.selection[0].text.lower() + '.png'
     name = name.replace(' and ', '_')
     image_source = join(constants.NEW_TEMPLATE_IMAGE_PATH, name)
     image_source = join(get_kd_data_dir(), image_source)
     parent = self.image.parent
     parent.remove_widget(self.image)
     self.image = Image(source=image_source)
     parent.add_widget(self.image)
     self.prev_selection = adapter.data.index(adapter.selection[0].text)
Ejemplo n.º 14
0
 def on_adapter_selection_change(self, adapter):
     '''Event handler for 'on_selection_change' event of adapter.
     '''
     name = adapter.selection[0].text.lower() + '.png'
     name = name.replace(' and ', '_')
     image_source = join(constants.NEW_TEMPLATE_IMAGE_PATH, name)
     image_source = join(get_kd_data_dir(), image_source)
     parent = self.image.parent
     parent.remove_widget(self.image)
     self.image = Image(source=image_source)
     parent.add_widget(self.image)
     self.prev_selection = adapter.data.index(adapter.selection[0].text)
Ejemplo n.º 15
0
    def load_profiles(self):
        '''This function loads project settings
        '''
        self.settings_changed = False
        self.PROFILES_PATH = os.path.join(get_config_dir(),
                                          constants.DIR_PROFILES)

        self.DEFAULT_PROFILES = os.path.join(get_kd_data_dir(),
                                             constants.DIR_PROFILES)

        if not os.path.exists(self.PROFILES_PATH):
            shutil.copytree(self.DEFAULT_PROFILES, self.PROFILES_PATH)

        self.update_panel()
Ejemplo n.º 16
0
    def _perform_buildozer_init(self, *args):
        '''Copies the spec from data/new_templates/default.spec to the project
        folder
        '''
        get_designer().close_popup()

        proj_dir = get_current_project().path
        spec_file = os.path.join(proj_dir, 'buildozer.spec')

        templates_dir = os.path.join(get_kd_data_dir(),
                                     constants.DIR_NEW_TEMPLATE)
        shutil.copy(os.path.join(templates_dir, 'default.spec'), spec_file)

        self.designer.designer_content.update_tree_view(get_current_project())
Ejemplo n.º 17
0
    def _perform_buildozer_init(self, *args):
        '''Copies the spec from data/new_templates/default.spec to the project
        folder
        '''
        get_designer().close_popup()

        proj_dir = get_current_project().path
        spec_file = os.path.join(proj_dir, 'buildozer.spec')

        templates_dir = os.path.join(get_kd_data_dir(),
                                     constants.DIR_NEW_TEMPLATE)
        shutil.copy(os.path.join(templates_dir, 'default.spec'), spec_file)

        self.designer.designer_content.update_tree_view(get_current_project())
Ejemplo n.º 18
0
    def load_profiles(self):
        '''This function loads project settings
        '''
        self.settings_changed = False
        self.PROFILES_PATH = os.path.join(get_config_dir(),
                                          constants.DIR_PROFILES)

        self.DEFAULT_PROFILES = os.path.join(get_kd_data_dir(),
                                             constants.DIR_PROFILES)

        if not os.path.exists(self.PROFILES_PATH):
            shutil.copytree(self.DEFAULT_PROFILES, self.PROFILES_PATH)

        self.update_panel()