wxPython wx.FileDialog需要时间来加载

时间:2015-05-17 19:06:14

标签: python wxpython

我正在使用wxPython构建应用程序,我需要向用户询问文件。这是我的职能:

def choose_path(self, event):
    """Choose the path"""
    self.btnPath.Disable()
    path, exists = open_file()
    self.btnPath.Enable()
    if path is not None:
        if exists:
            self.txtPath.SetLabel(path)

    self.btnOpen.Enable(bool(self.txtPath.GetValue()))


def open_file(default_path="data\\pcap"):
    """Method for opening files,returns the file_path of the choosen file and exists"""

    file_path = None
    dialog = wx.FileDialog(None, "File Browser", default_path,
                           style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.STAY_ON_TOP, wildcard=OPEN_WILDCARD)

    if dialog.ShowModal() == wx.ID_OK:
        file_path = dialog.GetPath()

    dialog.Destroy()

    return file_path, os.path.exists(file_path)

问题是有时加载FileDialog并且应用程序崩溃需要时间。我该怎么办呢?

0 个答案:

没有答案