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'))
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'))
def store_files(self): '''To store the list of files on disk. ''' _string = '' for _file in self.list_projects: _string += _file + '\n' recent_file_path = os.path.join(get_config_dir(), RECENT_FILES_NAME) f = open(recent_file_path, 'w') f.write(_string) f.close()
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()
def load_files(self): '''To load the list of files from disk ''' recent_file_path = os.path.join(get_config_dir(), RECENT_FILES_NAME) if not os.path.exists(recent_file_path): return f = open(recent_file_path, 'r') path = f.readline() while path != '': file_path = path.strip() if isinstance(file_path, bytes): file_path = file_path.decode(get_fs_encoding()).encode( get_fs_encoding()) if os.path.exists(file_path): self.list_projects.append(file_path) path = f.readline() f.close()