def sendFile(self, event): if Chat.chatWith == None: wx.MessageBox("请选择一位好友", "提示", parent=self) return dlg = wx.FileDialog(self, u"请选择文件") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() filename = dlg.GetFilename() Chat.SendFile(path, filename)