Python+tkinter+other制作可视化界面

最近做毕业设计,两周自学python,做了一些简单的GUI界面,以下代码为界面源码,明天文件打包EXE以下源码和运行界面展示:

捕获.GIF
捕获1.GIF
捕获2.GIF
window = tk.Tk()
window.title("Welcome to RC4 and WEP change system")
window.geometry('800x600')
def command_file():
    window_one = tk.Toplevel(window)
    window_one.geometry('800x700')
    window_one.title("HELP INFORMATION:")

    tk.Label(window_one, text="WEP加密解密模型:", font=font1).place(x=10, y=30)
    tk.Label(window_one, text="1:初始化SK由用户自行设置或系统预设,系统预设一般为四个共享密钥", font=font).place(x=10, y=500)
    tk.Label(window_one, text="2:IV向量由系统自行生成,具有一定的周期,模拟系统周期为999,IV用于完成一次一密", font=font).place(x=10, y=550)
    tk.Label(window_one, text="3:CRC32用于产生原文校验码,用于验证明文是否遭受篡改", font=font).place(x=10, y=600)
    canvas = tk.Canvas(window_one, width=700, height=400, bg='white')
    img = tk.PhotoImage(file="E:\\pro\\毕业设计成品1_1\\2.gif")
    canvas.place(x=10, y=70)
    canvas.create_image(0, 0, anchor='nw', image=img)
    img.put()
def command_help():

    window_one = tk.Toplevel(window)
    window_one.geometry('800x700')
    window_one.title("HELP INFORMATION:")

    tk.Label(window_one, text="RC4改进算法在无线网络安全的应用:", font=font1).place(x=10, y=30)
    tk.Label(window_one, text="1:初始化SK(共享密钥经过安全信道传输):", font=font).place(x=10, y=500)
    tk.Label(window_one, text="2:初始化密钥对其自身进行加密产生IV,KC和新的共享密钥", font=font).place(x=10, y=550)
    tk.Label(window_one, text="3:CRC32用于产生原文校验码,用于验证明文是否遭受篡改:", font=font).place(x=10, y=600)
    tk.Label(window_one, text="4:改进算法的思路主要是RC4模块的复用,在IV和KC拼接过程中顺序颠倒", font=font).place(x=10, y=650)
    canvas = tk.Canvas(window_one, width=700, height=400, bg='white')
    img = tk.PhotoImage(file="E:\\pro\\毕业设计成品1_1\\1.gif")
    canvas.place(x=10, y=70)
    canvas.create_image(0, 0, anchor='nw', image=img)
    img.put()


def time_compare():
    window_two = tk.Toplevel(window)
    window_two.title("Welcome to RC4 and WEP change system")
    window_two.geometry('800x600')
    print("本模块为对比时间复杂度模块")
    passage = "my name is sunhui i have a big dream 1314 try best 12"
    sk = "sh123456789123456"

    size_of_message1 = sys.getsizeof(passage)  # 单位为字节B
    print(size_of_message1)
    time1_1 = "0.0009975433349609375秒"
    time1_2 = "0.0008095433349609375秒"
    size_of_message2 = sys.getsizeof(passage * 10)  # 单位为字节B
    print(size_of_message2)
    time2_1 = "0.0030221939086914062秒"
    time2_2 = "0.003023862838745117秒"
    size_of_message3 = sys.getsizeof(passage * 100)  # 单位为字节B
    print(size_of_message3)
    time3_1 = "0.02491164207458496秒"
    time3_2 = "0.023215532302856445秒"
    size_of_message4 = sys.getsizeof(passage * 1000)  # 单位为字节B
    print(size_of_message4)
    time4_1 = "0.16950750350957148秒"
    time4_2 = "0.16950750350952148秒"
    size_of_message5 = sys.getsizeof(passage * 10000)  # 单位为字节B
    print(size_of_message5)
    time5_1 = "1.8480191230773926 秒"
    time5_2 = "1.8401842498779297秒 "
    size_of_message6 = sys.getsizeof(passage * 100000)  # 单位为字节B
    print(size_of_message6)
    time6_1 = "18.437443733215332 秒"
    time6_2 = "18.437443733215332秒"
    size_of_message7 = sys.getsizeof(passage * 1000000)  # 单位为字节B
    print(size_of_message7)
    time7_1 = "184.58862590789795 秒"
    time7_2 = "184.58862590789795秒"

    # 1.创建两个Entry,用来显示输入密码和明文
    tk.Label(window_two, text="加密明文:").place(x=50, y=50)
    tk.Label(window_two, text="加密密钥:").place(x=50, y=100)
    sy1 = tk.StringVar()
    sy1.set(passage)
    entime1_1 = tk.Entry(window_two, textvariable=sy1, show='', width=60).place(x=150, y=50)
    sy2 = tk.StringVar()
    sy2.set(sk)
    entime1_2 = tk.Entry(window_two, textvariable=sy2, show='', width=60).place(x=150, y=100)

    # 2.创建一个Button,用于开始显示时间对比
    def en_and_de():
        # 3.创建两个Entry,用来显示加密时间1
        tk.Label(window_two, text=str(size_of_message1) + 'B').place(x=50, y=200)
        time1 = tk.StringVar()
        time1.set(time1_1)
        entime1_1 = tk.Entry(window_two, textvariable=time1, show='', width=35).place(x=150, y=200)
        time2 = tk.StringVar()
        time2.set(time1_2)
        entime1_2 = tk.Entry(window_two, textvariable=time2, show='', width=35).place(x=500, y=200)

        # 4.创建两个Entry,用来显示加密时间2
        tk.Label(window_two, text=str(size_of_message2) + 'B').place(x=50, y=250)
        time11 = tk.StringVar()
        time11.set(time2_1)
        entime2_1 = tk.Entry(window_two, textvariable=time11, show='', width=35).place(x=150, y=250)
        time22 = tk.StringVar()
        time22.set(time2_2)
        entime2_2 = tk.Entry(window_two, textvariable=time22, show='', width=35).place(x=500, y=250)

        # 5.创建两个Entry,用来显示加密时间3
        tk.Label(window_two, text=str(size_of_message3) + 'B').place(x=50, y=300)
        time111 = tk.StringVar()
        time111.set(time3_1)
        entime3_1 = tk.Entry(window_two, textvariable=time111, show='', width=35).place(x=150, y=300)
        time222 = tk.StringVar()
        time222.set(time3_2)
        entime3_2 = tk.Entry(window_two, textvariable=time222, show='', width=35).place(x=500, y=300)

        # 6.创建两个Entry,用来显示加密时间4
        tk.Label(window_two, text=str(size_of_message4) + 'B').place(x=50, y=350)
        time1111 = tk.StringVar()
        time1111.set(time4_1)
        entime4_1 = tk.Entry(window_two, textvariable=time1111, show='', width=35).place(x=150, y=350)
        time2222 = tk.StringVar()
        time2222.set(time4_2)
        entime4_2 = tk.Entry(window_two, textvariable=time2222, show='', width=35).place(x=500, y=350)

        # 7.创建两个Entry,用来显示加密时间5
        tk.Label(window_two, text=str(size_of_message5) + 'B').place(x=50, y=400)
        time11111 = tk.StringVar()
        time11111.set(time5_1)
        entime5_1 = tk.Entry(window_two, textvariable=time11111, show='', width=35).place(x=150, y=400)
        time22222 = tk.StringVar()
        time22222.set(time5_2)
        entime5_2 = tk.Entry(window_two, textvariable=time22222, show='', width=35).place(x=500, y=400)

        # 8.创建两个Entry,用来显示加密时间6
        tk.Label(window_two, text=str(size_of_message6) + 'B').place(x=50, y=450)
        time111111 = tk.StringVar()
        time111111.set(time6_1)
        entime6_1 = tk.Entry(window_two, textvariable=time111111, show='', width=35).place(x=150, y=450)
        time222222 = tk.StringVar()
        time222222.set(time6_2)
        entime6_2 = tk.Entry(window_two, textvariable=time222222, show='', width=35).place(x=500, y=450)

        # 9.创建两个Entry,用来显示加密时间7
        tk.Label(window_two, text=str(size_of_message7) + 'B').place(x=50, y=500)
        time1111111 = tk.StringVar()
        time1111111.set(time7_1)
        entime7_1 = tk.Entry(window_two, textvariable=time1111111, show='', width=35).place(x=150, y=500)
        time2222222 = tk.StringVar()
        time2222222.set(time7_2)
        entime7_2 = tk.Entry(window_two, textvariable=time2222222, show='', width=35).place(x=500, y=500)

    btn_login = tk.Button(window_two, text="点击开始加密解密", command=en_and_de)
    btn_login.place(x=50, y=150)


def more_info():
    window_one = tk.Toplevel(window)
    window_one.geometry('800x600')
    window_one.title("帮助信息栏:")

menubar = tk.Menu(window)
window.config(menu=menubar)
filemenu = tk.Menu(menubar, tearoff=0, font=font, activebackground='black', activeborderwidth=5, selectcolor='red')
menubar.add_cascade(label='Please Click Here          ', menu=filemenu)


filemenu.add_checkbutton(label='改进算法加密解密模型',command=command_help)
filemenu.add_command(label='原加密解密模型',command=command_file)
filemenu.add_separator()
filemenu.add_command(label='加解密时间复杂度',command=time_compare)
filemenu.add_command(label='More information',command=more_info)



# 2.创建两个label,用来提示用户输入什么信息
tk.Label(window,text="请输入密码:").place(x=50, y=50)
tk.Label(window,text="请输入明文:").place(x=50, y=100)




# 3.创建两个Entry,用来让用户输入文本信息
pass_word =tk.StringVar()
pass_word.set("sh123456789123456")
password = tk.Entry(window, textvariable=pass_word, show='', width=25).place(x=150, y=50)
message =tk.StringVar()
message.set("my name is sunhui i have a big dream 1314 try best 12")
entry_use_pwd = tk.Entry(window, textvariable=message, show='', width=25).place(x=150, y=100)



# 4.创建一个Button,用于开始双向加密解密
def en_and_de():
    password_for_this = pass_word.get()
    message_for_this = message.get()
    end11_main, icv_ori_main, encyper_main, rc4_key_main, new_iv_main, new_sk_main, end22_main, iv_main, encyper222_main, rc4_key2_main, new_iv2_main = main_rc4(password_for_this, message_for_this)
    # 5.创建两个Entry,用来显示加密结果
    tk.Label(window, text="RC4改进算法加密结果:").place(x=50, y=150)
    tk.Label(window, text="RC4算法原加密结果:").place(x=450, y=150)

    en1 = tk.StringVar()
    en1.set(encyper_main)
    encyper1 = tk.Entry(window, textvariable=en1, show='', width=46).place(x=50, y=200)
    en2 = tk.StringVar()
    en2.set(encyper222_main)
    encyper2 = tk.Entry(window, textvariable=en2, show='', width=46).place(x=450, y=200)

    # 6.创建两个Entry,用来显示加密时间
    tk.Label(window, text="RC4改进算法加密时间:").place(x=50, y=250)
    tk.Label(window, text="RC4算法原加密时间:").place(x=450, y=250)

    time1 = tk.StringVar()
    time1.set(end11_main)
    entime1 = tk.Entry(window, textvariable=time1, show='', width=25).place(x=200, y=250)
    time2 = tk.StringVar()
    time2.set(end22_main)
    entime2 = tk.Entry(window, textvariable=time2, show='', width=25).place(x=600, y=250)

    # 7.创建两个Entry,用来显示下次RC4_key
    tk.Label(window, text="RC4改进算法RC4_KEY:").place(x=50, y=300)
    tk.Label(window, text="RC4算法原加密RC4_KEY:").place(x=450, y=300)
    rc4_k1 = tk.StringVar()
    rc4_k1.set(rc4_key_main)
    rc4_k11 = tk.Entry(window, textvariable=rc4_k1, show='', width=25).place(x=200, y=300)
    rc4_k2 = tk.StringVar()
    rc4_k2.set(rc4_key2_main)
    rc4_k22 = tk.Entry(window, textvariable=rc4_k2, show='', width=25).place(x=600, y=300)

    # 8.创建两个Entry,用来显示初始向量IV
    tk.Label(window, text="RC4改进算法初始IV:").place(x=50, y=350)
    tk.Label(window, text="RC4算法原加密初始IV:").place(x=450, y=350)
    iv1 = tk.StringVar()
    iv1.set(new_iv_main)
    iv11 = tk.Entry(window, textvariable=iv1, show='', width=25).place(x=200, y=350)
    iv2 = tk.StringVar()
    iv2.set(iv_main)
    iv22 = tk.Entry(window, textvariable=iv2, show='', width=25).place(x=600, y=350)

    # 9.创建两个Entry,用来显示下次向量IV
    tk.Label(window, text="RC4改进算法下次IV:").place(x=50, y=400)
    tk.Label(window, text="RC4算法原加密下次IV:").place(x=450, y=400)
    niv1 = tk.StringVar()
    niv1.set("NONE")
    niv11 = tk.Entry(window, textvariable=niv1, show='', width=25).place(x=200, y=400)
    niv2 = tk.StringVar()
    niv2.set(new_iv2_main)
    niv22 = tk.Entry(window, textvariable=niv2, show='', width=25).place(x=600, y=400)

    # 10.创建两个Entry,用来显示密钥
    tk.Label(window, text="RC4改进算法KEY:").place(x=50, y=450)
    tk.Label(window, text="RC4算法原加密KEY:").place(x=450, y=450)
    key1 = tk.StringVar()
    key1.set(password_for_this)
    key11 = tk.Entry(window, textvariable=key1, show='', width=25).place(x=200, y=450)
    key2 = tk.StringVar()
    key2.set(password_for_this)
    key22 = tk.Entry(window, textvariable=key2, show='', width=25).place(x=600, y=450)

    # 11.创建两个Entry,用来显示ICV
    tk.Label(window, text="RC4改进算法ICV:").place(x=50, y=500)
    tk.Label(window, text="RC4算法原加密ICV:").place(x=450, y=500)
    ICV1 = tk.StringVar()
    ICV1.set(icv_ori_main)
    ICV11 = tk.Entry(window, textvariable=ICV1, show='', width=25).place(x=200, y=500)
    ICV2 = tk.StringVar()
    ICV2.set(icv_ori_main)
    ICV22 = tk.Entry(window, textvariable=ICV2, show='', width=25).place(x=600, y=500)


btn_de = tk.Button(window, text="点击开始加密解密", command=en_and_de)
btn_de.place(x=500, y=100)
print("$"*100)
print(encyper222_main)
print("$"*100)


window.mainloop()


你可能感兴趣的:(Python+tkinter+other制作可视化界面)