emmental/emmental/entry.py

21 lines
675 B
Python
Raw Normal View History

# Copyright 2022 (c) Anna Schumaker.
"""Customized Gtk.Entries for easier development."""
from gi.repository import Gtk
from . import format
class Filter(Gtk.SearchEntry):
"""A Gtk.Entry that returns a filter query."""
def __init__(self, what: str, **kwargs):
"""Set up the FilterEntry."""
super().__init__(placeholder_text=f"type to filter {what}", **kwargs)
def get_placeholder_text(self) -> str:
"""Get the entry's placeholder-text."""
return self.get_property("placeholder-text")
def get_query(self) -> str | None:
"""Get the query string for the entered text."""
return format.search(self.get_text())