def OnPortSettings(self, event):  # wxGlade: TerminalFrame.<event_handler>
        """
        Show the port settings dialog. The reader thread is stopped for the
        settings change.
        """
        if event is not None:           # will be none when called on startup
            self.StopThread()
            self.serial.close()
        ok = False
        while not ok:
            with wxSerialConfigDialog.SerialConfigDialog(
                    self,
                    -1,
                    "",
                    show=wxSerialConfigDialog.SHOW_BAUDRATE | wxSerialConfigDialog.SHOW_FORMAT | wxSerialConfigDialog.SHOW_FLOW,
                    serial=self.serial) as dialog_serial_cfg:
                dialog_serial_cfg.CenterOnParent()
                result = dialog_serial_cfg.ShowModal()
            # open port if not called on startup, open it on startup and OK too
            if result == wx.ID_OK or event is not None:
                try:
                    self.serial.open()
                except serial.SerialException as e:
                    with wx.MessageDialog(self, str(e), "Serial Port Error", wx.OK | wx.ICON_ERROR)as dlg:
                        dlg.ShowModal()
                else:
                    self.StartThread()
                    self.SetTitle("Serial Terminal on %s [%s,%s,%s,%s%s%s]" % (
                            self.serial.portstr,
                            self.serial.baudrate,
                            self.serial.bytesize,
                            self.serial.parity,
                            self.serial.stopbits,
                            ' RTS/CTS' if self.serial.rtscts else '',
                            ' Xon/Xoff' if self.serial.xonxoff else '',
                            ))
                    ok = True
            else:
                # on startup, dialog aborted
                self.alive.clear()
                ok = True
dataset/ETHPy150Open pyserial/pyserial/examples/wxTerminal.py/TerminalFrame.OnPortSettings/original