|
|
|
@ -0,0 +1,71 @@
|
|
|
|
|
import redis
|
|
|
|
|
from tkinter import *
|
|
|
|
|
from tkinter.ttk import *
|
|
|
|
|
from tkinter import messagebox
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def redis_luru():
|
|
|
|
|
redis_host = entry_host.get()
|
|
|
|
|
redis_port = entry_port.get()
|
|
|
|
|
redis_password = entry_password.get()
|
|
|
|
|
redis_db = entry_db.get()
|
|
|
|
|
redis_pool = redis.ConnectionPool(host=redis_host, port=redis_port, password=redis_password, db=redis_db)
|
|
|
|
|
r = redis.Redis(connection_pool=redis_pool)
|
|
|
|
|
keyname = entry_keyname.get()
|
|
|
|
|
key = entry_key.get()
|
|
|
|
|
r.set(keyname, key)
|
|
|
|
|
messagebox.showinfo(title='Redis数据录入', message='录入成功')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def createUI():
|
|
|
|
|
'''
|
|
|
|
|
创建窗口和控件
|
|
|
|
|
:return:
|
|
|
|
|
'''
|
|
|
|
|
global entry_host, entry_port, entry_password, entry_db, entry_key, entry_keyname
|
|
|
|
|
root = Tk()
|
|
|
|
|
root.title("Redis数据录入")
|
|
|
|
|
# frame_head,其父窗口为root
|
|
|
|
|
frame_head = Frame(root)
|
|
|
|
|
frame_head.pack(side=TOP, fill=BOTH, expand=YES)
|
|
|
|
|
|
|
|
|
|
# frame_account,其父窗口为frame_head
|
|
|
|
|
frame_account = Frame(frame_head)
|
|
|
|
|
frame_account.grid(row=0, column=0)
|
|
|
|
|
label_host = Label(frame_account, text='host:', width=10)
|
|
|
|
|
label_host.grid(row=0, column=0, padx=10, pady=5)
|
|
|
|
|
entry_host = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_host.grid(row=0, column=1, padx=10, pady=5)
|
|
|
|
|
entry_host.insert(0, '127.0.0.1')
|
|
|
|
|
label_port = Label(frame_account, text='port:', width=10)
|
|
|
|
|
label_port.grid(row=1, column=0, padx=10, pady=5)
|
|
|
|
|
entry_port = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_port.grid(row=1, column=1, padx=10, pady=5)
|
|
|
|
|
entry_port.insert(0, '6379')
|
|
|
|
|
label_password = Label(frame_account, text='password:', width=10)
|
|
|
|
|
label_password.grid(row=2, column=0, padx=10, pady=5)
|
|
|
|
|
entry_password = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_password.grid(row=2, column=1, padx=10, pady=5)
|
|
|
|
|
label_db = Label(frame_account, text='db:', width=10)
|
|
|
|
|
label_db.grid(row=3, column=0, padx=10, pady=5)
|
|
|
|
|
entry_db = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_db.grid(row=3, column=1, padx=10, pady=5)
|
|
|
|
|
entry_db.insert(0, '0')
|
|
|
|
|
label_keyname = Label(frame_account, text='Key Name:', width=10)
|
|
|
|
|
label_keyname.grid(row=4, column=0, padx=10, pady=5)
|
|
|
|
|
entry_keyname = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_keyname.grid(row=4, column=1, padx=10, pady=5)
|
|
|
|
|
label_key = Label(frame_account, text='Key:', width=10)
|
|
|
|
|
label_key.grid(row=5, column=0, padx=10, pady=5)
|
|
|
|
|
entry_key = Entry(frame_account, foreground='blue', width=42)
|
|
|
|
|
entry_key.grid(row=5, column=1, padx=10, pady=5)
|
|
|
|
|
# frame_btn,其父窗口为root
|
|
|
|
|
frame_btn = Frame(root, width=40)
|
|
|
|
|
frame_btn.pack(side=BOTTOM, fill=BOTH, expand=YES)
|
|
|
|
|
btn_submit = Button(frame_btn, text='确定录入', command=redis_luru)
|
|
|
|
|
btn_submit.grid(row=0, column=0, padx=200, pady=10)
|
|
|
|
|
root.mainloop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
createUI()
|