2

Consider:

import Tkinter as tk
import tkMessageBox
root = tk.Tk()
root.withdraw()

if True:
    tkMessageBox.askyesno("aa", "bb?")
tkMessageBox.askyesno("aa1", "bb1?")
tkMessageBox.askyesno("aa2", "bb2?")

enter image description here

When the second or the third (the results vary between the runs!) tkMessageBox.askyesno is invoked, two icons (both for the title "aa1" or "aa2", respectively) appear on my Ubuntu 16.04 launcher as shown in the above screenshot. I tried doing root.update() between the calls of tkMessageBox.askyesno without improvement. What is going on and how do I fix this?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68
  • one is for the root window, one is for the popup window. – Bryan Oakley Dec 14 '17 at 19:48
  • @BryanOakley The root window is withdrawn. – AlwaysLearning Dec 14 '17 at 20:02
  • Sure, but some window managers will still create an icon for it. That seems to be what is happening here. – Bryan Oakley Dec 14 '17 at 20:40
  • I recommend you try to not pop up the dialogs immediately, but wait until after `mainloop` starts running (eg: you can put them in a function, and call the function with `after_idle`). – Bryan Oakley Dec 14 '17 at 20:44
  • @BryanOakley There is no icon for `root` if I do not invoke the dialog. Also, the title of that icon suggests that it refers to the dialog. Furthermore, in the real script, more than two `tkMessageBox.askyesno` dialogs are invoked one after another and I get more than two icons. I do not use the main loop of `tkinter`, since I am using `pyinotify`, which has its own main loop. Any other workaround? – AlwaysLearning Dec 15 '17 at 09:05

0 Answers0