Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New command palette design #446

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/biscuit/common/palette/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def __init__(self, master: App, width=80, *args, **kwargs) -> None:
width (int, optional): The width of the palette. Defaults to 80."""

super().__init__(master, *args, **kwargs)
self.config(pady=1, padx=1, bg=self.base.theme.border)
self.config(pady=2, padx=2, bg=self.base.theme.border)

self.container = Frame(self, **self.base.theme.palette, padx=5, pady=5)
self.container.pack(fill=tk.BOTH)
self.container = Frame(self, **self.base.theme.palette, padx=2, pady=2)
self.container.pack(fill=tk.BOTH, expand=True)

self.width = round(width * self.base.scale)
self.active = False
Expand All @@ -60,9 +60,7 @@ def __init__(self, master: App, width=80, *args, **kwargs) -> None:
self.active_set = None

self.searchbar = SearchBar(self)
self.searchbar.grid(
row=0, sticky=tk.EW, pady=(1, 7), padx=1, in_=self.container
)
self.searchbar.grid(row=0, sticky=tk.EW, in_=self.container, pady=(0, 2))

self.configure_bindings()

Expand Down Expand Up @@ -248,7 +246,7 @@ def show(self, prefix: str = None, default: str = None) -> None:
x = self.master.winfo_rootx() + int(
(self.master.winfo_width() - self.winfo_width()) / 2
)
y = self.master.winfo_rooty() + self.base.menubar.searchbar.winfo_y()
y = self.master.winfo_rooty() + int((self.master.winfo_height() / 2) - 200)
self.geometry(f"+{x}+{y}")
self.deiconify()

Expand Down
15 changes: 8 additions & 7 deletions src/biscuit/common/palette/searchbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@ class SearchBar(Frame):

def __init__(self, master: Palette, *args, **kwargs) -> None:
super().__init__(master, *args, **kwargs)
self.config(bg=self.base.theme.biscuit)
self.config(bg=self.base.theme.border)
self.term = ""

self.text_variable = tk.StringVar()
self.text_variable.trace_add("write", self.filter)

frame = Frame(self, **self.base.theme.palette)
frame.pack(fill=tk.BOTH, padx=1, pady=1)
# frame = Frame(self, bg=self.base.theme.border)
# frame.pack(fill=tk.BOTH, padx=2, pady=2)

self.search_bar = tk.Entry(
frame,
font=self.base.settings.uifont,
self,
font=self.base.settings.font,
width=self.master.width,
relief=tk.FLAT,
textvariable=self.text_variable,
**self.base.theme.palette.searchbar,
bg=self.base.theme.border,
fg=self.base.theme.biscuit,
)

self.search_bar.grid(sticky=tk.EW, padx=5, pady=3)
self.search_bar.grid(sticky=tk.EW, padx=5, pady=5)
self.configure_bindings()

def configure_bindings(self) -> None:
Expand Down
Loading