-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdragdroparea.py
42 lines (26 loc) · 878 Bytes
/
dragdroparea.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
from PyQt5.QtWidgets import QWidget, QComboBox, QLabel, QVBoxLayout
class ComboBox(QComboBox):
def __init__(self, parent=None):
super().__init__()
self.setAcceptDrops(True)
self.parent = parent
def dragEnterEvent(self, e):
print(e)
if e.mimeData().hasText():
e.accept()
else:
e.ignore()
def dropEvent(self, e):
self.addItem(e.mimeData().text())
self.parent.on_file_upload(e.mimeData().text())
class DragDropArea(QWidget):
def __init__(self, parent=None):
super().__init__()
self.parent = parent
self.init_ui()
def init_ui(self):
layout = QVBoxLayout()
layout.addWidget(QLabel("Drag and drop music file here"))
com = ComboBox(parent=self.parent)
layout.addWidget(com)
self.setLayout(layout)