import re from urllib import parse import tkinter as tk import tkinter.messagebox as msgbox import webbrowser class App(object): def __init__(self,width=500, height=300): self.w = width self.h = height # 软件名称 self.title = "视频解析助手" self.root = tk.Tk(className=self.title) self.url = tk.StringVar() # 控制单元选框默认选中的属性 self.v = tk.IntVar() # 软件空间划分 self.v.set(1) frame1 = tk.Frame(self.root) frame2 = tk.Frame(self.root) # 软件控件内容设置 group = tk.Label(frame1, text="播放通道", padx=10, pady=10) tb = tk.Radiobutton(frame1, text="唯一通道", variable=self.v, value=1,width=10,height=3) lable = tk.Label(frame2, text="请输入视频播放地址:") entry = tk.Entry(frame2, textvariable=self.url, highlightcolor="Fuchsia", highlightthickness=1, width=30) play = tk.Button(frame2, text="播放", font=("楷体", 12), fg="Purple", width=2, height=1, command=self.video_play) # 空间布局 # 激活空间 frame1.pack() frame2.pack() group.grid(row=0, column=0) tb.grid(row=0, column=1) lable.grid(row=0, column=0) entry.grid(row=0, column=1) play.grid(row=0, column=2, ipadx=10, ipady=10) # 解析电影 def video_play(self): port = "http://www.wmxz.wang/video.php?url=" if re.match(r'https?:/{2}w.+$', self.url.get()): ip = self.url.get() ip = parse.quote_plus(ip) webbrowser.open(port + ip) else: msgbox.showerror(title="错误", message="视频地址无效,请输入正确发的地址:") def loop(self): self.root.mainloop() if __name__ == '__main__': app = App() app.loop()