def __init__(self, name): self.name = name self.path = "characters/{0}/".format(self.name) self.display_name = None self.series = None self.extra_series = [] self.sprites_path = None self.icons_path = None self.avatar = None self.loaded_sprites = False self.loaded_icons = False self.sprites = None self.icons = None self.link = None self.version = None # Hash tables for faster membership checking self.nsfw_sprites = {} self.spoiler_sprites = {} self.cg_sprites = {} try: self.config = ConfigParser(self.name) except ValueError: self.config = ConfigParser.get_configparser(self.name) try: self.read_config() except (KeyError, AttributeError): Logger.exception('Problematic character located in: ' + self.path)
def right_click(self, inst, touch): if touch.button == 'right': try: if inst.collide_point(touch.x, touch.y): favorite = App.get_running_app().get_fav_chars() favorite.options = characters config = ConfigParser() config.read('mysteryonline.ini') fav_list = str(config.get('other', 'fav_characters').strip('[]')) fav_list = fav_list.replace("'", "") fav_list = fav_list.split(',') fav_list = [x.strip() for x in fav_list] for option in favorite.options: state = 'down' if option in favorite.value and option in fav_list else 'normal' btn = ToggleButton(text=option, state=state, size_hint_y=None, height=50) favorite.buttons.append(btn) for btn in favorite.buttons: if btn.text is characters[inst.name].name: if btn.state == 'normal': btn.state = 'down' else: btn.state = 'normal' favorite.value = [btn.text for btn in favorite.buttons if btn.state == 'down'] favorite.buttons.clear() self.save.is_saved = False self.main_lay.clear_widgets() self.fill_with_chars() except AttributeError: pass
def read_spoiler_sprites(self): try: spoiler_section = self.config['spoiler'] except KeyError: return spoiler_list = [] series = self.extra_series[:] series.insert(0, self.series) config = ConfigParser() config.read('mysteryonline.ini') try: whitelist = config.get('other', 'whitelisted_series') except: for key, s in zip(sorted(spoiler_section), series): spoiler_sprites = spoiler_section[key].split(',') spoiler_list.extend(spoiler_sprites) for sprite_name in spoiler_list: self.spoiler_sprites[sprite_name] = None return whitelist = whitelist.strip('[]') whitelist = whitelist.replace("'", "") whitelist = whitelist.split(',') whitelist = [x.strip() for x in whitelist] for key, s in zip(sorted(spoiler_section), series): if s not in whitelist: spoiler_sprites = spoiler_section[key].split(',') spoiler_list.extend(spoiler_sprites) for sprite_name in spoiler_list: self.spoiler_sprites[sprite_name] = None
def load(self): print("the data dir " + self.data_dir) self.config = ConfigParser() self.config.read(os.path.join(self.data_dir, 'preferences.ini')) self.set_config_defaults() self._prefs_dict = {'range_alerts': {}, 'gauge_settings': {}} try: with open(self.prefs_file, 'r') as data: content = data.read() content_dict = json.loads(content) if content_dict.has_key("range_alerts"): for name, settings in content_dict[ "range_alerts"].iteritems(): self._prefs_dict["range_alerts"][ name] = Range.from_dict(settings) if content_dict.has_key("gauge_settings"): for id, channel in content_dict[ "gauge_settings"].iteritems(): self._prefs_dict["gauge_settings"][id] = channel except Exception: pass
def build(self): #self.config = Config.get_configparser('app') self.config = ConfigParser(name='tetris_cfg') self.config.read('tetris.ini') #print "app cfg", self.config.filename #parser = ConfigParser.get_configparser('app') #clr = parser.get("color", "root_bgclr").encode("utf-8") clr = self.config.getdefault("color", "root_bgclr", '1,1,1') m = re.search(r'.*?(\d+).*,.*?(\d+).*,.*?(\d+).*', clr) self.root_bgclr_r = float(m.groups()[0])/255 self.root_bgclr_g = float(m.groups()[1])/255 self.root_bgclr_b = float(m.groups()[2])/255 clr = self.config.getdefault("color", "activity_bgclr", '1,1,1') m = re.search(r'.*?(\d+).*,.*?(\d+).*,.*?(\d+).*', clr) self.activity_bgclr_r = float(m.groups()[0])/255 self.activity_bgclr_g = float(m.groups()[1])/255 self.activity_bgclr_b = float(m.groups()[2])/255 # self.length = parser.getint("tetris", "length") # self.activity_rows = parser.getint("tetris", "activity_rows") # self.activity_cols = parser.getint("tetris", "activity_cols") self.anchor_x = self.config.getdefaultint("tetris", "anchor_x", 50) self.anchor_y = self.config.getdefaultint("tetris", "anchor_y", 50) self.length = self.config.getdefaultint("tetris", "length", 50) self.activity_rows = self.config.getdefaultint("tetris", "activity_rows", 24) self.activity_cols = self.config.getdefaultint("tetris", "activity_cols", 12) self.test = self.config.getdefaultint("tetris", "test", 100) logging.debug("[%d] [%d] [%d] [%d]", self.length, self.activity_rows, self.activity_cols, self.test) rootWidget = RootWidget() rootWidget.StartGame() return rootWidget
def load_config(self): '''(internal) This function is used for returning a ConfigParser with the application configuration. It's doing 3 things: #. Create an instance of a ConfigParser #. Load the default configuration by calling :meth:`build_config`, then #. If exist, load the application configuration file, or create it if it's not existing. :return: ConfigParser instance ''' self.config = config = ConfigParser() self.build_config(config) # if no sections are created, that's mean the user don't have # configuration. if len(config.sections()) == 0: return # ok, the user have some sections, read the default file if exist # or write it ! filename = self.get_application_config() if filename is None: return config if exists(filename): try: config.read(filename) except: Logger.error('App: Corrupted config file, ignored.') self.config = config = ConfigParser() self.build_config(config) pass else: config.filename = filename config.write() return config
def __init__(self, **kwargs): super().__init__(**kwargs) self.selected_dampers = [ ] # Every damper selected by MyRightCheckbox add to this list. self.all_dampers_in_container = [ ] # Consists of all adding DamperListItem. self.damper = None self.dampers = [ ] # Has all getting dampers (class Damper) from the DB. self.found_dampers = [] # Has all found in searching dampers. self.menu_sort = None self.menu_dots = None # For exit on double tap on the buttnon back. self.is_back_clicked_once = False # My config. self.config = ConfigParser() # App theme. self.primary_palette = "Teal" self.accent_palette = "Amber" self.theme_style = "Light" # To avoid multi chosen right_checkbox_lang. self.lang_checkboxes_dict = dict() # Handling the back button. Window.bind(on_keyboard=self.key_input) # The current target TextInput widget requesting the keyboard # is presented just above the soft keyboard. Window.softinput_mode = "below_target"
def load_proj_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser() file_path = os.path.join(self.proj_loader.proj_dir, 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) proj_prop_panel = self.create_json_panel( 'Project Properties', self.config_parser, './designer/settings/proj_settings_proj_prop.json') self.add_widget(proj_prop_panel) self.add_json_panel( 'Shell Environment', self.config_parser, './designer/settings/proj_settings_shell_env.json')
def reapply_version(app: MyDevoirsApp) -> Tuple[int, str]: """ Verifie les differents version précendentes :param app: L'instance en cours :return: 0: le fichier n'existe pas 1: la version a du être ajoutée 2: la version existe == version en cours 3: la version existe < version en cours 4: la version existe > version en cours """ cf_file = app.get_application_config() file = Path(cf_file) return_value = 0 file_version = None if file.is_file(): # pragma: no branch config = ConfigParser() try: config.read(cf_file) file_version = config.get("aide", "version") except NoSectionError: return_value = 1 except NoOptionError: return_value = 1 if file_version is not None: if file_version < VERSION: return_value = 3 elif file_version > VERSION: return_value = 4 else: return_value = 2 return return_value, file_version
def __init__(self, **kwargs): super(MyConnectDialog, self).__init__(**kwargs) self.register_type('buttons', SettingButtons) self.register_event_type('on_connect') config = ConfigParser() config.setdefaults( 'common', { 'conf_role': 'SERVER', 'conf_transport': 'TLS', 'conf_ip': '192.168.1.220', 'conf_serport': 'COM1' }) config.setdefaults('client', { 'conf_user': '******', 'conf_cert_chain': 'myhome-bundle.crt' }) config.setdefaults('server', { 'conf_serv_cert': 'rootca.crt', 'conf_serv_key': 'secret/rootca.key' }) self.myconfig = config try: config.read("i-spy.myconfig") except: print("No i-spy.myconfig") self.add_json_panel('IO device connect', config, data=json)
def get_first_sub(self): config = ConfigParser() config.read('mysteryonline.ini') try: return self.sublocations[str(config.get('other', 'last_sublocation'))].name except KeyError: return self.list_sub()[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)
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
def load_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser() DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] DEFAULT_CONFIG = os.path.join(_dir, 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) self.add_json_panel( 'Kivy Designer Settings', self.config_parser, os.path.join(_dir, 'designer', 'settings', 'designer_settings.json')) path = self.config_parser.getdefault('global', 'python_shell_path', '') if path == "": self.config_parser.set('global', 'python_shell_path', sys.executable) self.config_parser.write()
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) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] settings_dir = os.path.join(_dir, 'designer', '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'))
def __init__(self, **kwargs): super().__init__(**kwargs) Window.bind(on_keyboard=self.events_program) Window.soft_input_mode = "below_target" self.LIST_SCREENS = [ "base", "license", "about", "server_lists_screen", "syncscreen", "server_readinglists_screen", "single_file_screen", "open_file_screen", ] self.list_previous_screens = ["base"] self.window = Window self.config = ConfigParser() self.manager = None self.window_language = None self.exit_interval = False self.comic_thumb_height = 240 self.comic_thumb_width = 156 self.dict_language = literal_eval( open(os.path.join(self.directory, "data", "locales", "locales.txt")).read()) # self.translation = Translation( # self.lang, 'Ttest', os.path.join(self.directory, # data', 'locales') # ) self.base_url = "" self.settings_cls = MySettings self.md_manager = None self.open_comic_screen = ""
def change_sz(self, ev, instance, *args): self.config = ConfigParser() self.config.read('my.ini') button_text = instance setattr(self.mainbutton1, 'text', button_text) self.config.set('My Label', 'font_size', button_text) self.config.write()
def get_config(path=None): """Get a configuration. The path, where a config file is searched, can be given in `path`, a string. If no such argument is passed in, we use results from :func:`get_conffile_locations`. Returns a `kivy.config.ConfigParser` instance. """ conf = ConfigParser() fpscan_path = find_fpscan_binary() conf['DEFAULT'] = { 'waeup_user': '******', 'waeup_passwd': 'grok', 'waeup_url': 'localhost:8080', 'save_passwd': '0', } if fpscan_path is not None: conf['DEFAULT'].update(fpscan_path=fpscan_path) if path is not None: conffile_location = path else: conffile_location = get_conffile_location() conf.read(conffile_location) return conf
def load_story_config(self, library_dir): self.story_config = ConfigParser() story_file_loc = library_dir.joinpath(self.title + '.ini') if not story_file_loc.is_file(): self.story_config.setdefaults('metadata', get_metadata_defaults(self.title, self.library_parent)) self.story_config.setdefaults('title', get_page_defaults(self.title)) self.story_config_file = str(story_file_loc) # Set config from story's config file. self.story_config.read(str(self.story_config_file)) if self.story_config.get('metadata', 'story') != self.title: self.story_config.set('metadata', 'story', self.title) if self.story_config.get('metadata', 'library') != self.library_parent: self.story_config.set('metadata', 'library', self.library_parent) # Find the media location for this story's title page self.title_media_location = self.story_config.get('title', 'media_location') # Find all the pages self.pages = ['title'] + [x.strip() for x in self.story_config.get('metadata', 'pages').split(',')] self.story_config.write()
def __init__(self, **kvargs): super(PyConversations, self).__init__(**kvargs) Window.bind(on_keyboard=self.events_program) Window.soft_input_mode = 'below_target' # self.admob_id = 'ca-app-pub-8865711525352558~2442322860' # self.banner_id = '' # self.interstitial_id = '' # self.ads = KivMob(self.admob_id) self.list_previous_screens = ['base'] self.window = Window self.config = ConfigParser() self.manager = None self.window_language = None self.exit_interval = False self.dict_language = literal_eval( open( os.path.join(self.directory, 'data', 'locales', 'locales.txt')).read() ) self.translation = Translation( self.lang, 'Ttest', os.path.join(self.directory, 'data', 'locales') ) self.start_time = None
def update_sub(self, loc): if self.subloc_btn is not None: self.subloc_drop.clear_widgets() fav_subloc = App.get_running_app().get_fav_subloc() config = ConfigParser() config.read('mysteryonline.ini') fav_list = str(config.get('other', 'fav_subloc').strip('[]')) fav_list = fav_list.replace("'", "") fav_list = fav_list.split(',') fav_list = [x.strip() for x in fav_list] for sub in loc.list_sub(): if loc.name + '_' + sub in fav_list and loc.name + '_' + sub in fav_subloc.value: btn = Button( text=sub, size_hint=(None, None), size=(200, 30), background_normal= 'atlas://data/images/defaulttheme/button_pressed', background_down='atlas://data/images/defaulttheme/button') btn.bind( on_release=lambda btn_: self.subloc_drop.select(btn_.text)) self.subloc_drop.add_widget(btn) for sub in loc.list_sub(): if loc.name + '_' + sub not in fav_subloc.value or loc.name + '_' + sub not in fav_list: btn = Button(text=sub, size_hint=(None, None), size=(200, 30)) btn.bind( on_release=lambda btn_: self.subloc_drop.select(btn_.text)) self.subloc_drop.add_widget(btn) self.subloc_btn.text = loc.get_first_sub()
def __init__(self, **kvargs): super(Gllearn, self).__init__(**kvargs) Window.bind(on_keyboard=self.events_program) Window.soft_input_mode = 'below_target' self.list_previous_screens = ['base'] self.window = Window self.config = ConfigParser() self.manager = None self.window_language = None self.window_game_language = None self.exit_interval = False self.dict_language = literal_eval( open(os.path.join(self.directory, 'data', 'locales', 'locales.txt')).read()) self.translation = Translation( self.lang, 'Gllearn', os.path.join(self.directory, 'data', 'locales')) self.translation_game = Translation( self.lang_games, 'Games', os.path.join(self.directory, 'data', 'locales')) self.snake_words_with_color = [{ word: get_random_color(alpha=1.0) for word in words } for words in [ s.split(' ') for s in self.translation_game._('snake_rounds').split(' | ') ]] self.current_round_snake = 0
def build_config(self, _) -> None: """ """ self.config = ConfigParser() self.config.read('config.ini') self.config.setdefaults('general', { 'userdir': 'user', 'autosave': True }) self.config.setdefaults( 'ai', { 'timeout': 20.0, 'memory': 20, 'max_length': 60, 'beam_searches': 1, 'temperature': 0.8, 'top_k': 40, 'top_p': 0.9, 'repetition_penalty': 1.1 }) self.config.setdefaults( 'modules', { 'input_filters': 'aiventure:filters', 'output_filters': 'aiventure:filters', 'display_filter': 'aiventure:filters' }) self.config.write()
def build_settings(self, req, result): self.settings = None self.settings = SettingsWithNoMenu() self.settings.on_config_change = self.on_config_change self.settings.register_type('string_long', SettingString) self.settings.register_type('num_int', SettingNumeric) self.settings.register_type('num', SettingNumeric) config = ConfigParser() print result['settings'] config.setdefaults(self.popup.device_id, result['settings']) self.settings.add_json_panel(result['name'], config, data=dumps(result['settings_format'])) self.add_widget(self.settings) buttons = BoxLayout(orientation='horizontal') buttons.add_widget( Button(text='Previous', on_release=self.popup.previous_view, height='50dp')) buttons.add_widget( Button(text='Next', on_release=self.popup.next_view, height='50dp')) self.add_widget(buttons)
def __init__(self, **kwargs): super(NuBippyApp, self).__init__(**kwargs) self.isPopup = False self.show_info = False self.use_kivy_settings = False # load config file # we don't display the settings panel, changes can be made manually to the ini file self.config = ConfigParser() self.config.read('nubippy.ini') # Set the language and load the language file self.language = self.config.get('Language', 'active_language') try: self.lang = json.load(open('res/json/languages/' + self.language + '.json', 'r')) except ValueError as e: print('') print('##################################################################') print('') print('There was an Error loading the ' + self.language + ' language file.') print('') print(str(e)) print('') print('##################################################################') raise SystemExit return
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
def load_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser(name='DesignerSettings') DESIGNER_CONFIG = os.path.join(get_config_dir(), DESIGNER_CONFIG_FILE_NAME) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] DEFAULT_CONFIG = os.path.join(_dir, 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(_dir, 'designer', '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(_dir, 'designer', 'settings', 'buildozer_settings.json')) self.add_json_panel( 'Hanga', self.config_parser, os.path.join(_dir, 'designer', 'settings', 'hanga_settings.json')) self.add_json_panel( 'Keyboard Shortcuts', self.config_parser, os.path.join(_dir, 'designer', 'settings', 'shortcuts.json'))
def __init__(self, directory): self.dir_parser = AtlasedCharacterDirParser(directory) self.sprites = None self.icon_keys = [] self.icons = None self.name = self.extract_name(directory) self.config_parser = ConfigParser() self.load(directory)
def __init__(self, data_dir, user_files_dir, save_timeout=0.2, **kwargs): self._prefs_dict = UserPrefs.DEFAULT_PREFS_DICT self.config = ConfigParser() self.data_dir = data_dir self.user_files_dir = user_files_dir self.prefs_file = path.join(self.data_dir, self.prefs_file_name) self.register_event_type("on_pref_change") self.load()
def __init__(self, **kwargs): super().__init__(**kwargs) settings_config = ConfigParser() settings_config.read('data/settings.ini') if platform == 'win': self.add_json_panel('General', settings_config, 'data/settings/general.json') elif platform == 'android': self.add_json_panel('General', settings_config, 'data/settings/general_android.json')
class LoginScreen(Screen): def __init__(self, screen_name, navigate_to, register_screen): super(LoginScreen, self).__init__() self.conf_parser = ConfigParser() self.conf_parser.read('settings.ini') self.host = self.conf_parser['host_settings']['host_ip'] self.port = self.conf_parser['host_settings']['host_port'] self.navigate_to_screen = navigate_to self.name = screen_name self.register_screen = register_screen self.lower_panel = BoxLayout(orientation='vertical', spacing=5, padding=15) self.add_widget(self.lower_panel) self.username_input = TextInput(size_hint_y=.6, multiline=False) self.password_input = TextInput(size_hint_y=.6, multiline=False) self.login_button = Button(text='Login', on_release=self.login_user, size_hint_y=.6, background_normal='', background_color=[.99, .3, .3, .99]) self.register_button = Button(text='Registration', on_release=self.go_to_registration, size_hint_y=.6, background_normal='', background_color=[.99, .3, .3, .99]) self.status_label = Label() self.lower_panel.add_widget(Label(text='Login', size_hint_y=.6)) self.lower_panel.add_widget(self.username_input) self.lower_panel.add_widget(Label(text='Password', size_hint_y=.6)) self.lower_panel.add_widget(self.password_input) self.lower_panel.add_widget(self.login_button) self.lower_panel.add_widget(self.register_button) self.lower_panel.add_widget(self.status_label) def login_user(self, *args): link = r'http://{}:{}/login/'.format(self.host, self.port) j_data = {} j_data["username"] = self.username_input.text j_data["password"] = self.password_input.text response = requests.post(link, data=j_data) if response.status_code == 200: response_data = response.json() if response_data['state'] == 'ok': self.manager.transition.direction = 'up' self.manager.current = self.navigate_to_screen def go_to_registration(self, *args): self.manager.transition.direction = 'down' self.manager.current = self.register_screen
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)
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
class ProjectSettings(Settings): '''Subclass of :class:`kivy.uix.settings.Settings` responsible for showing settings of project. ''' project = ObjectProperty(None) '''Reference to :class:`desginer.project_manager.Project` ''' config_parser = ObjectProperty(None) '''Config Parser for this class. Instance of :class:`kivy.config.ConfigParser` ''' 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) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] settings_dir = os.path.join(_dir, 'designer', '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')) @ignore_proj_watcher def on_config_change(self, *args): '''This function is default handler of on_config_change event. ''' self.config_parser.write() super(ProjectSettings, self).on_config_change(*args)
def build_my_settings(settings, req, result): for settable in result: yeah_id = settable[0] settings_format = settable[1] my_settings = settable[2] print yeah_id, settings_format, my_settings config = ConfigParser() config.setdefaults(yeah_id, my_settings) settings.add_json_panel(my_settings['name'], config, data=dumps(settings_format))
class ProjectSettings(Settings): """Subclass of :class:`kivy.uix.settings.Settings` responsible for showing settings of project. """ project = ObjectProperty(None) """Reference to :class:`desginer.project_manager.Project` """ config_parser = ObjectProperty(None) """Config Parser for this class. Instance of :class:`kivy.config.ConfigParser` """ 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") ) @ignore_proj_watcher def on_config_change(self, *args): """This function is default handler of on_config_change event. """ self.config_parser.write() super(ProjectSettings, self).on_config_change(*args)
def do_search(self): def on_success(req, result): print ('search success.') for p in result['result']: p_id = str(p['id']) if p['code'] is None or p['code'] == '': subtext = p['name'] else: subtext = p['code'] image_source = self.get_local_image(p) btn = Factory.CustomButton(image_source=image_source, id=p_id, size_hint_y=None, width=300, height=100, subtext=subtext) btn.bind(on_press=self.do_add_item) self.products_search_list.append(btn) self.my_tabbed_panel_wid.grid_layout_search_wid.add_widget(btn) self.my_tabbed_panel_wid.switch_to(self.my_tabbed_panel_wid.tab_search_wid) self.my_tabbed_panel_wid.grid_layout_search_wid.height = (len(result['result'])/4+4)*110 self.text_input_wid.text = '' def on_failure(req, result): on_error(req, result) def on_error(req, result): print ('POSScrean.search().on_error() ') print ('POSScreen.do_search():') if len(self.products_search_list) > 0: for n in self.products_search_list: self.my_tabbed_panel_wid.grid_layout_search_wid.remove_widget(n) self.products_search_list = [] config = ConfigParser.get_configparser(name='app') producturl = config.get('serverconnection', 'server.url') + "pos/product/" + self.text_input_wid.text UrlRequest(producturl, on_success=on_success, on_failure=on_failure, on_error=on_error)
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) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] settings_dir = os.path.join(_dir, 'designer', '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'))
def build(self): self.title = core.string_lang_title[:-1] # заголовок окна программы self.icon = "Data/Images/logo.png" # иконка окна программы self.use_kivy_settings = False self.config = ConfigParser() self.config.read("{}/program.ini".format(core.prog_path)) self.beep = SoundLoader.load("Data/mess_unread.wav") self.set_variable_from_settings() # Домашняя страница клиента. self.start_screen = \ StartScreen(name_buttons_menu=core.name_buttons_menu, buttons_menu=core.buttons_menu, buttons_group=core.buttons_group, previous="Data/Images/logo.png", title_previous=core.string_lang_title[:-1], title_image="Data/Images/DV.png", overflow_image="Data/Images/overflow_image.png", previous_image="Data/Images/previous_image.png", events_callback=self.events_program) self.screen = self.start_screen Clock.schedule_once(self.read_license, 3) return self.start_screen
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") )
def load_proj_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser() file_path = os.path.join(self.proj_loader.proj_dir, 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) proj_prop_panel = self.create_json_panel('Project Properties', self.config_parser, './designer/settings/proj_settings_proj_prop.json') self.add_widget(proj_prop_panel) self.add_json_panel('Shell Environment', self.config_parser, './designer/settings/proj_settings_shell_env.json')
def build(self): self.config = ConfigParser() self.config.read(join( dirname(__file__),'duplicator.ini') ) print( self.config.get('general','app_background_color') ) #if not self.config.has_section("general"): # self.config.add_section("general") self.activeprinter = None self.printer_pause = 0 self.sm = ScreenManager() self.sm.add_widget(MenuScreen(name='Menu')) self.sm.add_widget(PrintScreen(name='Print')) self.sm.add_widget(ScanScreen(name='Scan')) self.sm.add_widget(ShareScreen(name='Share')) self.sm.add_widget(ConfigScreen(name='Config')) self.sm.add_widget(PlaterScreen(name='Plater')) self.sm.add_widget(ViewScreen(name='View')) self.sm.add_widget(FileGcodeLoadScreen(name='FileGcodeLoad')) self.menu_bar = Factory.MenuBar() self.sm.get_screen('Menu').ids.window_layout.add_widget(self.menu_bar) self.menu_bar.ids.short_message.text = 'Duplicator Started\nReady for action.' self.cam1 = cv2.VideoCapture(0) return self.sm
def load_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser() DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] DEFAULT_CONFIG = os.path.join(_dir, 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) self.add_json_panel('Kivy Designer Settings', self.config_parser, os.path.join(_dir, 'designer', 'settings', 'designer_settings.json')) path = self.config_parser.getdefault( 'global', 'python_shell_path', '') if path == "": self.config_parser.set('global', 'python_shell_path', sys.executable) self.config_parser.write()
def __init__(self): Screen.__init__(self) self.name = 'menu' self.config = ConfigParser() self.config.add_section("deck") self.config.add_section("card") self.config.adddefaultsection("menu") self.config.set("deck", "start_studying", 1) self.config.set("deck", "change_deck_mode", "Normal") self.config.set("deck", "show_list", True) self.config.set("deck", "undo", True) self.config.set("deck", "redo", True) self.config.set("card", "add", "") self.config.set("card", "edit", True) self.config.set("card", "remove", True) self.config.add_callback(self.check_deck_locks, "deck", "redo") self.config.add_callback(self.check_deck_locks, "deck", "undo") self.config.add_callback(self.check_card_locks, "card", "edit") self.config.add_callback(self.check_card_locks, "card", "add") self.menu = SettingsWithNoMenu() self.menu.register_type("screen", FlashcardAppManager.SettingNewScreen) self.menu.register_type("action", FlashcardAppManager.SettingDoAction) self.menu.add_json_panel("Flashcards", self.config, os.path.join(os.path.dirname(__file__), 'menu.json')) self.add_widget(self.menu)
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_all_images(self): config = ConfigParser.get_configparser(name='app') for p in self.products_json['result']: image_name = p['code'] if p['code'] is None: image_name = str(p['id']) image_file = image_name + "-small.png" self.download_photo(config.get('serverconnection', 'server.url') + "static/products/" + image_file, "./products/" + image_file)
def __init__(self, scenario_screen, block, *args, **kwargs): super(BlockSettingsPopup, self).__init__(*args, **kwargs) self.app = App.get_running_app() self.title = 'Block settings' self.block = block self.scenario_screen = scenario_screen self.settings = SettingsWithNoMenu() self.settings.on_config_change = self.on_config_change self.settings.register_type('string_long', SettingString) self.settings.register_type('num_int', SettingNumeric) self.settings.register_type('num', SettingNumeric) config = ConfigParser() config.setdefaults(block.yeah_id, block.settings) self.settings.add_json_panel(block.settings['name'], config, data=dumps(block.settings_format)) self.content = self.settings
def on_start(self): """ Método chamado para inicializar o menu inicial :return: nada """ Window.size = (300, 100) config = ConfigParser() # Carrega últimas configurações utilizadas (ou padrões se arquivo não é encontrado) config.read('settings.ini') self.username = config.get('section0', 'key00') self.color = SettingsApp.get_color(config.get('section0', 'key01')) if config.get('section1', 'key10') == "Single": self.is_multiplayer = False else: self.is_multiplayer = True self.match = config.get('section1', 'key11') self.rows = config.getint('section2', 'key20') self.columns = config.getint('section2', 'key21') self.bombs = config.getint('section3', 'key30')
def load_settings(self): """This function loads project settings """ self.config_parser = ConfigParser(name="DesignerSettings") DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME) _dir = os.path.dirname(designer.__file__) _dir = os.path.split(_dir)[0] DEFAULT_CONFIG = os.path.join(_dir, 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(_dir, "designer", "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(_dir, "designer", "settings", "buildozer_settings.json") ) self.add_json_panel( "Hanga", self.config_parser, os.path.join(_dir, "designer", "settings", "hanga_settings.json") ) self.add_json_panel( "Keyboard Shortcuts", self.config_parser, os.path.join(_dir, "designer", "settings", "shortcuts.json") )
def pay(self): unique_id = uuid.uuid4() def on_success(req, result): os.remove('offline/' + str(unique_id) + '.json') self.manager.get_screen('posscreen').icon_wid.source = 'icon.png' with open('sale.json', 'w') as fp: json.dump(result, fp) fp.close() self.sale_json = result print ('on_success: sale returned.') self.manager.get_screen('posscreen').do_clear_item_list() self.parent.current = "posscreen" def on_failure(req, result): on_error(req, result) def on_error(req, result): print ('on_error: Could not send payment. Save to file instead.') self.manager.get_screen('posscreen').icon_wid.source = 'icon_offline.png' self.manager.get_screen('posscreen').do_clear_item_list() self.parent.current = "posscreen" try: print("Pay and clear list") payslip_json = dict([]) payslip_positions = self.manager.get_screen('posscreen').my_data_view customer = dict([]) customer['customerid'] = self.manager.get_screen('posscreen').customer_id payslip_json['customer'] = customer payslip_items = [] for i in payslip_positions: print("selling: " + str(i)) next_element = self.getProduct(i.product_code) if next_element is not None: payslip_items.append(next_element) payslip_json['items'] = payslip_items with open('offline/' + str(unique_id) + '.json', 'w') as fp: json.dump(payslip_json, fp) fp.close() # clear list config = ConfigParser.get_configparser(name='app') print(config.get('serverconnection', 'server.url')) saleurl = config.get('serverconnection', 'server.url') + "pos/sale/" data_json = json.dumps(payslip_json) headers = {'Content-type': 'application/jsonrequest', 'Accept': 'application/jsonrequest'} if len(self.manager.get_screen('posscreen').my_data_view) > 0: UrlRequest(url=saleurl, on_success=on_success, on_failure=on_failure, on_error=on_error, req_headers=headers, req_body=data_json) else: self.manager.get_screen('posscreen').do_clear_item_list() self.parent.current = "posscreen" except Exception: print(traceback.format_exc()) print "PaymentScreen.pay() Error: Could not send payslip"
def on_pre_enter(self, *args): def on_success(req, result): self.icon_wid.source = 'icon.png' with open('products.json', 'w') as fp: json.dump(result, fp) fp.close() self.products_json = result print ('products loaded.') if len(result['result']) > 0: self.grid_layout_home_wid.clear_widgets() for i in result['result']: code = i['code'] if code == '': code = '200001' btn = Factory.CustomButton(image_source='./products/'+code+'-small.png', id=code, size_hint_y=None, width=300, height=100, subtext=code) btn.bind(on_press=self.do_add_item) self.products_list.append(btn) print ('add online product ' + code) self.grid_layout_home_wid.add_widget(btn) self.grid_layout_home_wid.height = (len(result['result'])/4)*110 try: config = ConfigParser.get_configparser(name='app') print(config.get('serverconnection', 'server.url')) producturl = config.get('serverconnection', 'server.url') + "pos/products/" if len(self.products_list) == 0: UrlRequest(producturl, on_success) else: return except: print "POSScreen Error: Could not load products" print "Initialize products selection" for key, val in self.ids.items(): print("key={0}, val={1}".format(key, val)) if len(self.products_list) > 0: for n in self.products_list: self.grid_layout_home_wid.remove_widget(n) if len(self.products_list) == 0: with open('products.json') as data_file: result = json.load(data_file) self.products_json = result for i in result['result']: code = i['code'] if code == '': code = '200001' btn = Factory.CustomButton(image_source='./products/'+code+'-small.png', id=code, size_hint_y=None, width=300, height=100, subtext=code) btn.bind(on_press=self.do_add_item) self.products_list.append(btn) print ('add local product ' + code) self.grid_layout_home_wid.add_widget(btn) self.grid_layout_home_wid.height = (len(result['result'])/4)*110
def __init__(self): self.bIsInit = False self.uMyPath = u'' self.uScriptName = u'' self.uScriptFile = u'' self.iMyVersion = ToIntVersion('1.0.0') self.fOrcaVersion = ToIntVersion('1.0.0') self.uType = u'Generic' self.uSubType = u'Generic' self.aScriptIniSettings = QueryDict() self.oConfigParser = KivyConfigParser() self.uDefaultConfigName = "" self.uConfigFileName = "" self.uSection = ""
def build_settings(self, req, result): self.settings = None self.settings = SettingsWithNoMenu() self.settings.on_config_change = self.on_config_change self.settings.register_type('string_long', SettingString) self.settings.register_type('num_int', SettingNumeric) self.settings.register_type('num', SettingNumeric) config = ConfigParser() print result['settings'] config.setdefaults(self.popup.device_id, result['settings']) self.settings.add_json_panel(result['name'], config, data=dumps(result['settings_format'])) self.add_widget(self.settings) buttons = BoxLayout(orientation = 'horizontal') buttons.add_widget(Button(text = 'Previous', on_release = self.popup.previous_view, height = '50dp')) buttons.add_widget(Button(text = 'Next', on_release = self.popup.next_view, height = '50dp')) self.add_widget(buttons)
def __init__(self, **kwargs): super(NewGame, self).__init__(**kwargs) self.config = ConfigParser() self.config.read(tttraders_user_conf('tttraders.ini')) self.settings.register_type("int", TTSettingInt) for tab in TradersGame.ConfigTabs: lst = TradersGame.Config[tab] for c in lst: if c.get("key", None): self.config.adddefaultsection(c['section']) self.config.setdefault(c['section'], c['key'], c.get("default", None)) self.settings.add_json_panel(tab, self.config, data=json.dumps(lst))
def on_release(self): print ('POSScreen.ImageButton.on_press: upload payslips') upload_count = len(glob.glob('offline/*.json')) if upload_count > 0: self.popup.open() self.pb.value = 0 file_count = len(glob.glob('offline/*.json')) increment = 100.0/file_count + 1 for fn in glob.glob('offline/*.json'): if os.path.isfile(fn): Clock.schedule_once(partial(self.upload_payslips, fn, increment), 0) config = ConfigParser.get_configparser(name='app') if config.get('section1', 'download_images_after_sync') == 'True': self.parent.parent.parent.load_all_images()
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 build(self): config = ConfigParser.get_configparser(name='app') producturl = config.get('serverconnection', 'server.url') + "pos/product/" + '200018' data = json.load(urllib2.urlopen(producturl)) product = data['result'][0] layout = BoxLayout(orientation='vertical') # use a (r, g, b, a) tuple blue = (0, 0, 1.5, 2.5) red = (2.5, 0, 0, 1.5) btn = Button(text='Touch me!'+product['name'], background_color=blue, font_size=40) btn.bind(on_press=self.callback) self.label = Label(text="------------", font_size='50sp') layout.add_widget(btn) layout.add_widget(self.label) return layout
def post_init(self, *args): config = ConfigParser.get_configparser(name='app') self.customer_id = config.get('section1', 'default_customer_id') self.order_id = int(config.get('section1', 'default_order_id')) with open('customers.json') as data_file: result = json.load(data_file) self.customers_json = result for c in result['result']: self.customers_list.append(c) customer = self.get_customer(self.customer_id) if customer: self.customer_name = customer["name"] else: self.customer_name = '???' self.btn_customer_wid.text = 'Client: ' + self.customer_name print ('post_init...')