Skip to content

Commit

Permalink
remove duplicate code and fix typo
Browse files Browse the repository at this point in the history
remove duplicate tooltip
  • Loading branch information
YellowRoseCx committed Jul 30, 2023
1 parent 430986e commit 8573a67
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,24 +765,6 @@ def getfilename(var, text):
button = ctk.CTkButton(parent, 50, text="Browse", command= lambda a=var,b=searchtext:getfilename(a,b))
button.grid(row=row+1, column=1, stick="nw")
return
def show_tooltip(event, tooltip_text=None):
if hasattr(show_tooltip, "_tooltip"):
tooltip = show_tooltip._tooltip
else:
tooltip = ctk.CTkToplevel(root)
tooltip.configure(fg_color="#ffffe0")
tooltip.withdraw()
tooltip.overrideredirect(True)
tooltip_label = ctk.CTkLabel(tooltip, text=tooltip_text, text_color="#000000", fg_color="#ffffe0")
tooltip_label.pack(expand=True, padx=2, pady=1)
show_tooltip._tooltip = tooltip
x, y = root.winfo_pointerxy()
tooltip.wm_geometry(f"+{x + 10}+{y + 10}")
tooltip.deiconify()
def hide_tooltip(event):
if hasattr(show_tooltip, "_tooltip"):
tooltip = show_tooltip._tooltip
tooltip.withdraw()

from subprocess import run, CalledProcessError
def get_device_names():
Expand Down Expand Up @@ -930,7 +912,7 @@ def changerunmode(a,b,c):

runoptbox = ctk.CTkComboBox(quick_tab, values=runopts, width=180,variable=runopts_var, state="readonly")
runoptbox.grid(row=1, column=1,padx=8, stick="nw")
runoptbox.set(runopts[0])
runoptbox.set(runopts[0]) # Set to first available option
# Tell user how many backends are available
num_backends_built = makelabel(quick_tab, str(len(runopts)) + "/6", 5, 2)
num_backends_built.grid(row=1, column=2, padx=0, pady=0)
Expand Down Expand Up @@ -968,15 +950,16 @@ def changerunmode(a,b,c):
makelabel(hardware_tab, "Presets:", 1)
runoptbox = ctk.CTkComboBox(hardware_tab, values=runopts, width=180,variable=runopts_var, state="readonly")
runoptbox.grid(row=1, column=1,padx=8, stick="nw")
runoptbox.set(runopts[0])
runoptbox.set(runopts[0]) # Set to first available option
runopts_var.trace('w', changerunmode)
changerunmode(1,1,1)

# Tell user how many backends are available
num_backends_built = makelabel(hardware_tab, str(len(runopts)) + "/6", 5, 2)
num_backends_built.grid(row=1, column=2, padx=0, pady=0)
num_backends_built.configure(text_color="#00ff00")
num_backends_built.bind("<Enter>", show_tooltip)
# Bind the backend count label with the tooltip function
num_backends_built.bind("<Enter>", lambda event: show_tooltip(event, f"This is the number of backends you have built and available." + (f"\nMissing: {', '.join(antirunopts)}" if len(runopts) != 6 else "")))
num_backends_built.bind("<Leave>", hide_tooltip)
# threads
makelabelentry(hardware_tab, "Threads:" , threads_var, 8, 50)
Expand Down

0 comments on commit 8573a67

Please sign in to comment.