2

I would like to monitor the presence of USB devices and have found modules such as PyUSB that serve this purpose. However, I don't know how to run USB detection services alongside the Tkinter main loop. Is this possible?

sentinel
  • 401
  • 5
  • 14

2 Answers2

2

Before starting tk mainloop, start some separate thread that will monitor USBs. Or you can try using tk alarms http://www.pythonware.com/library/tkinter/introduction/x9507-alarm-handlers-and-other.htm to periodically check USB.

Zuljin
  • 2,612
  • 17
  • 14
0

Might I suggest that instead of trying to constantly monitor the presence of a USB device you include a search or refresh button that will check just once.

Symon
  • 2,170
  • 4
  • 26
  • 34
  • 1
    Why make the user do something the computer is perfectly capable of doing? Does the app serve the user or the other way around? It might be OK to _also_ include the button to give the user a place to force a check if they think the automatic check isn't working, but it shouldn't be the only way. – Bryan Oakley Mar 30 '11 at 21:58
  • I realize that, I was just trying to provide an alternate answer that might be easier for him to implement. For example if i were simply whipping up an application for my own personal use I wouldn't mind needing to push a button. – Symon Mar 31 '11 at 13:54