forked from baronleonardo/Serial
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlineedit_serialin.py
More file actions
35 lines (25 loc) · 831 Bytes
/
lineedit_serialin.py
File metadata and controls
35 lines (25 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtCore import pyqtSignal
class LineEdit_SerialIn(QLineEdit):
"""docstring for LineEdit_SerialIn"""
__line_ending = "\n"
# create a signal
serial_input_sent = pyqtSignal(['QString'])
def __init__(self, parent=None):
super(LineEdit_SerialIn, self).__init__(parent)
self.parent = parent
def on_EnterKey_pressed(self):
text = self.text() + self.__line_ending
self.serial_input_sent.emit(text)
self.clear()
def on_Sendbtn_pressed(self):
self.on_EnterKey_pressed()
def on_line_ending_changed(self, line_ending_index):
if line_ending_index == 0:
self.__line_ending = ""
elif line_ending_index == 1:
self.__line_ending = "\n"
elif line_ending_index == 2:
self.__line_ending = "\r"
elif line_ending_index == 3:
self.__line_ending = "\r\n"