1 # -*- coding: UTF-8 -*- 2 from Tkinter import * 3 tk=Tk() 4 tk.geometry('500x400+500+200') 5 tk.title('API测试系统') 6 def close(): 7 tk.destroy() 8 def turn1(): 9 l1.pack_forget() 10 b1.pack_forget() 11 b2.pack_forget() 12 option.pack(side=TOP, expand=NO, fill=NONE) 13 b3.pack(side=TOP) 14 def turn2(): 15 global type 16 type=var.get() 17 option.pack_forget() 18 b3.pack_forget() 19 l2.pack() 20 l3.pack() 21 l4.pack() 22 text1.pack() 23 b4.pack(side=RIGHT, expand=NO, fill=NONE) 24 b5.pack(side=RIGHT, expand=NO, fill=NONE) 25 def clear(): 26 text1.delete(0.0, END) 27 def submit(): 28 l2.pack_forget() 29 l3.pack_forget() 30 l4.pack_forget() 31 text1.pack_forget() 32 b4.pack_forget() 33 b5.pack_forget() 34 l5.pack(side=TOP,expand=YES,fill=X) 35 b6.pack(side=RIGHT,expand=NO,fill=NONE) 36 b7.pack(side=RIGHT,expand=NO,fill=NONE) 37 print type 38 global value 39 value=text1.get("0.0", "end").encode('utf-8') 40 print value 41 def result1(): 42 l5.pack_forget() 43 b6.pack_forget() 44 b7.pack_forget() 45 l6.pack(side=TOP, fill=X) 46 labelframe1.pack(side=LEFT, fill=Y) 47 left1.pack() 48 labelframe2.pack(side=LEFT, fill=Y) 49 left2.pack() 50 labelframe3.pack(side=LEFT, fill=Y) 51 left3.pack() 52 labelframe4.pack(side=LEFT, fill=Y) 53 left4.pack() 54 55 def result2(): 56 l5.pack_forget() 57 b6.pack_forget() 58 b7.pack_forget() 59 l6.pack(side=TOP, fill=X) 60 labelframe1.pack(side=LEFT, fill=Y) 61 left1.pack() 62 labelframe2.pack(side=LEFT, fill=Y) 63 left2.pack() 64 labelframe3.pack(side=LEFT, fill=Y) 65 left3.pack() 66 labelframe4.pack(side=LEFT, fill=Y) 67 left4.pack() 68 # 初始化界面 69 l1=Label(tk,text='欢迎使用API测试系统,是否立即使用') 70 l1.pack(side=TOP,expand=YES,fill=X) 71 b1=Button(tk, text='否',command=close) 72 b1.pack(side=RIGHT, expand=NO, fill=NONE) 73 b2=Button(tk, text='是',command=turn1) 74 b2.pack(side=RIGHT, expand=NO, fill=NONE) 75 #获取请求方式 76 var=StringVar(tk) 77 var.set("GET") 78 option = OptionMenu(tk, var, "GET", "PUT", "POST", "DELETE") 79 option.pack_forget() 80 b3 = Button(tk, text="OK",command=turn2) 81 b3.pack_forget() 82 # 传输数据 83 l2=Label(tk,text='请输入sring类型的键值对数据:') 84 l2.pack_forget() 85 l3=Label(tk,text='参考格式:') 86 l3.pack_forget() 87 l4=Label(tk,text='{‘url’:‘url’,‘token’:‘token’,‘param’:‘param’}') 88 l4.pack_forget() 89 text1=Text(tk,width=50,height=20) 90 text1.pack_forget() 91 b4=Button(tk,text='提交',command=submit) 92 b4.pack_forget() 93 b5=Button(tk,text='重新填写',command=clear) 94 b5.pack_forget() 95 # 生成报告 96 l5=Label(tk, text='是否生成测试报告') 97 l5.pack_forget() 98 b6=Button(tk,text='否',command=result1) 99 b6.pack_forget() 100 b7=Button(tk,text='是',command=result2) 101 b7.pack_forget() 102 # 结果显示 103 l6=Label(tk, text='结果显示') 104 l6.pack_forget() 105 labelframe1 = LabelFrame(tk, text="API ") 106 labelframe1.pack_forget() 107 left1 = Label(labelframe1, text="test ") 108 left1.pack_forget() 109 110 labelframe2 = LabelFrame(tk, text="进度") 111 labelframe2.pack_forget() 112 left2 = Label(labelframe2, text="10%") 113 left2.pack_forget() 114 115 labelframe3 = LabelFrame(tk, text="结果") 116 117 left3 = Label(labelframe3, text="finished") 118 left3.pack() 119 120 labelframe4 = LabelFrame(tk, text="时间") 121 labelframe4.pack_forget() 122 left4 = Label(labelframe4, text="2min") 123 left4.pack_forget() 124 tk.mainloop()