shorts_factory/MakeVideo4.py

77 lines
3.2 KiB
Python

import tkinter as tk
from tkinter import ttk, filedialog, messagebox, simpledialog
class VideoCreatorApp:
def __init__(self, master):
self.master = master
self.master.title('Video Creator')
self.init_ui()
# 시퀀스 데이터 관리
self.sequence = [] # 스크립트, 이미지, 액션을 포함하는 시퀀스
def init_ui(self):
self.sequence_frame = ttk.Frame(self.master)
self.sequence_frame.pack(fill=tk.BOTH, expand=True)
self.add_script_button = ttk.Button(self.sequence_frame, text="Insert Script", command=self.insert_script)
self.add_script_button.pack(fill=tk.X)
self.add_image_button = ttk.Button(self.sequence_frame, text="Insert Image", command=self.insert_image)
self.add_image_button.pack(fill=tk.X)
self.add_action_button = ttk.Button(self.sequence_frame, text="Insert Action", command=self.insert_action)
self.add_action_button.pack(fill=tk.X)
self.create_video_button = ttk.Button(self.sequence_frame, text="Create Video", command=self.create_video)
self.create_video_button.pack(fill=tk.X)
self.sequence_listbox = tk.Listbox(self.sequence_frame)
self.sequence_listbox.pack(fill=tk.BOTH, expand=True)
def insert_script(self):
script_text = simpledialog.askstring("Input", "Enter your script:")
if script_text:
self.sequence.append({'type': 'script', 'content': script_text})
self.update_sequence_listbox()
def insert_image(self):
file_path = filedialog.askopenfilename(filetypes=(("Image files", "*.jpg;*.png;*.gif;*.webp"), ("All files", "*.*")))
if file_path:
self.sequence.append({'type': 'image', 'content': file_path})
self.update_sequence_listbox()
def insert_action(self):
action_type = simpledialog.askstring("Input", "Enter action type (e.g., 'sleep', 'clean'):")
if action_type == "sleep":
duration = simpledialog.askinteger("Input", "Enter duration (seconds):")
self.sequence.append({'type': 'action', 'action': action_type, 'duration': duration})
elif action_type == "clean":
self.sequence.append({'type': 'action', 'action': action_type})
self.update_sequence_listbox()
def update_sequence_listbox(self):
self.sequence_listbox.delete(0, tk.END)
for item in self.sequence:
if item['type'] == 'script':
self.sequence_listbox.insert(tk.END, f"script {item['content'][:50]}...")
elif item['type'] == 'image':
self.sequence_listbox.insert(tk.END, f"image {item['content']}")
elif item['type'] == 'action':
if item['action'] == 'sleep':
self.sequence_listbox.insert(tk.END, f"action sleep {item['duration']}")
elif item['action'] == 'clean':
self.sequence_listbox.insert(tk.END, "action clean screen")
def create_video(self):
# 여기에 비디오 생성 로직을 구현
pass
def main():
root = tk.Tk()
app = VideoCreatorApp(root)
root.mainloop()
if __name__ == '__main__':
main()