66
77from PySide6 import QtCore
88
9+ from ..Constants import PyinstallerArgs
910from .validators import FilePathValidator
1011
1112
@@ -32,7 +33,7 @@ def __init__(self, parent: Optional[QtCore.QObject] = None) -> None:
3233 self .FD : Optional [bool ] = None
3334 self .console : Optional [str ] = None
3435
35- def handle_option (self , option : tuple [str , str ]):
36+ def handle_option (self , option : tuple [PyinstallerArgs , str ]):
3637 """
3738 处理用户在界面选择的打包选项,进行有效性验证并保存 \n
3839 :param option: 选项
@@ -41,27 +42,27 @@ def handle_option(self, option: tuple[str, str]):
4142 arg_key , arg_value = option
4243
4344 # 进行有效性验证,有效则保存并发射option_set信号,无效则发射option_error信号
44- if arg_key == " script_path" :
45+ if arg_key == PyinstallerArgs . script_path :
4546 script_path = Path (arg_value )
4647 if FilePathValidator .validate_script (script_path ):
4748 self .script_path = script_path
4849 self .ready_to_pack .emit (True )
4950 self .option_set .emit (option )
5051 self .out_name = script_path .stem # 输出名默认与脚本名相同
51- self .option_set .emit ((" out_name" , self .out_name ))
52+ self .option_set .emit ((PyinstallerArgs . out_name , self .out_name ))
5253 else :
5354 self .ready_to_pack .emit (False )
5455 self .option_error .emit (arg_key )
5556
56- elif arg_key == " icon_path" :
57+ elif arg_key == PyinstallerArgs . icon_path :
5758 icon_path = Path (arg_value )
5859 if FilePathValidator .validate_icon (icon_path ):
5960 self .icon_path = icon_path
6061 self .option_set .emit (option )
6162 else :
6263 self .option_error .emit (arg_key )
6364
64- elif arg_key == " out_name" :
65+ elif arg_key == PyinstallerArgs . out_name :
6566 self .out_name = arg_value
6667 self .option_set .emit (option )
6768
0 commit comments