作者:大美妞庄严典雅__ | 来源:互联网 | 2023-09-04 23:55
方法一:
import os
import cv2
import tkinter
from CBC_2 import CBCS
from Base64 import BaSe64
from CBC_1 import AES_ENCRYPT
from tkinter import filedialog
from tkinter.messagebox import showwarning,showinfo
def Input_Key():# 初始化弹出输入对话框child = tkinter.Tk()#弹出对话框的titlechild.title('文件加密和解密的秘钥值')child['height'] = 110child['width'] = 320child.resizable(0, 0)# 设置弹出对话的框的标签值label = tkinter.Label(child, text='秘钥值:', font=('黑体', 12))label.place(x=1, y=17)# 弹出输入对话框请获取相应的值digit_str = tkinter.StringVar()entry = tkinter.Entry(child, font=('黑体', 12), textvariable=digit_str)entry.place(x=100, y=17)# 绑定回车键def Get_key(*args):global keykey = entry.get()if not key:key = '123'showinfo(title='警告', message='系统默认秘钥值')child.destroy()#按下回车键返回秘钥child.bind('', Get_key)#点击OK按钮返回秘钥btn_OK = tkinter.Button(child, text='OK', font=('黑体', 12), height=1, command=Get_key)btn_OK.place(x=150, y=50)child.mainloop()print('key: ', key)return key
方法二(更为简洁):
import os
import cv2
import tkinter
from tkinter import simpledialogroot=tkinter.Tk()
#输入字符串
entry_str=simpledialog.askstring(title='文件秘钥值',prompt='秘钥输入')
print('entry_str: ',entry_str)
#输入浮点
entry_float=simpledialog.askfloat(title='浮点数',prompt='浮点输入')
print('entry_float: ',entry_float)
#输入整数
entry_int=simpledialog.askfloat(title='整数',prompt='整数输入')
print('entry_int: ',entry_int)root.mainloop()