def setUp(self) -> None: self.app = QtWidgets.QApplication(sys.argv) self.terminal_example = terminal.OstrannaTerminal() self.terminal_example.file_to_send = \ r'C:\Users\juice\Downloads\PycharmProjects\OstrannaTerminal\Ostranna_Logo.ico' self.terminal_example.text_settings = data_types.TextSettings() self.terminal_example.port_settings = data_types.ComSettings()
def __init__(self): super().__init__() self.setupUi(self) self.serial_port = QtSerialPort.QSerialPort() self.port_settings: data_types.ComSettings = data_types.ComSettings() self.text_settings: data_types.TextSettings = data_types.TextSettings() self.all_macros: List[data_types.MacroSet] = list() self.current_macros: data_types.MacroSet = data_types.MacroSet( name="", macros=list()) self.load_macros() self.counter: int = 0 self.time_shown = False self.tail = "" self.file_to_send = "" self.graph_form = Optional[terminal_graph.MainWindow] self.graph = False self.start_time = datetime.datetime.now() self.settings_form: Optional[settings.Settings] = None self.macros_form: Optional[macros.Macros] = None self.ascii_form: Optional[ASCII_table.ASCIITable] = None self.help_form: Optional[help.Help] = None self.var_form: Optional[variables.Variables] = variables.Variables() self.var_form.send_signal[str].connect(self.var_signal_send) self.current_font = QtGui.QFont("Consolas", 10) self.apply_styles() self.macros_btns_list = list() self.macros_ui() self.load_settings() self.serial_port_ui() self.set_transmitzone_ui() self.create_connections() self.init_timer_data()
def terminal_example(): terminal_ex = terminal.OstrannaTerminal() terminal_ex.text_settings = data_types.TextSettings() terminal_ex.port_settings = data_types.ComSettings() terminal_ex.CBSTM.setChecked(True) terminal_ex.CBNRF.setChecked(False) terminal_ex.CBPorts.setCurrentIndex(0) terminal_ex.BtnConnect.click() yield terminal_ex terminal_ex.destroy()
def __init__(self): super().__init__() self.setupUi(self) self.CBBaudrate.activated.connect(self.baudrate_changed) self.BtnReScan.clicked.connect(self.scan_ports) self.BtnConnect.clicked.connect(self.connect) self.BtnDisconnect.clicked.connect(self.disconnect) self.BtnClear.clicked.connect(self.clear_pressed) self.BtnClear.setShortcut('Esc') self.BtnSend.clicked.connect(self.send_clicked) self.BtnSend2.clicked.connect(self.send_clicked) self.BtnCounter.clicked.connect(self.clear_counter) self.BtnSave.clicked.connect(self.save_to_file) self.BtnCreateMacros.clicked.connect(self.macros_pressed) self.TxtTransmit.returnPressed.connect(self.send_clicked) self.TxtTransmit2.returnPressed.connect(self.send_clicked) self.BtnSettings.clicked.connect(self.settings_pressed) self.BtnFile.clicked.connect(self.select_file) self.BtnSendFile.clicked.connect(self.send_file) self.BtnAscii.clicked.connect(self.ascii_show) self.serial_port = QtSerialPort.QSerialPort() self.serial_port.readyRead.connect(self.read_data) self.serial_port.errorOccurred.connect(self.serial_error) self.port_settings: data_types.ComSettings = data_types.ComSettings() self.text_settings: data_types.TextSettings = data_types.TextSettings() self.scan_ports() self.all_macros: List[data_types.MacroSet] = list() self.current_macros: data_types.MacroSet = data_types.MacroSet(name="", macros=list()) self.load_macros() self.counter: int = 0 self.file_to_send = "" self.start_time = datetime.datetime.now() self.settings_form: Optional[settings.Settings] = None self.macros_form: Optional[macros.Macros] = None self.ascii_form: Optional[ASCII_table.ASCIITable] = None self.colors: Dict[str, Tuple[int, int, int]] = \ {'background-color': (255, 255, 255), 'font-transmit': (50, 250, 00), 'font-receive': (0, 0, 0), 'bytes-color': (255, 0, 0)} self.CBBaudrate.setCurrentText('115200') self.current_font = QtGui.QFont("Consolas", 10) self.TxtBuffer.setFont(self.current_font) self.TxtBuffer.setTextBackgroundColor(QtGui.QColor(*self.colors['background-color'])) self.TxtBuffer.setTextColor(QtGui.QColor(*self.colors['font-transmit'])) self.macros_btns_list = [self.BtnMacros1, self.BtnMacros2, self.BtnMacros3, self.BtnMacros4, self.BtnMacros5, self.BtnMacros6, self.BtnMacros7, self.BtnMacros8, self.BtnMacros9, self.BtnMacros10, self.BtnMacros11, self.BtnMacros12, self.BtnMacros13, self.BtnMacros14, self.BtnMacros15, self.BtnMacros16, self.BtnMacros17, self.BtnMacros18, self.BtnMacros19, self.BtnMacros20] for btn in self.macros_btns_list: btn.clicked.connect(self.macro_btn_pressed) self.CBMacros.currentTextChanged.connect(self.macros_selected) self.load_settings()
def tearDown(self): self.terminal_example.text_settings = data_types.TextSettings() self.terminal_example.port_settings = data_types.ComSettings() self.terminal_example.settings_form.save_settings() self.terminal_example.colors = { 'background-color': (255, 255, 255), 'font-transmit': (50, 250, 00), 'font-receive': (0, 0, 0), 'bytes-color': (255, 0, 0) } self.terminal_example.current_font = QtGui.QFont("Consolas", 10) self.terminal_example.destroy() self.app.quit()
def testComSettings(self): right_settings = data_types.ComSettings( name="", last_name="", baudrate=9100, databits=5, parity=data_types.Parity.MARK, stopbits=2, handshaking=data_types.Handshaking.NONE, last_macros_set="test2", STMFilter=False, NRFFilter=True) self.assertEqual(self.terminal_example.port_settings, right_settings) self.assertFalse(self.terminal_example.CBSTM.isChecked()) self.assertTrue(self.terminal_example.CBNRF.isChecked())
def setUp(self): self.app = QtWidgets.QApplication(sys.argv) self.terminal_example = terminal.OstrannaTerminal() self.terminal_example.text_settings = data_types.TextSettings() self.terminal_example.port_settings = data_types.ComSettings()