# Buggy code
def __init__(
    self,
    plugin,
    id_,
    history_filename,
    config_options,
    additional_options,
    interpreter_versions,
    connection_file=None,
    hostname=None,
    menu_actions=None,
    slave=False,
    external_kernel=False,
    given_name=None,
    options_button=None,
    show_elapsed_time=False,
    reset_warning=True,
    ask_before_restart=True,
):
    super(ClientWidget, self).__init__(plugin)
    SaveHistoryMixin.__init__(self, history_filename)

    # --- Init attrs
    self.id_ = id_
    self.connection_file = connection_file
    self.hostname = hostname
    self.menu_actions = menu_actions
    self.slave = slave
    self.external_kernel = external_kernel
    self.given_name = given_name
    self.show_elapsed_time = show_elapsed_time
    self.reset_warning = reset_warning
    self.ask_before_restart = ask_before_restart

    # --- Other attrs
    self.options_button = options_button
    self.stop_button = None
    self.reset_button = None
    self.stop_icon = ima.icon("stop")
    self.history = []
    self.allow_rename = True
    self.stderr_dir = None
    self.is_error_shown = False

    # --- Widgets
    self.shellwidget = ShellWidget(
        config=config_options,
        ipyclient=self,
        additional_options=additional_options,
        interpreter_versions=interpreter_versions,
        external_kernel=external_kernel,
        local_kernel=True,
    )
    self.infowidget = WebView(self)
    self.set_infowidget_font()
    self.loading_page = self._create_loading_page()
    self._show_loading_page()

    # Elapsed time
    self.time_label = None
    self.t0 = time.monotonic()
    self.timer = QTimer(self)

    # --- Layout
    vlayout = QVBoxLayout()
    toolbar_buttons = self.get_toolbar_buttons()

    hlayout = QHBoxLayout()
    hlayout.addWidget(self.create_time_label())
    hlayout.addStretch(0)
    for button in toolbar_buttons:
        hlayout.addWidget(button)

    vlayout.addLayout(hlayout)
    vlayout.setContentsMargins(0, 0, 0, 0)
    vlayout.addWidget(self.shellwidget)
    vlayout.addWidget(self.infowidget)
    self.setLayout(vlayout)

    # --- Exit function
    self.exit_callback = lambda: plugin.close_client(client=self)

    # --- Dialog manager
    self.dialog_manager = DialogManager()

    # Show timer
    self.update_time_label_visibility()


# Traceback (AttributeError)
File "C:\Users\raeckman\git\spyder\spyder\preferences\configdialog.py", line 224, in button_clicked
configpage.apply_changes()
File "C:\Users\raeckman\git\spyder\spyder\preferences\configdialog.py", line 105, in apply_changes
self.apply_callback()
File "C:\Users\raeckman\git\spyder\spyder\preferences\configdialog.py", line 270, in <lambda>
self.apply_settings(self.changed_options))
File "C:\Users\raeckman\git\spyder\spyder\plugins\ipythonconsole\plugin.py", line 760, in apply_plugin_settings
client.show_time_action.setChecked(show_time_o)
AttributeError: 'ClientWidget' object has no attribute 'show_time_action'

# Fixed code
def __init__(
    self,
    plugin,
    id_,
    history_filename,
    config_options,
    additional_options,
    interpreter_versions,
    connection_file=None,
    hostname=None,
    menu_actions=None,
    slave=False,
    external_kernel=False,
    given_name=None,
    options_button=None,
    show_elapsed_time=False,
    reset_warning=True,
    ask_before_restart=True,
):
    super(ClientWidget, self).__init__(plugin)
    SaveHistoryMixin.__init__(self, history_filename)

    # --- Init attrs
    self.id_ = id_
    self.connection_file = connection_file
    self.hostname = hostname
    self.menu_actions = menu_actions
    self.slave = slave
    self.external_kernel = external_kernel
    self.given_name = given_name
    self.show_elapsed_time = show_elapsed_time
    self.reset_warning = reset_warning
    self.ask_before_restart = ask_before_restart

    # --- Other attrs
    self.options_button = options_button
    self.stop_button = None
    self.reset_button = None
    self.stop_icon = ima.icon("stop")
    self.history = []
    self.allow_rename = True
    self.stderr_dir = None
    self.is_error_shown = False

    # --- Widgets
    self.shellwidget = ShellWidget(
        config=config_options,
        ipyclient=self,
        additional_options=additional_options,
        interpreter_versions=interpreter_versions,
        external_kernel=external_kernel,
        local_kernel=True,
    )
    self.infowidget = WebView(self)
    self.set_infowidget_font()
    self.loading_page = self._create_loading_page()
    self._show_loading_page()

    # Elapsed time
    self.time_label = None
    self.t0 = time.monotonic()
    self.timer = QTimer(self)
    self.show_time_action = create_action(
        self, _("Show elapsed time"), toggled=self.set_elapsed_time_visible
    )

    # --- Layout
    vlayout = QVBoxLayout()
    toolbar_buttons = self.get_toolbar_buttons()

    hlayout = QHBoxLayout()
    hlayout.addWidget(self.create_time_label())
    hlayout.addStretch(0)
    for button in toolbar_buttons:
        hlayout.addWidget(button)

    vlayout.addLayout(hlayout)
    vlayout.setContentsMargins(0, 0, 0, 0)
    vlayout.addWidget(self.shellwidget)
    vlayout.addWidget(self.infowidget)
    self.setLayout(vlayout)

    # --- Exit function
    self.exit_callback = lambda: plugin.close_client(client=self)

    # --- Dialog manager
    self.dialog_manager = DialogManager()

    # Show timer
    self.update_time_label_visibility()