eldoc/mods/utils.py

45 lines
1.2 KiB
Python
Raw Normal View History

2019-12-01 16:22:43 +03:00
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': 'Паспорт иностранца'
}
2019-12-01 16:22:43 +03:00
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 = []