Python Tkinter - How to make a description pop up for a button -
i don't know start, don't have code. know way make description pop when hover on button, or widget matter?
def button_description(button, text, self): event = none self.del_search_description = lambda event=event: del_search_description(self) self.search_description = lambda event=event: search_description_delay(self, text, button) button.bind("<enter>", self.search_description) button.bind("<leave>", self.del_search_description) def del_search_description(self, event=none): try: self.search_description_top.destroy() except attributeerror: pass return event def search_description_delay(self, text, button, event=none): button.after(500 , search_description(self, text, button ,event)) def search_description(self, text, button, event=none): self.search_description_top = toplevel() self.search_description_top.wm_overrideredirect(true) self.search_description_top_label = label(self.search_description_top, text=text, justify=left, background="gold", relief=solid, borderwidth=1, font='50') self.search_description_top_label.grid(row=0, column=0) x = button.winfo_rootx() - int(len( self.search_description_top_label.cget("text")) * 3.5) + int(button.winfo_width()/2) y = button.winfo_rooty() + 25 self.search_description_top.geometry("+%s+%s" % (x, y)) return event
call button_description function, , provide button, or other widget, text put on description, , class tkinter code running (pass word self if within class code is)
Comments
Post a Comment