From f8f267fb15287f6f8e679698e55dd5a8e5f142b8 Mon Sep 17 00:00:00 2001 From: work-dell-pc Date: Thu, 20 Jun 2024 09:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=8F=E5=B0=8F=E4=BA=86=E7=AA=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- gui.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 42c7b1d..03f4580 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ pyinstaller --onefile --add-data="file:file" -wF -i file/favicon-32x32.png -n "N ``` 效果: -![s3](./file/s1.gif) +![s3](./file/s3.gif) ### 2.2 WEB diff --git a/gui.py b/gui.py index 82e1205..4fda287 100644 --- a/gui.py +++ b/gui.py @@ -13,15 +13,14 @@ def __init__(self, parent=None): def init_ui(self): self.setWindowTitle("NCM转换器") - self.setGeometry(100, 100, 573, 573) + self.setGeometry(100, 100, 400, 400) # 调整窗体尺寸 self.setWindowIcon(QIcon(self.get_resource_path("file/favicon-32x32.png"))) # 加载图片 self.original_pixmap = QPixmap(self.get_resource_path("file/bk.png")) self.label = QLabel(self) - self.label.setPixmap(self.original_pixmap) - self.label.setGeometry(0, 0, 573, 573) + self.label.setGeometry(0, 0, 400, 400) # 调整标签尺寸 self.update_text('将ncm文件拖拽到此处') # 初始文本内容 def create_base_pixmap(self): """创建不包含文本的基础背景图片""" @@ -31,7 +30,8 @@ def create_base_pixmap(self): self.label.setGeometry(0, 0, 573, 573) def update_text(self, text): - pixmap = self.original_pixmap.copy() # 复制原始的 QPixmap 对象 + resized_pixmap = self.original_pixmap.scaled(self.label.size(), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation) + pixmap = resized_pixmap.copy() # 复制调整大小后的 QPixmap 对象 painter = QPainter(pixmap) painter.setPen(QColor('black')) # 设置文本颜色 font = QFont('SimHei', 20) # 设置字体和大小