def METHOD_NAME(self, checked=False, filename=None):
    """Run a python script in the current kernel."""
    if filename is None:
        # Show a dialog box for user to select working directory
        filename = myqt.QtWidgets.QFileDialog.getOpenFileName(
            self.window,
            "Run Script",
            os.getcwd(),
            "py (*.py);;text (*.txt);;all (*)",
        )
        if filename[0]:  # returns a tuple of file and filter or ("","")
            filename = filename[0]
        else:
            filename = None
    # Run script if one was selected
    if filename is not None:
        kc = self.window.active_frontend.kernel_client
        kc.execute("%run {}".format(filename))