admin管理员组文章数量:1635415
import tkinter as tk
from tkinter.filedialog import askopenfilename
# 超参数配置
USER_NAME='root' # 登陆的用户名
SERVER_IP='xx.xxx.xxx.xx' # 服务器ip
LOCATION='/root' # 上传到服务器的目标路径
win = tk.Tk()
win.resizable(width=False, height=False) # 窗口大小不可改变
win.title("文件传输程序")
win.geometry("750x350")
# 选择文件
e1 = tk.Entry(win)
e1.place(x=30,y=50)
def select_file():
filename = askopenfilename()
e1.delete(0, tk.END)
e1.insert(0, filename)
b1 = tk.Button(win, text="选择文件", command=select_file)
b1.place(x=170,y=48)
# 用户名
l1 = tk.Label(win,text="用户名:")
l1.place(x=250,y=50)
e2 = tk.Entry(win,width=6)
e2.place(x=300,y=50)
# 服务器地址
l2 = tk.Label(win,text="服务器地址:")
l2.place(x=360,y=50)
e3 = tk.Entry(win,width=12)
e3.place(x=430,y=50)
# 目标路径
l3 = tk.Label(win,text="目标路径:")
l3.place(x=540,y=50)
e4 = tk.Entry(win,width=15)
e4.place(x=600,y=50)
def send_file():
cmd = r'scp %s %s@%s:%s'%(e1.get(),e2.get(),e3.get(),e4.get())
# print(cmd)
# b2['state'] = tk.DISABLED
# os.system(cmd)
# b2['state'] = tk.NORMAL
# tk.messagebox.showinfo(title='Hi', message='文件传输完成!')
e5.delete(0, tk.END)
e5.insert(0, cmd)
# b2 = tk.Button(win, text="发送文件", command=send_file)
b2 = tk.Button(win, text="生成命令", command=send_file)
b2.place(x=320,y=120)
e5 = tk.Entry(win,width=50)
e5.place(x=180,y=180)
def init(): # 初始化文本
e2.insert(0, USER_NAME)
e3.insert(0, SERVER_IP)
e4.insert(0, LOCATION)
init()
win.mainloop()
版权声明:本文标题:tkinter制作scp命令一键生成器 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729204021a1189863.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论