python 开发windowslinux图形界面FTP工具

python 开发windowslinux图形界面FTP工具,第1张

概述1.运行示列图:2.核心代码示列:classFTP_files():"""ftp服务端"""def__init__(self):self.server=Nonedefftp_files(self):self.ftp_put=tk.Tk()self.ftp_put.title('FTP服务器')self.ft 1.运行示列图:

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



总结

以上是内存溢出为你收集整理的python 开发windows/linux图形界面FTP工具全部内容,希望文章能够帮你解决python 开发windows/linux图形界面FTP工具所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1185015.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存