first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import sys
|
||||
from PyQt6.QtWidgets import QApplication, QWidget
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
class DropWidget(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setAcceptDrops(True)
|
||||
self.resize(400, 300)
|
||||
self.setWindowTitle("Drag & Drop Monitor")
|
||||
print("Окно готово к приему перетаскивания. Перетащите что-нибудь сюда.")
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
mime_data = event.mimeData()
|
||||
formats = mime_data.formats()
|
||||
print("Типы перетаскиваемых данных:", [str(f) for f in formats])
|
||||
|
||||
if mime_data.hasUrls():
|
||||
print("Перетаскиваются файлы или ссылки")
|
||||
elif mime_data.hasText():
|
||||
print("Перетаскивается текст")
|
||||
elif mime_data.hasImage():
|
||||
print("Перетаскивается изображение")
|
||||
elif mime_data.hasHtml():
|
||||
print("Перетаскивается HTML")
|
||||
else:
|
||||
print("Неизвестный тип данных")
|
||||
|
||||
event.accept()
|
||||
|
||||
def dropEvent(self, event):
|
||||
print("Объект сброшен.")
|
||||
event.accept()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
window = DropWidget()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
Reference in New Issue
Block a user