Skip to content Skip to sidebar Skip to footer

Python Tkinter Treeview Not Allowing Modal Window With Direct Binding Like On_rightclick

Treeview with mouseclick binding that directly calls a function to open a modal window fails on grab_set() tkinter.TclError: grab failed: window not viewable The same works perfe

Solution 1:

I use Linux Mint 17/Ubuntu 14.04, 64bit, Python 3 too.

You can always check source code of existing dialogs and see how it works.

For example check filedialogs - path to file with source code:

import tkinter.filedialog

print(tkinter.filedialog.__file__)

# /usr/lib/python3.5/tkinter/filedialog.py

and you will see

self.top.wait_visibility() # window needs to be visible for the grabself.top.grab_set()

So you have to use wait_visibility() before grab_set()

defshowIsNotModal(self, item):
    print("you clicked on", self.tree.item(item, "text"))
    pup = PopupWindow(self.root);
    pup.tLabel2['text'] = "Sadly no: grab_set() fails"

    pup.wait_visibility() # <-----

    pup.grab_set()
    self.root.wait_window(pup)

Post a Comment for "Python Tkinter Treeview Not Allowing Modal Window With Direct Binding Like On_rightclick"