I am trying to write a function to dynamically resize an image displayed in a tkinter window. Therefore I bound this function to the Configure event:
connroot.
1) We don't know that, since we can't see your code...
2) Short answer is: you can't, because that's exactly what
event does! Long answer, you can, with a little trick/hack. Since anytime the window is changing, it will call all the binded functions to
, and the same happens anytime as the mouse button released (right after the last
call) we can create a flag/switch which will tell us, if the window was "configured" then we can check that switch anytime the mouse button is released, and switch it back to the default value after we ran some actions.
So if you want the image to resized only, when the mouse was released and the window was changed this is the code you need:
from tkinter import *
class Run:
def __init__(self):
self.root = Tk()
self.clicked = False
self.root.bind('', self.image_resize)
self.root.bind('', lambda e: self.click(True))
def image_resize(self, event):
if self.clicked:
print("I'm printed after .") # the action goes here!
self.click(False)
def click(self, value):
self.clicked = value
app = Run()
app.root.mainloop()