Code flow question due to unexpected code flow (I feel that this is correct anyway …)
I have a situation where I have a treeview. To this treeview I bind the click of the left mouse button which then executes a function which is a lambda event : previewInMain(treeLocal, win)
Per … (yeah, I know I’m passing win, but I hate globals as I fear they waste memory … I find it hard to drop old habits I regret. apologise in advance for my ineptitude. but … I’m still fairly new to Python … < 3 months.)
treeLocal.bind(’’, lambda event: previewInMain(treeLocal, win))
When previewInMain(treeLocal, win)) is called, the element of the treeview returns the previously selected item in the treeview list, not the one that has just now been selected by the single mouse click. If I move this to a double mouse click, it functions properly but while it’s on the single mouse click, the previous element is the element that is returned as selected. To my mind, the selected element is returning the element previously being returned prior to the new mouse click event. Is this just how it works or am I doing something fundamentally wrong? Any thoughts or work arounds would be greatly appreciated as my selected element in the called function is therefore one element behind the one that is currently highlighted. I’m guessing that the sending of the event is p[art if not most of the problem, so I’m looking for a work around I guess…My thoughts are that the lambda fucntion is being executed prior to the event, but then …? Any thoughts?