May-07-2020, 04:43 PM
def grab_mouse1 (): try: with Listener(on_click=on_click,on_scroll=on_scroll) as listener: listener.join() except:#<---- print("exception on the listener mouse1")#<---- finally:#<---- listener.stop()#<---- global left left = window_width global top top = window_height print('value1 x: {0} and value1 y: {1}'.format(window_width,window_height)) lbl_topleft = tk.Label(root, text = 'Mouse clicked at (x:{0} and y: {1})'.format(left, top), fg = 'green', font =('helvetica', 12, 'bold')) canvas1.create_window(150, 200, window = lbl_topleft) #when button 2 pressed listen to mouse input, when mouse input stop output to label 2 def grab_mouse2 (): try: with Listener(on_click=on_click,on_scroll=on_scroll) as listener: listener.join() except :#<---- print("exception on the listener mouse2")#<---- finally:#<---- listener.stop()#<---- global right right = window_width global bottom bottom = window_height print('value2 x: {0} and value2 y: {1}'.format(window_width,window_height)) lbl_bottomright = tk.Label(root, text = 'Mouse clicked at (x:{0} and y: {1})'.format(right, bottom), fg = 'green', font =('helvetica', 12, 'bold')) canvas1.create_window(150, 220, window = lbl_bottomright)by modifying my try/exception function to have finally I have handled the unresponsive but not the exception. the result is the same but i would like to not have the exception.
so my self declared error was reduced to a warning but we are shooting for 100/100 here
Please let me know what you think, Thank you for your help