1.运行示列图:

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

2.核心代码示列:


class FTP_files():
"""ftp 服务端"""

def __init__(self):
self.server = None

def ftp_files(self):
self.ftp_put = tk.Tk()
self.ftp_put.title('FTP 服务器')
self.ftp_put.geometry("580x265+500+100")
self.ftp_put.resizable(width=False, height=False)
self.ftp_put.update()
name = tk.StringVar()

ttk.Label(self.ftp_put, text="").grid(row=0, column=1, columnspan=1)
tk.Label(self.ftp_put,
text="IP *",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=1, column=1, columnspan=1)

tk.Label(self.ftp_put,
text="用户名 *",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=1, column=2, columnspan=1)

self.IP_yc = tk.StringVar(value='127.0.0.1') # 默认值:value
self.IP_yclj = ttk.Entry(self.ftp_put, width=20, textvariable=self.IP_yc)
self.IP_yclj.grid(row=1, column=1)
self.IP_yclj.focus()

self.yhm_yc = tk.StringVar(value='admin')
self.yhm_yclj = ttk.Entry(self.ftp_put, width=20, textvariable=self.yhm_yc)
self.yhm_yclj.grid(row=1, column=2)
self.yhm_yclj.focus()


tk.Label(self.ftp_put,
text=u"账号状态",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=2, column=1)

tk.Label(self.ftp_put,
text=u"密码 *",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=2, column=2)

self.xy_yc = tk.StringVar()
self.xy_yclj = ttk.Combobox(self.ftp_put,
width=18,
textvariable=self.xy_yc,
state='readonly') # 下拉框字体,内容为weather,宽度,state='editable'表示内容可编辑

self.xy_yclj['values'] = (' 可 用', ' 禁 用') # 设置下拉列表的值

self.xy_yclj.grid(column=1, row=2) # 设置其在界面中出现的位置 column代表列 row 代表行
self.xy_yclj.current(0)

self.mm_yc = tk.StringVar()
self.mm_yclj = ttk.Entry(self.ftp_put, width=20, textvariable=self.mm_yc, show='*')
self.mm_yclj.grid(row=2, column=2)
self.mm_yclj.focus()

tk.Label(self.ftp_put,
text=u"路径 *",
font=("黑体", 10, "bold"),
width=40, height=3,
wraplength=80,
anchor='w').grid(row=3, column=1, sticky="nswe")

tk.Label(self.ftp_put,
text=u"端口 *",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=3, column=2)

self.file_win = tk.StringVar(value=".")

self.dk_yclj = ttk.Entry(self.ftp_put,
width=20,
textvariable=self.file_win)
self.dk_yclj.grid(row=3, column=1)
self.dk_yclj.focus()

self.port_yc = tk.StringVar(value='21')
self.bb_yclj = ttk.Entry(self.ftp_put, width=20, textvariable=self.port_yc)
self.bb_yclj.grid(row=3, column=2)
self.bb_yclj.focus()

self.btn_select_path = Button(self.ftp_put,
text="选择",
command=self.selectPath,
width=3,
height=1)

self.btn_select_path.place(relx=0.36, rely=0.45)

tk.Label(self.ftp_put,
text=u"权限 *",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=4, column=1)

tk.Label(self.ftp_put,
text=u"用户连接*",
font=("黑体", 10, "bold"),
width=40,
height=3,
wraplength=80,
anchor='w').grid(row=4, column=2)


self.sb_yc = tk.StringVar(value='elradfmwMT')
self.sb_yclj = ttk.Entry(self.ftp_put, width=20, textvariable=self.sb_yc)
self.sb_yclj.grid(row=4, column=1)
self.sb_yclj.focus()

self.number = tk.StringVar(value='10')
self.numberChosen1 = ttk.Entry(self.ftp_put, width=20, textvariable=self.number)
self.numberChosen1.grid(row=4, column=2)
# 设置其在界面中出现的位置 column代表列 row 代表行
self.sb_yclj.focus()

# =============开启====================
login_btn = Button(self.ftp_put,
text=' 启动 ',
bg='#1E90FF',
command=lambda: self.vrvagent_thread(self.main, ))

login_btn.place(relx=0.36, rely=0.8)
# login_btn.bind("<Button-1>", self.ftp_put)
# =======================================

# =============取消====================
login_btn = Button(self.ftp_put,
text=' 停止 ',
bg='#1E90FF',
command=self.ftp_put.destroy) # state='disable'

login_btn.place(relx=0.52, rely=0.8)
# login_btn.bind("<Button-1>", '')

self.ftp_put.mainloop()


def selectPath(self):

path = filedialog.askdirectory()
if os.path.isdir(path):
self.file_win.set(path)

def main(self, *args):

ftp_Local_Upload_path = self.file_win.get()
ftp_Remote_upload_path = self.sb_yc.get()
IP = self.IP_yclj.get()
PORT = self.port_yc.get()
USERNAME = self.yhm_yclj.get()
PASSWORD = self.mm_yclj.get()
qx = self.sb_yclj.get()

authorizer = DummyAuthorizer()
authorizer.add_user(USERNAME, PASSWORD, ftp_Local_Upload_path, perm='elradfmwMT')
handler = FTPHandler
handler.authorizer = authorizer
handler.banner = "pyftpdlib based ftpd ready."
address = (IP, int(PORT))
self.server = FTPServer(address, handler)
self.server.max_cons = 256
self.server.max_cons_per_ip = 5
self.server.serve_forever()