0

I have a couple of treeviews tkinter widgets. For style purposes i need to prevent a manual resizing of the treeview columns width without totally disableing column resize.

Using a possible solution provided here: How to disable manual resizing of Tkinter's Treeview column? i am catching single click events on separators between the columns and stop the event there. For this purpose every treeview binds a handling function.

Example:

self.tree.bind('<Button-1>', lambda event: handle_treeview_single_click(self.tree, event))

def handle_treeview_single_click(tree, event):
    if tree.identify_region(event.x, event.y) == 'separator':
        return 'break'

Running the code produce the following error:

  File "C:\Program Files (x86)\Python27\ArcGIS10.2\lib\lib-tk\ttk.py", line 1277, in identify
    return self.tk.call(self._w, "identify", component, x, y)
TclError: bad component "region": must be row or column

this doesn't change regardless the object i click on (Header, cell or separator). For example the relating parameter look like this:

tree = Treeview: .42424440.47830640.47831440.47831800.47831840
x = 464 
y = 14

Not sure what im missing here, even more since im fairly new to python.

Kamakiri
  • 63
  • 2
  • 7
  • I fully understand the reason behind the downvote. From the perspectiv of an experienced developer it may look like a dumb question. Using pycharm and debugging it as an inexperiencend one it was still hard to point out the problem. I tried a lot before posting here. Referring to: http://idownvotedbecau.se/noattempt/ Maybe you can think about it. – Kamakiri Jan 17 '18 at 15:02

1 Answers1

1

There is a comment in the ttk source code that explains why this might not be working:

def identify_region(self, x, y):
    """
    ...
    * Availability: Tk 8.6"""
    return self.identify("region", x, y)

Since you're using python 2.7, you probably aren't using tk 8.6. You can verify this by printing out the value of Tkinter.TkVersion

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685