Python Forum
[Tkinter] program unresponsive during pynput mouse click
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] program unresponsive during pynput mouse click
#2
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
Reply


Messages In This Thread
RE: program unresponsive during pynput mouse click - by RobotTech - May-07-2020, 04:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter - touchscreen, push the button like click the mouse John64 5 873 Jan-06-2024, 03:45 PM
Last Post: deanhystad
  Application becomes unresponsive as soon as i use the buttons AX_LEARNS 2 763 May-26-2023, 03:33 AM
Last Post: deanhystad
  [Tkinter] Mouse click without use bind ATARI_LIVE 8 7,489 Oct-23-2020, 10:41 PM
Last Post: ATARI_LIVE
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 3,779 Dec-16-2019, 04:47 AM
Last Post: woooee
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,039 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [PyQt] `QPushButton` without mouse click animation Atalanttore 2 5,879 Apr-22-2019, 01:00 PM
Last Post: Atalanttore
  QTabBar Indexing is wrong for right mouse click xenas 2 2,537 Jan-04-2019, 10:08 PM
Last Post: xenas
  right mouse button click with PyQt5 brecht83 4 19,433 Nov-09-2018, 02:55 PM
Last Post: brecht83
  [PyQt] QSlider jump to mouse click position MegasXLR 2 8,269 May-26-2018, 08:55 AM
Last Post: MegasXLR
  [Tkinter] Window unresponsive when executed. fawazcode 2 3,817 Sep-11-2017, 12:29 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020