fix: improve ui.py code quality
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
||||
QLineEdit, QPushButton, QLabel, QComboBox,
|
||||
QProgressBar, QTextEdit, QFrame)
|
||||
from PySide6.QtCore import Qt, QRect
|
||||
from PySide6.QtGui import QPixmap, QPainter, QPen, QColor, QBrush
|
||||
QProgressBar, QTextEdit, QFrame, QFileDialog)
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
|
||||
class DropZone(QFrame):
|
||||
file_dropped = Signal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setAcceptDrops(True)
|
||||
@@ -48,14 +49,13 @@ class DropZone(QFrame):
|
||||
if urls:
|
||||
self.file_selected = urls[0].toLocalFile()
|
||||
event.acceptProposedAction()
|
||||
self.parent().on_file_selected(self.file_selected)
|
||||
self.file_dropped.emit(self.file_selected)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
from PySide6.QtWidgets import QFileDialog
|
||||
filepath, _ = QFileDialog.getOpenFileName(self, "选择文件")
|
||||
if filepath:
|
||||
self.file_selected = filepath
|
||||
self.parent().on_file_selected(filepath)
|
||||
self.file_dropped.emit(filepath)
|
||||
|
||||
class UiCreator:
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user