@@ -25,7 +25,7 @@ def init_ui(self):
25
25
self .update_text ('将ncm文件拖拽到此处' ) # 初始文本内容
26
26
def create_base_pixmap (self ):
27
27
"""创建不包含文本的基础背景图片"""
28
- self .base_pixmap = QPixmap (get_resource_path ("file/bk.png" ))
28
+ self .base_pixmap = QPixmap (self . get_resource_path ("file/bk.png" ))
29
29
self .label = QLabel (self )
30
30
self .label .setPixmap (self .base_pixmap )
31
31
self .label .setGeometry (0 , 0 , 573 , 573 )
@@ -59,14 +59,20 @@ def dragEnterEvent(self, event: QDragEnterEvent):
59
59
event .acceptProposedAction ()
60
60
61
61
def dropEvent (self , event : QDropEvent ):
62
- for url in event .mimeData ().urls ():
63
- file_path = url . toLocalFile ()
64
- if file_path . endswith ( ".ncm" ) :
62
+ file_paths = [ url . toLocalFile () for url in event .mimeData ().urls () if url . toLocalFile (). endswith ( ".ncm" )]
63
+ if file_paths :
64
+ for file_path in file_paths :
65
65
try :
66
66
dump (file_path )
67
- self .update_text (f"处理完成:{ file_path } " )
67
+ file_name = os .path .basename (file_path )
68
+ self .update_text (f"处理完成:{ file_name } " )
69
+ QApplication .processEvents ()
68
70
except Exception as e :
69
- self .update_text (f"处理文件时出错:{ str (e )} " )
71
+ file_name = os .path .basename (file_path )
72
+ self .update_text (f"处理文件时出错:{ file_name } : { str (e )} " )
73
+ QApplication .processEvents ()
74
+ else :
75
+ self .update_text ("没有找到 .ncm 文件" )
70
76
71
77
72
78
if __name__ == "__main__" :
0 commit comments