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

最近做畢業(yè)設(shè)計,兩周自學(xué)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由用戶自行設(shè)置或系統(tǒng)預(yù)設(shè),系統(tǒng)預(yù)設(shè)一般為四個共享密鑰", font=font).place(x=10, y=500)
    tk.Label(window_one, text="2:IV向量由系統(tǒng)自行生成,具有一定的周期,模擬系統(tǒng)周期為999,IV用于完成一次一密", font=font).place(x=10, y=550)
    tk.Label(window_one, text="3:CRC32用于產(chǎn)生原文校驗碼,用于驗證明文是否遭受篡改", font=font).place(x=10, y=600)
    canvas = tk.Canvas(window_one, width=700, height=400, bg='white')
    img = tk.PhotoImage(file="E:\\pro\\畢業(yè)設(shè)計成品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改進算法在無線網(wǎng)絡(luò)安全的應(yīng)用:", font=font1).place(x=10, y=30)
    tk.Label(window_one, text="1:初始化SK(共享密鑰經(jīng)過安全信道傳輸):", font=font).place(x=10, y=500)
    tk.Label(window_one, text="2:初始化密鑰對其自身進行加密產(chǎn)生IV,KC和新的共享密鑰", font=font).place(x=10, y=550)
    tk.Label(window_one, text="3:CRC32用于產(chǎn)生原文校驗碼,用于驗證明文是否遭受篡改:", font=font).place(x=10, y=600)
    tk.Label(window_one, text="4:改進算法的思路主要是RC4模塊的復(fù)用,在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\\畢業(yè)設(shè)計成品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("本模塊為對比時間復(fù)雜度模塊")
    passage = "my name is sunhui i have a big dream 1314 try best 12"
    sk = "sh123456789123456"

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

    # 1.創(chuàng)建兩個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.創(chuàng)建一個Button,用于開始顯示時間對比
    def en_and_de():
        # 3.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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='加解密時間復(fù)雜度',command=time_compare)
filemenu.add_command(label='More information',command=more_info)



# 2.創(chuàng)建兩個label,用來提示用戶輸入什么信息
tk.Label(window,text="請輸入密碼:").place(x=50, y=50)
tk.Label(window,text="請輸入明文:").place(x=50, y=100)




# 3.創(chuàng)建兩個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.創(chuàng)建一個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.創(chuàng)建兩個Entry,用來顯示加密結(jié)果
    tk.Label(window, text="RC4改進算法加密結(jié)果:").place(x=50, y=150)
    tk.Label(window, text="RC4算法原加密結(jié)果:").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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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.創(chuàng)建兩個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()


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容