import os from mods.files import ui_dir import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk gender_dict = { 'male': 'Мужской', 'female': 'Женский' } doc_type_dict = { 'passport': 'Паспорт', 'birth_cert': 'Св.о рождении', 'foreign_passport': 'Паспорт иностранца' } def show_msg(text, sec_text='', level='info'): msg_win_file = os.path.join(ui_dir, f'{level}_win.glade') b = Gtk.Builder() b.add_from_file(msg_win_file) w = b.get_object(level) w.set_property('text',text) w.set_property('secondary_text',sec_text) w.run() w.close() def enable_widget(w_list): for widget in w_list: widget.set_sensitive(True) def disable_widget(w_list): for widget in w_list: widget.set_sensitive(False) class ConditionalFilter: def __init__(self, search_func): self.search_func = search_func self.reset() def filter(self, query): if query != self.fstr: self.fstr = query self.ids = list(map(lambda x: x.id, self.search_func(query))) return self.ids def reset(self): self.fstr = '' self.ids = []