# -*- coding: UTF-8 -*-
from Tkinter import *
tk=Tk()
tk.geometry('500x400+500+200')
tk.title('API测试系统')
def close():
tk.destroy()
def turn1():
l1.pack_forget()
b1.pack_forget()
b2.pack_forget()
option.pack(side=TOP, expand=NO, fill=NONE)
b3.pack(side=TOP)
def turn2():
global type
type=var.get()
option.pack_forget()
b3.pack_forget()
l2.pack()
l3.pack()
l4.pack()
text1.pack()
b4.pack(side=RIGHT, expand=NO, fill=NONE)
b5.pack(side=RIGHT, expand=NO, fill=NONE)
def clear():
text1.delete(0.0, END)
def submit():
l2.pack_forget()
l3.pack_forget()
l4.pack_forget()
text1.pack_forget()
b4.pack_forget()
b5.pack_forget()
l5.pack(side=TOP,expand=YES,fill=X)
b6.pack(side=RIGHT,expand=NO,fill=NONE)
b7.pack(side=RIGHT,expand=NO,fill=NONE)
print type
global value
value=text1.get("0.0", "end").encode('utf-8')
print value
def result1():
l5.pack_forget()
b6.pack_forget()
b7.pack_forget()
l6.pack(side=TOP, fill=X)
labelframe1.pack(side=LEFT, fill=Y)
left1.pack()
labelframe2.pack(side=LEFT, fill=Y)
left2.pack()
labelframe3.pack(side=LEFT, fill=Y)
left3.pack()
labelframe4.pack(side=LEFT, fill=Y)
left4.pack() def result2():
l5.pack_forget()
b6.pack_forget()
b7.pack_forget()
l6.pack(side=TOP, fill=X)
labelframe1.pack(side=LEFT, fill=Y)
left1.pack()
labelframe2.pack(side=LEFT, fill=Y)
left2.pack()
labelframe3.pack(side=LEFT, fill=Y)
left3.pack()
labelframe4.pack(side=LEFT, fill=Y)
left4.pack()
# 初始化界面
l1=Label(tk,text='欢迎使用API测试系统,是否立即使用')
l1.pack(side=TOP,expand=YES,fill=X)
b1=Button(tk, text='否',command=close)
b1.pack(side=RIGHT, expand=NO, fill=NONE)
b2=Button(tk, text='是',command=turn1)
b2.pack(side=RIGHT, expand=NO, fill=NONE)
#获取请求方式
var=StringVar(tk)
var.set("GET")
option = OptionMenu(tk, var, "GET", "PUT", "POST", "DELETE")
option.pack_forget()
b3 = Button(tk, text="OK",command=turn2)
b3.pack_forget()
# 传输数据
l2=Label(tk,text='请输入sring类型的键值对数据:')
l2.pack_forget()
l3=Label(tk,text='参考格式:')
l3.pack_forget()
l4=Label(tk,text='{‘url’:‘url’,‘token’:‘token’,‘param’:‘param’}')
l4.pack_forget()
text1=Text(tk,width=50,height=20)
text1.pack_forget()
b4=Button(tk,text='提交',command=submit)
b4.pack_forget()
b5=Button(tk,text='重新填写',command=clear)
b5.pack_forget()
# 生成报告
l5=Label(tk, text='是否生成测试报告')
l5.pack_forget()
b6=Button(tk,text='否',command=result1)
b6.pack_forget()
b7=Button(tk,text='是',command=result2)
b7.pack_forget()
# 结果显示
l6=Label(tk, text='结果显示')
l6.pack_forget()
labelframe1 = LabelFrame(tk, text="API ")
labelframe1.pack_forget()
left1 = Label(labelframe1, text="test\n")
left1.pack_forget() labelframe2 = LabelFrame(tk, text="进度")
labelframe2.pack_forget()
left2 = Label(labelframe2, text="10%")
left2.pack_forget() labelframe3 = LabelFrame(tk, text="结果") left3 = Label(labelframe3, text="finished")
left3.pack() labelframe4 = LabelFrame(tk, text="时间")
labelframe4.pack_forget()
left4 = Label(labelframe4, text="2min")
left4.pack_forget()
tk.mainloop()