Skip to content

Commit

Permalink
修改拖拽处理、debug
Browse files Browse the repository at this point in the history
  • Loading branch information
lissettecarlr committed Jun 20, 2024
1 parent 0b9852f commit 35b42e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pyinstaller --onefile --add-data="file:file" -wF -i file/favicon-32x32.png -n "N
```

效果:
![s1](./file/s1.gif)
![s3](./file/s1.gif)


### 2.2 WEB
Expand Down
Binary file added file/s3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 12 additions & 6 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def init_ui(self):
self.update_text('将ncm文件拖拽到此处') # 初始文本内容
def create_base_pixmap(self):
"""创建不包含文本的基础背景图片"""
self.base_pixmap = QPixmap(get_resource_path("file/bk.png"))
self.base_pixmap = QPixmap(self.get_resource_path("file/bk.png"))
self.label = QLabel(self)
self.label.setPixmap(self.base_pixmap)
self.label.setGeometry(0, 0, 573, 573)
Expand Down Expand Up @@ -59,14 +59,20 @@ def dragEnterEvent(self, event: QDragEnterEvent):
event.acceptProposedAction()

def dropEvent(self, event: QDropEvent):
for url in event.mimeData().urls():
file_path = url.toLocalFile()
if file_path.endswith(".ncm"):
file_paths = [url.toLocalFile() for url in event.mimeData().urls() if url.toLocalFile().endswith(".ncm")]
if file_paths:
for file_path in file_paths:
try:
dump(file_path)
self.update_text(f"处理完成:{file_path}")
file_name = os.path.basename(file_path)
self.update_text(f"处理完成:{file_name}")
QApplication.processEvents()
except Exception as e:
self.update_text(f"处理文件时出错:{str(e)}")
file_name = os.path.basename(file_path)
self.update_text(f"处理文件时出错:{file_name}: {str(e)}")
QApplication.processEvents()
else:
self.update_text("没有找到 .ncm 文件")


if __name__ == "__main__":
Expand Down

0 comments on commit 35b42e6

Please sign in to comment.