-
Notifications
You must be signed in to change notification settings - Fork 8
/
example.py
44 lines (34 loc) · 1.41 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import platform
from qtpy import QtWidgets
from breadcrumbsaddressbar import BreadcrumbsAddressBar
from breadcrumbsaddressbar.platform.common import if_platform
if platform.system() == "Windows":
from breadcrumbsaddressbar.platform.windows import (
event_device_connection, parse_message)
if __name__ == '__main__':
class Form(QtWidgets.QDialog):
def perm_err(self, path):
print('perm err', path)
def path_err(self, path):
print('path err', path)
def __init__(self): # pylint: disable=super-init-not-called
print(QtWidgets.QStyleFactory.keys())
# style = QtWidgets.QStyleFactory.create("fusion")
# self.app.setStyle(style)
super().__init__()
self.setLayout(QtWidgets.QHBoxLayout())
self.address = BreadcrumbsAddressBar()
self.layout().addWidget(self.address)
self.address.listdir_error.connect(self.perm_err)
self.address.path_error.connect(self.path_err)
@if_platform('Windows')
def nativeEvent(self, eventType, message):
msg = parse_message(message)
devices = event_device_connection(msg)
if devices:
print("insert/remove device")
self.address.update_rootmenu_devices()
return False, 0
app = QtWidgets.QApplication([])
form = Form()
form.exec_()