在检测到闪存驱动器Tkinter时更改窗口

时间:2018-09-16 10:24:49

标签: python-3.x tkinter usb

到目前为止,我有一个GUI,但是现在我在USB插入时如何更改窗口方面遇到了问题。我尝试使用pyudev来监视设备,但是每当我在GUI代码中添加pyudev时,即使这些代码在分离时都起作用,它也不会运行。我也想在GUI中列出文件,以便用户可以选择要打印的文件。先感谢您! :) 这是我用于检测USB设备的代码。

import pyudev

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='usb')

for device in iter(monitor.poll, None):
    if device.action == 'add':
        print('{} connected'.format(device))

    if device.action == 'remove':
        print('{} removed' .format(device))

0 个答案:

没有答案