The FileSelectWidget
class should define a custom signal that can be connected to the open_file
slot.
In order to do that, make sure the QtCore module is imported, and then define the custom signal like this:
class FileSelectWidget(QtGui.QWidget):
fileSelected = QtCore.Signal(object)
Then emit the signal whenever a file is selected:
def showFileSelectionDialog(self):
file_name, _ = QtGui.QFileDialog.getOpenFileName(
self, 'Open file', '/home')
if file_name:
self.fileSelected.emit(file_name)
And finally, connect the signal to the slot:
widget = FileSelectWidget()
widget.fileSelected.connect(self.open_file)
self.setCentralWidget(widget)