Beispiel #1
0
class Text(TextMixin, Editor):

    def __init__(self, master, style_def=None):
        super().__init__(master, style_def)
        self.config(**self.style.highlight_active)
        self._entry = Entry(self, **self.style.input)
        self._entry.configure(**self.style.no_highlight)
        self._entry.pack(fill="x")
        self._entry.on_entry(self._change)
        self.set_def(style_def)
Beispiel #2
0
class Text(TextMixin, Editor):
    def __init__(self, master, style_def=None):
        super().__init__(master, style_def)
        if style_def is None:
            style_def = {}
        self.config(**self.style.dark_highlight_active)
        self._entry = Entry(self, **self.style.dark_input)
        self._entry.pack(fill="x")
        self._entry.on_entry(self._change)
        if style_def.get("readonly", False):
            self._entry.config(state='disabled')
Beispiel #3
0
class Text(TextMixin, Editor):
    def __init__(self, master, style_def=None):
        super().__init__(master, style_def)
        self.config(**self.style.dark_highlight_active)
        self._entry = Entry(self, **self.style.dark_input)
        self._entry.configure(**self.style.no_highlight)
        self._entry.pack(fill="x")
        self._entry.on_entry(self._change)
        self.set_def(style_def)

    def set_def(self, definition):
        if definition.get("readonly", False):
            self._entry.config(state='disabled')
        super().set_def(definition)
Beispiel #4
0
class SearchBar(Frame):
    def __init__(self, master=None, **cnf):
        super().__init__(master, **cnf)
        self.config(**self.style.no_highlight, **self.style.dark)
        self._entry = Entry(self, **self.style.dark_input)
        self._clear_btn = Button(self,
                                 image=get_icon_image("close", 15, 15),
                                 **self.style.dark_button,
                                 width=25,
                                 height=25)
        self._clear_btn.pack(side="right", fill="y")
        self._clear_btn.on_click(self._clear)
        Label(self,
              **self.style.dark_text,
              image=get_icon_image("search", 15, 15)).pack(side="left")
        self._entry.pack(side="left", fill="both", expand=True, padx=2)
        self._entry.on_entry(self._change)
        self._on_change = None
        self._on_clear = None

    def focus_set(self):
        super().focus_set()
        self._entry.focus_set()

    def on_query_change(self, func, *args, **kwargs):
        self._on_change = lambda val: func(val, *args, **kwargs)

    def on_query_clear(self, func, *args, **kwargs):
        self._on_clear = lambda: func(*args, **kwargs)

    def _clear(self, *_):
        if self._on_clear:
            self._on_clear()

    def _change(self, *_):
        if self._on_change:
            self._on_change(self._entry.get())