我正在使用Python编写脚本,与Bash配合使用。当我设置了所有搜索选项并点击查找按钮时,我希望弹出一个带有“进度条”的弹出窗口,在搜索完成后消失。我通过“popup.show()”打开“弹出窗口”,直到我关闭弹出窗口之前,没有任何功能被执行。那么如何解决这个问题?
在控制器类中:
在控制器类中:
def search(self, widget):
cmd = "find " + self.model.directory + " -name \"" + self.model.name + "\"" + " -perm -" + str(self.model.mode)
if self.model.type is not None and self.model.type != '':
cmd += " -type " + self.model.type
if self.model.owner is not None:
cmd += " -user " + self.model.owner
if self.model.days is not None:
cmd += " -mtime -" + str(self.model.days)
self.progress = SearcherProgressBar()
output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
out = output.stdout.read().strip()
array = string.split(out, '\n')
self.list = list()
self.progress.label = "sdsds"
for value in array:
self.add_to_list(value)
#self.progress.popup.destroy() # when I uncomment, popup never appears
self.view.treestore.clear()
self.add_to_tree(self.list, None)
self.view.expand_item.set_sensitive(True)
在进度条类中:
class SearcherProgressBar:
def __init__(self):
self.popup = gtk.Window(gtk.WINDOW_POPUP)
vbox = gtk.VBox()
self.popup.add(vbox)
self.popup.set_size_request(500,100)
self.label = gtk.Label("Searching...")
vbox.pack_start(self.label, True, True, 0)
self.popup.connect("destroy", self.dest)
self.popup.show_all()
def dest(self, widget, data=None):
self.popup.destroy()
return False