import Tkinter as tk
import time
def processButton():
if v1.get() == 1:
window2 = tk.Tk()
window2.title("result")
text2 = tk.Text(window2)
text2.pack()
text2.insert('end','T1\n')
text2.insert('end', 'R1')
else:
t=text.get("0.0", "end")
window2 = tk.Tk()
window2.title("result")
text2 = tk.Text(window2)
text2.pack()
time.sleep(15)
text2.insert('end', 'T1'
+'\nR2'
+'\nT2'
+'\nR2')
window = tk.Tk()
window.title("Demo")
frame1 = tk.Frame(window)
frame1.pack()
text = tk.Text(window)
text.pack()
v1 =tk. IntVar()
rbDanju = tk.Radiobutton(frame1, text="单句分析",
variable=v1, value=1,
)
rbPiliang =tk. Radiobutton(frame1, text="批量分析",
variable=v1, value=2,
)
rbFenxi = tk.Button(frame1, text="分析", command = processButton)
rbDanju.grid(row=1, column=1)
rbPiliang.grid(row=1, column=2)
rbFenxi.grid(row=1,column=3)
frame2 =tk. Frame(window)
frame2.pack()
l1=tk.Label(frame2, text="单句分析只分析文本第一行",justify='left')
l1.grid(sticky=tk.E)
window.mainloop()
v1 =tk. IntVar()
rbDanju = tk.Radiobutton(frame1, text="单句分析",
variable=v1, value=1,
)
rbPiliang =tk. Radiobutton(frame1, text="批量分析",
variable=v1, value=2,
)
rbFenxi = tk.Button(frame1, text="分析", command = processButton)
rbDanju.grid(row=1, column=1)
rbPiliang.grid(row=1, column=2)
rbFenxi.grid(row=1,column=3)
frame2 =tk. Frame(window)
frame2.pack()
l1=tk.Label(frame2, text="单句分析只分析文本第一行",justify='left')
l1.grid(sticky=tk.E)
window.mainloop()
图形化界面: