我想呼叫python的第三方庫來對檔案進行加密解密,目前在制作這個系統的圖形界面。整個代碼我放在了三個py檔案中,但要怎么呼叫呢?
下面是主代碼:
#coding=utf-8
from tkinter import *
from tkinter.messagebox import *
from encrypt_1 import *
from decode_2 import *
root = Tk()
root.title("檔案加密解密")
root.geometry("450x300")
#檔案加密系統
def encrypt():
showinfo("加密系統","歡迎進入檔案加密系統!",command=encrypt_1)
#檔案解密系統
def decode():
showinfo("解密系統","歡迎進入檔案解密系統!")
aLabel = Label(root,text='歡迎進入檔案加密解密系統!',font='楷書 20',width=30,height=5,fg='red')
aLabel.place(x=20,y=10)
#加密系統
c1=Button(root,text='加密檔案',font ='20',height=2,width=25,command=encrypt)
c1.place(x=80,y=150)
#解密系統
c1=Button(root,text='檔案解密',font ='20',height=2,width=25,command=decode)
c1.place(x=80,y=200)
root.mainloop()
然后還有一個加密模塊和解密模塊,暫時不考慮解密模塊,加密模塊的代碼如下:
#coding=utf-8
from tkinter import *
from tkinter.messagebox import *
from tkinter import filedialog
#驗證加密時兩次密碼是否輸入一致
def verify():
if(E2.get()==E3.get()):
showinfo("加密成功!")
else:
showinfo("密碼請輸入一致!")
#瀏覽本地檔案
def file_view():
root.withdraw()
file_select = filedialog.askopenfilename()
root = Tk()
root.title("檔案加密")
root.geometry("450x300")
L1 = Label(root,text="選擇檔案:")
L1.place(x=10,y=10)
E1 = Entry(root,bd =5,font=12,width=15)
E1.place(x=80,y=10)
B1 = Button(root,text="瀏覽",width=15,command=file_view)
B1.place(x=250,y=10)
L2 = Label(root,text="密 碼:")
L2.place(x=10,y=60)
E2 = Entry(root,bd =5,font=12,width=15,show = "*")
E2.place(x=80,y=60)
L3 = Label(root,text="密碼確認:")
L3.place(x=10,y=110)
E3 = Entry(root,bd =5,font=12,width=15,show = "*")
E3.place(x=80,y=110)
B2 = Button(root,text="加密檔案",width=15,command=verify)
B2.place(x=100,y=150)
現在主要問題就是:
1.如何呼叫加密模塊的內容
2.加密模塊中瀏覽本地檔案怎么打開,或者把瀏覽中選擇的檔案路徑填到E1的文本框中
謝謝大家了!
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/11611.html
標籤:控件與界面
上一篇:動態計算公式怎么實作! !!!實作自定義指標和統計指標
下一篇:關于dw2xls的使用和程式編譯
