22import os
33import subprocess
44import time
5- from enum import Enum
65
76import wx
87
1110import threading
1211
1312from command import concat_filter , merge_filestream_audio_channel
13+ from message import ExportMessage , WorkStateEnum
14+
1415from pymediainfo import MediaInfo
1516
1617VERSION = "0.2.0"
@@ -30,16 +31,6 @@ def OnDropFiles(self, x, y, filenames):
3031
3132# TODO: 重写配置的参数验证,建立物品类和导出配置 ExportConfig
3233
33- class ExportMessageState (Enum ):
34- SUCCESS = "成功"
35- ERROR = "错误"
36-
37-
38- class ExportMessage :
39- def __init__ (self , state : ExportMessageState , message : any ):
40- self .state = state
41- self .message = message
42-
4334
4435# Implementing MainFrame
4536class SimpleCutPyMainFrame (SimpleCutPy .MainFrame ):
@@ -192,16 +183,15 @@ def ExportBtnOnClick(self, event):
192183 export_name = export_path + '/' + export_name
193184 else :
194185 # 默认使用第一个文件的目录
195- # os.chdir(os.path.dirname(self.item_list[0]["path"]))
196186 path = os .path .dirname (self .item_list [0 ]["path" ])
197187 export_name = path + '/' + export_name
198188
199- threading .Thread (target = self .export_videofile , args = (export_amix , export_mbps , export_name )).start ()
189+ threading .Thread (target = self .export_video_file , args = (export_amix , export_mbps , export_name )).start ()
200190 self .ExportBtn .Disable ()
201191
202192 return
203193
204- def export_videofile (self , export_amix , export_mbps , export_name ):
194+ def export_video_file (self , export_amix , export_mbps , export_name ):
205195 # 导出命令
206196 console_command = 'ffmpeg '
207197 filter_complex_string = '-filter_complex '
@@ -260,10 +250,10 @@ def export_videofile(self, export_amix, export_mbps, export_name):
260250 subprocess .run (console_command , shell = False , check = True , creationflags = subprocess .CREATE_NO_WINDOW )
261251
262252 # 完成命令,发送事件
263- wx .CallAfter (self .on_export_done , ExportMessage (ExportMessageState .SUCCESS , "导出完成" ))
253+ wx .CallAfter (self .on_export_done , ExportMessage (WorkStateEnum .SUCCESS , "导出完成" ))
264254 except subprocess .CalledProcessError as e :
265255 # 导出失败,发送事件
266- wx .CallAfter (self .on_export_done , ExportMessage (ExportMessageState . ERROR , e ))
256+ wx .CallAfter (self .on_export_done , ExportMessage (WorkStateEnum . FAIL , e ))
267257
268258 def ProjectWebBtnOnClick (self , event ):
269259 # TODO: Implement ProjectWebBtnOnClick
@@ -299,14 +289,28 @@ def append_files(self, filename, path):
299289 self .add_files (item_no , filename , path )
300290
301291 def OnStartTimeCtrlText (self , event ):
292+ """修改开始时间输入框的时候修改itemlist的start_time"""
302293 first_selected_index = self .first_selected_index
303- self .item_list [first_selected_index ]["start_time" ] = self .format_time (self .StartTimeCtrl .GetValue ())
294+ value = self .StartTimeCtrl .GetValue ()
295+
296+ if value == '' :
297+ value = "开头"
298+ self .item_list [first_selected_index ]["start_time" ] = value
299+ else :
300+ self .item_list [first_selected_index ]["start_time" ] = self .format_time (value )
304301
305302 self .list_load_item (self .item_list [first_selected_index ], first_selected_index )
306303
307304 def OnEndTimeCtrlText (self , event ):
305+ """修改结束时间输入框的时候修改itemlist的end_time"""
308306 first_selected_index = self .first_selected_index
309- self .item_list [first_selected_index ]["end_time" ] = self .format_time (self .EndTimeCtrl .GetValue ())
307+ value = self .EndTimeCtrl .GetValue ()
308+
309+ if value == '' :
310+ value = "结尾"
311+ self .item_list [first_selected_index ]["end_time" ] = value
312+ else :
313+ self .item_list [first_selected_index ]["end_time" ] = self .format_time (value )
310314
311315 self .list_load_item (self .item_list [first_selected_index ], first_selected_index )
312316
@@ -357,11 +361,19 @@ def list_load_item(self, load_item, list_ctrl_index):
357361 self .list_ctrl .SetItem (list_ctrl_index , 3 , load_item ["end_time" ])
358362 self .list_ctrl .SetItem (list_ctrl_index , 4 , load_item ["path" ])
359363
364+ def list_load_all_item (self ):
365+ """
366+ 把物品列表上的所有物品载入到用户界面的控件上
367+ :return:
368+ """
369+ for item in self .item_list :
370+ self .list_load_item (item , item ["no" ])
371+
360372 def on_export_done (self , msg : ExportMessage ):
361373 logging .debug (f"Export Done: { msg } " )
362- if msg .state == ExportMessageState .SUCCESS :
374+ if msg .state == WorkStateEnum .SUCCESS :
363375 wx .MessageBox ("导出成功" , "提示" , wx .OK | wx .ICON_INFORMATION )
364- elif msg .state == ExportMessageState . ERROR :
376+ elif msg .state == WorkStateEnum . FAIL :
365377 logging .error (f"Export Error: { msg .message } " )
366378 wx .MessageBox ("导出失败" , "提示" , wx .OK | wx .ICON_INFORMATION )
367379
0 commit comments