如何在wxpython中的两个帧(两个不同的文件)之间传递值?

如何在wxpython中的两个帧(两个不同的文件)之间传递值?,wxpython,Wxpython,我在一个文件中有一个网格,在另一个文件中有文本控件。当用户单击OK时,所有文本控件的值都必须显示在网格中 mainDialog.self.mainGrid.InsertRows(len(allData), 1) gridsize = mainDialog.self.mainGrid.GetGridCursorRow() mainDialog.self.mainGrid.SetCellValue(len(allData), 0, str(eventName)) mainDialog.self.ma

我在一个文件中有一个网格,在另一个文件中有文本控件。当用户单击OK时,所有文本控件的值都必须显示在网格中

mainDialog.self.mainGrid.InsertRows(len(allData), 1)
gridsize = mainDialog.self.mainGrid.GetGridCursorRow()
mainDialog.self.mainGrid.SetCellValue(len(allData), 0, str(eventName))
mainDialog.self.mainGrid.SetCellValue(len(allData), 1, str(eventDate))
mainDialog.self.mainGrid.SetCellValue(len(allData), 2, str(eventTimeReal))
mainDialog.self.mainGrid.SetCellValue(len(allData), 3, str(eventVenue))
这里,mainDialog是一个必须向其传递值的文件

它显示以下错误:

theGrid = mainDialog.mainDialog.mainGrid()
AttributeError: type object 'mainDialog' has no attribute 'mainGrid'

我认为你说得不对。您可能需要“self.mainGrid.SetCellValue”或“mainDialog.mainGrid.SetCellValue”。我个人认为,在多个帧之间进行通信的最佳方式是使用pubsub提供的发布/订阅模型。我在这里写了一篇关于这个主题的教程: