我有一个要求,我需要在运行progrom后在GUI中填充列表。以下GUI用于恢复系统的备份。
import Tkinter as tk
root = tk.Tk()
v = tk.IntVar()
v.set(1) # initializing the choice, i.e. Python
backups = [
(200,"WIN_7", "active", 4096, 320, 1),
(201,"WIN_7_sp1", "active", 4096, 320, 2),
(210,"WIN_Java", "inactive", 8019, 8),
(230,"Linux_C78", "active", 4096, 90),
(241,"Linux2_B78", "active", 4096, 80)
]
def ShowChoice():
print(v.get())
tk.Label(root,
text="""Choose a backup
to restore from the list:""",
justify = tk.LEFT,
padx = 20).pack()
for val, backup in enumerate(backups):
tk.Radiobutton(root,
text=backup,
padx = 20,
variable=v,
command=ShowChoice,
value=val).pack(anchor=tk.W)
root.mainloop()
由于备份列表正在从一个系统更改为另一个系统,因此需要更改脚本以在运行程序“listbk”后显示可用的备份。如果我运行程序'listbk',它会输出可用的备份,如下所示:
ID NAME STATUS MEM Disk RANDOMID
100 WIN_7 active 4096 320 1
301 WIN_7_sp1 active 4096 320 2
390 WIN_Java inactive 8019 320 8
480 Linux_C78 active 4096 320 90
541 Linux2_B78 active 4096 500 80
在python脚本中,我可以使用以下命令运行脚本来获取备份列表。
from subprocess import call
call(['listbk'])
在GUI中显示不同系统的可用备份的方法是什么。
感谢您的帮助......