简体   繁体   English

前进或后退-Python-ftplib

[英]move to forward or backward - Python - ftplib

I am intended to create a GUI FTP application by using Python and PyGTK. 我打算使用Python和PyGTK创建GUI FTP应用程序。 So I have chosen ftplib. 所以我选择了ftplib。

Requirement is I want to create two buttons. 要求是我要创建两个按钮。 Butoon 1 Forward and Button 2 Backward. 按钮1向前,按钮2向后。 When I click backward then it have to move to last directory. 当我向后单击时,它必须移至上一个目录。 If I assume my object and function as 如果我假设我的对象和功能为

ftp.cwd() then What I have to pass as an argument ie ftp.cwd(something that send to backward). ftp.cwd()然后我必须作为参数传递的内容,即ftp.cwd(向后发送的内容)。

Help me Please. 请帮帮我。

Thank you. 谢谢。

.cwd() is the correct method to change the remote (on ftp server) directory. .cwd()是更改远程(在ftp服务器上)目录的正确方法。

something that send to backward 落后的东西

To implement forward/backward buttons, you need a list of previously visited directories. 要实现前进/后退按钮,您需要一个以前访问过的目录的列表。 You could use collections.deque() that has .rotate() method that allows to move forwards and backwards in the history list. 您可以使用具有.rotate()方法的 collections.deque() ,该方法允许在历史记录列表中前后移动。

You could use maxlen parameter to limit the history size. 您可以使用maxlen参数限制历史记录的大小。 .append() adds a new item to the history. .append()将新项目添加到历史记录中。 Each item may be a simple string representing the remote path. 每个项目可以是代表远程路径的简单字符串。 You can pass these strings to .cwd() method to change the directory. 您可以将这些字符串传递给.cwd()方法以更改目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM