@@ -10,15 +10,58 @@ def __init__(self,parent=None):
1010 super (ZipPanel , self ).__init__ (parent )
1111 self .setupUi (self )
1212 self .serval_dict = {}
13- self .txt_display = "This function requires 7z, please show the correct path of 7z.exe\n "
13+ self .using7z = True
14+ import platform
15+ if platform .architecture ()[1 ].lower ().startswith ("windows" ):
16+ self .txt_display = "This function requires 7z, please show the correct path of 7z.exe.\n "
17+ self .txt_display += "Or you can choose to use internal zipfile tool instead.\n "
18+ else :
19+ self .txt_display = "You are not using Windows, you can only use internal zipfile tool.\n "
20+ self .btnZipTool .setEnabled (False )
21+ self .checkUsing7z .setChecked (True )
22+ self .checkUsing7z .setEnabled (False )
23+ self .using7z = False
1424 self .ziptool_Path = ""
1525 self .zip_Path = ""
1626 self .btnServal .clicked .connect (self .select_serval )
1727 self .btnZipTool .clicked .connect (self .select_zip )
1828 self .updatingTxtDisplay .connect (self .updateTxtDisplay )
1929 self .btnSave .clicked .connect (self .select_save )
2030 self .btnStart .clicked .connect (self .zip_pack )
31+ self .btnCut .clicked .connect (self .cut_serval )
32+ self .checkUsing7z .stateChanged .connect (self .using_ziptool_checked )
2133 self .updatingTxtDisplay .emit ()
34+ def using_ziptool_checked (self ):
35+ using_ziptool = self .checkUsing7z .checkState ()
36+ print (using_ziptool )
37+ if using_ziptool != 0 :
38+ self .txt_display += "Using internal zipfile tool instead now.\n "
39+ self .updatingTxtDisplay .emit ()
40+ self .using7z = False
41+ self .btnZipTool .setEnabled (False )
42+ else :
43+ self .txt_display += "Using 7z.exe now.\n "
44+ self .updatingTxtDisplay .emit ()
45+ self .using7z = True
46+ self .btnZipTool .setEnabled (True )
47+ def cut_serval (self ):
48+ if len (self .serval_dict )== 0 :
49+ QMessageBox .warning (self , "Cutting failed" , "Please Select the Save Path First!" , QMessageBox .Ok )
50+ return
51+ save_path = QFileDialog .getExistingDirectory (self ,"Select Path to Save Serval Files" ,os .getcwd ())
52+ if save_path != "" :
53+ filename_serval_dict = split_serval (self .serval_dict )
54+ try :
55+ for k ,v in filename_serval_dict .items ():
56+ with open (save_path + '/' + k + '.serval' ,'w' ,encoding = 'utf-8' ) as f :
57+ f .write (v )
58+ except Exception as e :
59+ print (str (e ))
60+ QMessageBox .warning (self , "Cutting failed" , "Please Make Sure Your Save Path is Available!" , QMessageBox .Ok )
61+ return
62+ QMessageBox .information (self ,"Saving Succeed" ,"Serval Files Saved Here:" + save_path ,QMessageBox .Ok )
63+ return
64+
2265 def select_save (self ):
2366 file_path_diag = QFileDialog .getSaveFileName (self , "Save File" , "C:/Users/" ,
2467 "7z files (*.7z);;all files(*.*)" )
0 commit comments