tkinter制作scp命令一键生成器

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()

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

笼中小夜莺

嘿嘿嘿,请用金钱尽情地蹂躏我吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值