Closed ethical-haquer closed 11 months ago
Can you post a minimal example that reproduces this behaviour and I will have a look.
Can you post a minimal example that reproduces this behavior and I will have a look.
Thanks for replying! Will do.
Can you post a minimal example that reproduces this behaviour and I will have a look.
Here you go:
import tkinter as tk
from tkinter import ttk
from tktooltip import ToolTip
import typing as typ
tooltip_list = [
('BL_Entry', "Drag and drop a BL file here, or paste it's path"),
('AP_Entry', "Drag and drop an AP file here, or paste it's path"),
('CP_Entry', "Drag and drop a CP file here, or paste it's path"),
('CSC_Entry', "Drag and drop a CSC file here, or paste it's path"),
('USERDATA_Entry', "Drag and drop a USERDATA file here, or paste it's path")
]
class Entry():
def __init__(self, name: str, master: ttk.Frame,
state: str = 'normal',
column: int = 0,
row: int = 0,
sticky: str = 'we',
padx: int = 5,
pady: int = 5,
columnspan: int = 1):
self.name = name + '_Entry'
self.master = master
self.state = state
self.column = column
self.row = row
self.sticky = sticky
self.padx = padx
self.pady = pady
self.columnspan = columnspan
self.tooltip_delay = 0.25
self.entry = ttk.Entry(self.master, state=self.state)
self.entry.grid(column=self.column, row=self.row, columnspan=self.columnspan, sticky=self.sticky, padx=self.padx, pady=self.pady)
self.create_tooltip(tooltip_list)
def create_tooltip(self, tooltip_list: typ.Optional[typ.List[typ.Tuple[str, str]]] = None):
for tooltip_widget, msg in tooltip_list:
if tooltip_widget == self.name:
ToolTip(self.entry, msg=msg, delay=self.tooltip_delay)
def __getattr__(self, attr):
return getattr(self.entry, attr)
window = tk.Tk(className='Tooltip Demo')
window.title('Tooltip Demo')
window.geometry('200x100')
# Creates the Odin archive Entries
BL_Entry = Entry('BL', window, 'normal', 0, 0, 'we', 5, 0, 3)
AP_Entry = Entry('AP', window, 'normal', 0, 1, 'we', 5, 0, 3)
CP_Entry = Entry('CP', window, 'normal', 0, 1, 'we', 5, 0, 3)
CSC_Entry = Entry('CSC', window, 'normal', 0, 3, 'we', 5, 0, 3)
USERDATA_Entry = Entry('USERDATA', window, 'normal', 0, 4, 'we', 5, 0, 3)
window.mainloop()
By default the Tooltip uses an aspect ratio for its tk.Message
box of 1000
, that means the widget will be 10 times as wide as it is tall, but aspect ratio is not the most robust way to set your width.
If you want a specific width you can set it explicitly in the tooltip by passing kwargs
ToolTip(self.entry, msg=msg, width=len(msg) * 10)
I'm currently using tkinter-tooltip in an app I made, Thor GUI. I have multiple tkinter entries that are almost identical: "BL", "AP", "CP", "CSC", and "USERDATA". The CSC Entry's tooltip has always looked like this, split on two lines: Whereas all the other ones look like this: The length of the message isn't causing it: It turns out the "CSC" part of the tooltip msg is actually causing it. The issue occurs with certain phrases such as: "CAAAA", "CJ", or "CCC", but doesn't occur with "CA", "CV", or "CC". Aside from being annoying in this particular use case, it's just a weird issue. I'd be interested to know what's causing it though. :rofl: