【发布时间】:2021-08-12 05:38:02
【问题描述】:
from tkinter import filedialog, font
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry("300x100")
root.title("SRT")
root.resizable(False, False)
frame = Frame(root)
frame.grid(column=1, row =0)
def open():
b.destroy()
filename1 = filedialog.askopenfilename(filetypes=[("SRT files(*.srt)", "*.srt")],initialdir = "/", title = "Select file")
root.geometry("775x300")
k=Label(frame,text="SELECTED SUBTITLE",font=("Times New Roman", 15)).grid(column=3, row =0)
y=Label(frame,text=filename1,font=("Times New Roman", 12)).grid(column=3, row =1)
seconds=Label(root, font=("Times New Roman", 15),text="Seconds").grid(column=2,row=2)
minutes=Label(root, font=("Times New Roman", 15),text="Minutes").grid(column=0,row=2,ipadx=20)
minuteselect = StringVar()
minutes = ttk.Combobox(root, textvariable=minuteselect)
minutes['values']=tuple([i for i in range(1,61)])
minutes['state'] = 'readonly'
minutes.grid(column=0,row=4,padx=10)
secondselect = StringVar()
seconds = ttk.Combobox(root, textvariable=secondselect)
seconds['values']=tuple([i for i in range(1,61)])
seconds['state'] = 'readonly'
seconds.grid(column=2,row=4)
plus =Button(root,text="DECREASE", width='10', height='1').place(x=400,y=150)
minus =Button(root,text="INCREASE", width='10', height='1').place(x=280,y=150)
b =Button(frame,text="Select The Subtitle", width='30', height='1',command=open)
b.grid(row=1, column=1,padx=41,pady=30)
b.rowconfigure(1, weight=1)
b.columnconfigure(1, weight=1)
root.mainloop()
我正在尝试构建一个同步 srt 文件的应用程序,并在从用户输入同步字幕文件的时间后创建一个新文件。我目前被困在如何从两个 Combobox 中检索数据并根据用户的输入处理文件。 在我的代码中,我尝试直接输入一个文件并打开第二个窗口,该窗口使用 2 个组合框和两个按钮 INCREASE 和 DECREASE 给出选项分钟和秒,如果单击增加,它将重定向到一个从组合框并使用提供的功能增加 srt 文件中的时间 py 模块 pysrt 反之亦然,如果我单击减少。我目前被困在如何获得两个输入:(1)以秒和分钟为单位的时间和(2)增加或减少按钮并相应地调用函数。
【问题讨论】: