Retaining/Show Ubuntu Python GUI 中传输文件的名称
Retaining/Show the name of transferred files in Python GUI on Ubuntu
我正在 Ubuntu 上的 python 中编写一个程序,将文件从远程 Linux 机器传输到我的主机 Ubuntu 机器,两台机器都直接连接到通过 CAT5 电缆相互连接。我的程序成功从其他 Linux 机器获取文件并显示传输的文件数。
但是我想添加一个从远程 linux 机器传输到主机的传输文件列表,其中包含传输文件的数量。
你能帮我改进我的编码以获得所需的结果吗?
import io,sys,os,subprocess
import Tkinter,ttk
from Tkinter import *
import tkMessageBox
def transFile():
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
previous =num_files # Count Number of Files before Transferred New Files
ip ="192.168.2.34"
os.system("rsync -rav pi@"+ip+":python ~/") # Command To transfer Files
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
present = num_files-previous
tkMessageBox.showinfo (" File Transfer", 'Number of Files Transfer is '+ str(present)+ '!')
def exitFiles():
root.quit()
root = Tk()
mainframe = ttk.Frame(root, padding="200 200 200 200")
mainframe.grid()
ttk.Button(mainframe, text="File Transfer", command=transFile).grid (column=10, row=3)
ttk.Button(mainframe, text="Exit", command=exitFiles).grid (column=95, row=3)
global process
path = os.path.expanduser("~/python") # Define path To play, delete, or rename video
root.mainloop()
我添加了最后五行,它会向您显示文件夹中的所有文件,您可能会在更多解析后得到所需的答案
def transFile():
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
previous =num_files # Count Number of Files before Transferred New Files
ip ="192.168.2.34"
os.system("rsync -rav pi@"+ip+":python ~/") # Command To transfer Files
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
present = num_files-previous
tkMessageBox.showinfo (" File Transfer", 'Number of Files Transfer is '+ str(present)+ '!')
a=0
for file in os.listdir('.'):
if fnmatch(file, '*.*'):
a +=1
ttk.Label(mainframe, text=file).grid(row=4+a, column=10)
我正在 Ubuntu 上的 python 中编写一个程序,将文件从远程 Linux 机器传输到我的主机 Ubuntu 机器,两台机器都直接连接到通过 CAT5 电缆相互连接。我的程序成功从其他 Linux 机器获取文件并显示传输的文件数。 但是我想添加一个从远程 linux 机器传输到主机的传输文件列表,其中包含传输文件的数量。
你能帮我改进我的编码以获得所需的结果吗?
import io,sys,os,subprocess
import Tkinter,ttk
from Tkinter import *
import tkMessageBox
def transFile():
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
previous =num_files # Count Number of Files before Transferred New Files
ip ="192.168.2.34"
os.system("rsync -rav pi@"+ip+":python ~/") # Command To transfer Files
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
present = num_files-previous
tkMessageBox.showinfo (" File Transfer", 'Number of Files Transfer is '+ str(present)+ '!')
def exitFiles():
root.quit()
root = Tk()
mainframe = ttk.Frame(root, padding="200 200 200 200")
mainframe.grid()
ttk.Button(mainframe, text="File Transfer", command=transFile).grid (column=10, row=3)
ttk.Button(mainframe, text="Exit", command=exitFiles).grid (column=95, row=3)
global process
path = os.path.expanduser("~/python") # Define path To play, delete, or rename video
root.mainloop()
我添加了最后五行,它会向您显示文件夹中的所有文件,您可能会在更多解析后得到所需的答案
def transFile():
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
previous =num_files # Count Number of Files before Transferred New Files
ip ="192.168.2.34"
os.system("rsync -rav pi@"+ip+":python ~/") # Command To transfer Files
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
present = num_files-previous
tkMessageBox.showinfo (" File Transfer", 'Number of Files Transfer is '+ str(present)+ '!')
a=0
for file in os.listdir('.'):
if fnmatch(file, '*.*'):
a +=1
ttk.Label(mainframe, text=file).grid(row=4+a, column=10)