为什么这个MessageDialog会冻结?

时间:2012-06-21 13:27:08

标签: python wxpython

显示wx.MessageDialog冻结整个用户界面,只有鼠标指针移动,屏幕上的任何内容都无法点击。我必须从终端杀死进程。

这适用于所有对话框,如颜色选择器或是/否。但不适用于文件选择器。

主题细节:恰好有一个CallLater发生在另一个框架中。

这是违规行为和违规行:

def append_data_point(self, data):
c, l, r = data
if not self._spectrum_data.data_present:
    print "hey no data"
    dlg = wx.MessageDialog(
    parent  = self, 
    message = "data not loaded, create a new data",
    caption = "no data loaded" ,
    style   = wx.OK)
    print "created dialog"
    dlg.ShowModal()
    print "showed modal" #THIS NEVER RUNS
    dlg.Destroy()

上面的函数恰好绑定到某个按钮:

 self.btn_open_file.Bind(wx.EVT_BUTTON, self.open_file)

选择文件(当然是从OS界面):

def open_file(self, event):
    dlg = wx.FileDialog(
        parent   = self, 
        message  = "select a spectrum file", 
        wildcard = "*.spectrum", 
        style    = wx.OPEN)
    if dlg.ShowModal() == wx.ID_OK: #PERDECTLY OK
        chosen_file = dlg.GetFilename()
        chosen_dir  = dlg.GetDirectory()
        filepath    = os.path.join(chosen_dir, chosen_file)

0 个答案:

没有答案
相关问题