-1

click to view picture

is there any way to create this, this is a picture when link in Wikipedia is highlighted

peter
  • 104
  • 8

1 Answers1

0

by running the following function you can see how a pop window will look like Tkinter program

LARGE_FONT= ("Verdana", 12)
NORM_FONT = ("Helvetica", 10)
SMALL_FONT = ("Helvetica", 8)

def popupmsg(msg):
    popup = tk.Tk()
    popup.wm_title("!")
    label = ttk.Label(popup, text=msg, font=NORM_FONT)
    label.pack(side="top", fill="x", pady=10)
    B1 = ttk.Button(popup, text="Okay", command = popup.destroy)
    B1.pack()
    popup.mainloop()

later you could use it in your program by removing somelines.

Aakash Dinkar
  • 332
  • 1
  • 10
  • You shouldn't be creating a new instance of `Tk`, and you shouldn't be calling `mainloop` a second time. That's not how tkinter is designed to be used. This promotes a bad programming practice. – Bryan Oakley Sep 15 '20 at 21:46
  • @Bryan I know that, and I wrote that code so that he can run individually this code and see how it works.‍♀️ – Aakash Dinkar Sep 16 '20 at 05:42
  • I need a window which popups when a text is highlighted and automatically destroys when the highlight is removed. this window contains the default three buttons of window and appears only when the command is run, how to run this function when the label in another window is highlighted ? – peter Sep 16 '20 at 10:36