1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| import tkinter
from tkinter.constants import *
def sendStr(): print('Data Send Ok!')
top = tkinter.Tk()
top.wm_geometry('320x480+1000+100')
top.wm_resizable(False,False)
top.title('TCP Server')
L1 = tkinter.Label(top, text='TCP Sever;\n20108/09/15', width=15, justify=LEFT, relief=RIDGE, background='#6699ff', )\ .pack_configure(anchor=S, side=TOP, ipady=2, pady=2, fill=NONE)
frame1 = tkinter.Frame(top,height=80,width=60,relief=RIDGE, bg='#ff3399',bd=5,borderwidth=4)
frame1.pack(fill=NONE,ipady=2,expand=False)
L2 = tkinter.Label(frame1,text='接\n收\n区',width=2, justify=LEFT, font=("宋体", 12, "bold"),)\ .pack(padx=2,pady=40,side=LEFT,anchor=N)
txt1 = tkinter.Text(frame1,width = 40, height = 10).pack(padx=2,pady=10,side=RIGHT,anchor=N)
frame2 = tkinter.Frame(top, relief=RIDGE,bg='#3366ff') frame2.pack(fill=X, padx=2,pady=10,side=TOP)
chk_text = 'Hex Display' int_if_choise = tkinter.IntVar() chk1 = tkinter.Checkbutton(frame2,text=chk_text,font=('黑体',12),variable=int_if_choise,onvalue='OK',offvalue='NO') chk1.pack(fill=NONE,side=LEFT,padx=2,pady=10) print('shuchu:',int_if_choise)
frame3 = tkinter.Frame(top,height=120,width=60,relief=RIDGE, bg='#ff3399',bd=5,borderwidth=4)
frame3.pack(fill=X,ipady=2,expand=False)
ServerReceiveVar = tkinter.StringVar(top,'')
L3 = tkinter.Label(frame3, text='Cache&Input:',font=('黑体',12)) L3.pack(fill=NONE, expand=NO, side=TOP, anchor=W, padx=2,pady=10)
txt2 = tkinter.Text(frame3, height = 2, width = 30).pack(padx=2, pady=2, ipady=4, side=LEFT, anchor=N)
button1 = tkinter.Button(frame3,text='Send Str', command=sendStr).pack(side=TOP, anchor=W, padx=2, pady=4)
button2 = tkinter.Button(frame3,text="Exit",command=top.destroy).pack(side=TOP, anchor=N, padx=2, pady=10)
top.mainloop()
|