You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							39 lines
						
					
					
						
							1.3 KiB
						
					
					
				
			
		
		
	
	
							39 lines
						
					
					
						
							1.3 KiB
						
					
					
				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()) |