mirror of
https://github.com/serialexperiments0815/OpenLibFetch.git
synced 2026-07-12 15:32:24 +00:00
22 lines
No EOL
879 B
Python
22 lines
No EOL
879 B
Python
import tkinter as tk
|
|
|
|
# This buttonfade class was implemented soly for it's function of giving placeholder-text in the searchbar
|
|
# which disappears when clicked into. (User-Friendly design).
|
|
class buttonfade(tk.Entry):
|
|
def __init__(self, master=None, placeholder="Search Here", *args, **kwargs):
|
|
super().__init__(master, *args, **kwargs)
|
|
self.placeholder = placeholder
|
|
self.insert(0, self.placeholder)
|
|
self.config(fg="gray")
|
|
self.bind('<FocusIn>', self.on_focus_in)
|
|
self.bind('<FocusOut>', self.on_focus_out)
|
|
|
|
def on_focus_in(self, event):
|
|
if self.get() == self.placeholder:
|
|
self.delete(0, tk.END)
|
|
self.config(fg="black")
|
|
|
|
def on_focus_out(self, event):
|
|
if self.get() == "":
|
|
self.insert(0, self.placeholder)
|
|
self.config(fg="gray") |