def on_config_change(self, config, section, key, value): '''Вызывается при выборе одного из пункта настроек программы.''' if key == 'language': if not os.path.exists('{}/data/language/{}.txt'.format( self.directory, data.select_locale[value])): dialog(text=data.string_lang_not_locale.format( data.select_locale[value]), title=self.title) config.set(section, key, data.old_language) config.write() self.close_settings()
def show_plugins(self, *args): '''Выводит на экран список установленных плагинов.''' dict_info_plugins = self._get_info_plugins() if not dict_info_plugins.__len__(): dialog(text=self.translation._(u'Нет установленных плагинов!'), title=self.title) return self._list_plugins = Lists(dict_items=dict_info_plugins, events_callback=self._action_plugin, flag='two_list_icon_check') card(self._list_plugins)
def show_plugins(self): '''Выводит на экран список установленных плагинов.''' dict_info_plugins = self._get_info_plugins() if not dict_info_plugins.__len__(): dialog( text=self.data.self.data.string_lang_not_install_plugin, title=self.title ) return self._list_plugins = Lists( dict_items=dict_info_plugins, events_callback=self._action_plugin, flag='two_list_icon_check' ) card(self._list_plugins)
def on_select(path_to_avatar): dialog_manager.dismiss() if os.path.splitext(path_to_avatar)[1] in [ '.png', '.jpg', '.jpeg', '.gif' ]: path_to_dir_image, name_image = os.path.split(path_to_avatar) name_image = '{}{}'.format( os.path.splitext(name_image)[0], '.png') new_path_to_avatar = '{}/data/contacts/previous/{}'.format( self.directory, name_image) create_previous_portrait(path_to_avatar, new_path_to_avatar) self._path_to_avatar = new_path_to_avatar self._form_create_contact.ids.avatar.source = new_path_to_avatar else: dialog(title=self.title, text=self.data.string_avatar_wrong)
def show_license(dialog, on_language): path_to_license = '{}/license/license_{}.rst'.format( self.directory, self.data.dict_language[on_language]) if not os.path.exists(path_to_license): dialog(text=self.data.string_lang_not_license, title=self.title) dialog.dismiss() return text_license = open(path_to_license).read() widget_license = RstDocument( text=text_license, background_color=self.data.alpha, underline_color=self.data.underline_rst_color) card(widget_license, size=(.9, .8)) dialog.dismiss()
def load_contacts(self, interval): if not self.dialog_load_contact: self.dialog_load_contact = dialog( title=data.string_lang_wait[:-3], text=data.string_lang_contacts_load, dismiss=False) while _default_time() < (Clock.get_time() + MAX_TIME): self.show_contacts(self.info_contacts) self.dialog_load_contact.dismiss() Clock.unschedule(self.load_contacts)
def _show_info_plugin(self, name_plugin): '''Вызывается при клике на имя плагина из списка.''' if not os.path.exists('{}/libs/plugins/{}/README.rst'.format( self.directory, name_plugin)): dialog(text=self.translation._(u'Нет информации о плагине!'), title=name_plugin) else: info_plugin = open('{}/libs/plugins/{}/README.rst'.format( self.directory, name_plugin)).read() info_plugin = info_plugin.format( NAME_APP=self.title, VERSION=self.started_plugins[name_plugin]['plugin-version'], AUTHOR=self.started_plugins[name_plugin]['plugin-author'], MAIL=self.started_plugins[name_plugin]['plugin-mail'], ) # TODO: избавиться от использования RstDocument. widget_info = RstDocument(text=info_plugin, background_color=self.alpha, underline_color=self.underline_rst_color) card(widget_info, size=(.75, .6))
def _show_info_plugin(self, name_plugin): '''Вызывается при клике на имя плагина из списка.''' if not os.path.exists('{}/libs/plugins/{}/README.rst'.format( self.directory, name_plugin)): dialog( text=self.data.string_lang_not_info_plugin, title=name_plugin ) else: info_plugin = open('{}/libs/plugins/{}/README.rst'.format( self.directory, name_plugin)).read() info_plugin = info_plugin.format( NAME_APP=self.title, VERSION=self.started_plugins[name_plugin]['plugin-version'], AUTHOR=self.started_plugins[name_plugin]['plugin-author'], MAIL=self.started_plugins[name_plugin]['plugin-mail'], ) widget_info = RstDocument( text=info_plugin, background_color=self.data.alpha, underline_color=self.data.underline_rst_color ) card(widget_info, size=(.75, .6))
def exit_program(self, *args): def close_dialog(): self.open_exit_dialog.dismiss() self.open_exit_dialog = None if self.open_exit_dialog: return self.open_exit_dialog = dialog( text=data.string_lang_exit, title=self.title, dismiss=False, buttons=[[data.string_lang_yes, lambda *x: sys.exit(0)], [data.string_lang_no, lambda *x: close_dialog()]])
def _action_plugin(self, name_plugin, state_plugin, action_plugin): '''Вызывается при манипуляции с пунктом плагина. Принимает имя, статус чекбокса ('normal/down') и действие ('item/check'), выбранного из списка плагина.''' if action_plugin == 'check': # выбран чекбокс плагина if state_plugin == 'down': text, result = self._compare_version_plugin(name_plugin) if not result: text = text.format( TEXT_COLOR=self.text_color, NAME_PLUGIN=name_plugin, LINK_COLOR=self.text_link_color, VERSION_MIN=self.started_plugins[name_plugin] ['app-version-min'], VERSION_APP=self.started_plugins[name_plugin] ['app-version']) buttons = [[ self.translation._(u'Да'), lambda *x: self._save_status_plugin( window, name_plugin, self.translation._(u'Да')) ], [ self.translation._(u'Нет'), lambda *x: self._save_status_plugin( window, name_plugin, self.translation._(u'Нет')) ]] window = dialog(text=text, title=self.title, buttons=buttons, dismiss=False) else: self._save_status_plugin(None, name_plugin, self.translation._(u'Да')) else: try: self._list_activate_plugins.remove(name_plugin) open( '{}/libs/plugins/plugins_list.list'.format( self.directory), 'w').write(str(self._list_activate_plugins)) except ValueError: pass else: self._show_info_plugin(name_plugin)
def show_license(self, *args): def choice_language_license(on_language): window = dialog(text=self.data.string_lang_wait, title=self.title) Clock.schedule_once( lambda *args: show_license(window, on_language), 0) choice_dialog.dismiss() def show_license(dialog, on_language): path_to_license = '{}/license/license_{}.rst'.format( self.directory, self.data.dict_language[on_language]) if not os.path.exists(path_to_license): dialog(text=self.data.string_lang_not_license, title=self.title) dialog.dismiss() return text_license = open(path_to_license).read() widget_license = RstDocument( text=text_license, background_color=self.data.alpha, underline_color=self.data.underline_rst_color) card(widget_license, size=(.9, .8)) dialog.dismiss() choice_dialog = dialog( text=self.data.string_lang_prev_license, title=self.title, buttons=[[ self.data.string_lang_on_russian, lambda *x: choice_language_license(self.data.string_lang_on_russian) ], [ self.data.string_lang_on_english, lambda *x: choice_language_license( self.data.string_lang_on_english) ]])
def choice_language_license(on_language): window = dialog(text=self.data.string_lang_wait, title=self.title) Clock.schedule_once( lambda *args: show_license(window, on_language), 0) choice_dialog.dismiss()
def show_about(self): dialog( text=self.data.string_lang_about.format( LINK_COLOR=self.data.text_link_color), title=self.title, ref_callback=self.events_callback )