@@ -13,15 +13,14 @@ def __init__(self, parent=None):
13
13
14
14
def init_ui (self ):
15
15
self .setWindowTitle ("NCM转换器" )
16
- self .setGeometry (100 , 100 , 573 , 573 )
16
+ self .setGeometry (100 , 100 , 400 , 400 ) # 调整窗体尺寸
17
17
18
18
self .setWindowIcon (QIcon (self .get_resource_path ("file/favicon-32x32.png" )))
19
19
# 加载图片
20
20
self .original_pixmap = QPixmap (self .get_resource_path ("file/bk.png" ))
21
21
22
22
self .label = QLabel (self )
23
- self .label .setPixmap (self .original_pixmap )
24
- self .label .setGeometry (0 , 0 , 573 , 573 )
23
+ self .label .setGeometry (0 , 0 , 400 , 400 ) # 调整标签尺寸
25
24
self .update_text ('将ncm文件拖拽到此处' ) # 初始文本内容
26
25
def create_base_pixmap (self ):
27
26
"""创建不包含文本的基础背景图片"""
@@ -31,7 +30,8 @@ def create_base_pixmap(self):
31
30
self .label .setGeometry (0 , 0 , 573 , 573 )
32
31
33
32
def update_text (self , text ):
34
- pixmap = self .original_pixmap .copy () # 复制原始的 QPixmap 对象
33
+ resized_pixmap = self .original_pixmap .scaled (self .label .size (), Qt .AspectRatioMode .KeepAspectRatio , Qt .TransformationMode .SmoothTransformation )
34
+ pixmap = resized_pixmap .copy () # 复制调整大小后的 QPixmap 对象
35
35
painter = QPainter (pixmap )
36
36
painter .setPen (QColor ('black' )) # 设置文本颜色
37
37
font = QFont ('SimHei' , 20 ) # 设置字体和大小
0 commit comments