Skip to content

Commit

Permalink
Tooltips go off-screen #1224
Browse files Browse the repository at this point in the history
center tooltip unless tip would go off the screen and then use what screen space is available
  • Loading branch information
lawson89 committed Oct 13, 2023
1 parent a3eb36d commit 8983a69
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion porcupine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ def show(self) -> None:
# dark text on a dark background on some systems.
tkinter.Label(tipwindow, text=self.text, border=3, fg="black", bg="white").pack()
tipwindow.update_idletasks()
tipwindow.geometry(f"+{self.mousex - tipwindow.winfo_width()}+{self.mousey - 30}")
screen_width = tipwindow.winfo_screenwidth()
to_end = screen_width - self.mousex
tip_width = tipwindow.winfo_width()
if to_end >= tip_width/2:
offset = int(tip_width/2)
else:
offset = int(tip_width - to_end)
tipwindow.geometry(f"+{self.mousex - offset}+{self.mousey - 30}")


def set_tooltip(widget: tkinter.Widget, text: str) -> None:
Expand Down

0 comments on commit 8983a69

Please sign in to comment.