ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

python 开发windows/linux图形界面FTP工具

2021-06-09 18:57:04  阅读:189  来源: 互联网

标签:FTP ftp python 图形界面 column yclj put self row


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



标签:FTP,ftp,python,图形界面,column,yclj,put,self,row
来源: https://blog.51cto.com/xuaijun/2886729

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有