44import re
55import serial
66import serial .tools .list_ports
7+ from io import StringIO
78
89import threading
910import queue
@@ -26,7 +27,7 @@ def escape_ansi(line):
2627 QDialog ,
2728 QFileDialog ,
2829 QSplitter ,
29- QTextEdit ,
30+ QPlainTextEdit ,
3031 QVBoxLayout ,
3132)
3233
@@ -36,7 +37,6 @@ def escape_ansi(line):
3637import csv
3738from tabs import Tabs
3839
39-
4040class MainWindow (QMainWindow ):
4141
4242 from menubar import (
@@ -108,7 +108,7 @@ def __init_font__(self):
108108
109109 def __get_editor_stylesheet__ (self ):
110110 return """
111- QTextEdit {
111+ QPlainTextEdit {
112112 background: rgb(27,27,28); border-color: gray; color: rgb(255, 255, 255);
113113 }
114114 QScrollBar {
@@ -129,7 +129,7 @@ def __get_editor_stylesheet__(self):
129129 def __init_ui__ (self ):
130130 QApplication .setStyle (QStyleFactory .create ("Cleanlooks" ))
131131 self .__init_font__ ()
132- self .log_editor = QTextEdit ()
132+ self .log_editor = QPlainTextEdit ()
133133 self .log_editor .setFont (self .font )
134134 self .log_editor .setStyleSheet (self .__get_editor_stylesheet__ ())
135135
@@ -158,7 +158,7 @@ def __init_ui__(self):
158158
159159 self .setStyleSheet ("QMainWindow { background-color: rgb(27,27,28); }" )
160160
161- self .output_editor = QTextEdit ()
161+ self .output_editor = QPlainTextEdit ()
162162 self .output_editor .setFont (self .font )
163163 self .output_editor .setStyleSheet (self .__get_editor_stylesheet__ ())
164164
@@ -399,9 +399,10 @@ def __open_raw__(self):
399399 self .plot_tab .setToolTip (path )
400400
401401 with open (path , "r" ) as csvfile :
402- self .output (csvfile .read ())
403- csvfile .seek (0 , 0 ) # go back to the beginning
404- reader = csv .reader (csvfile )
402+ filedata = csvfile .read ()
403+ filedata = escape_ansi (filedata )
404+ self .output (filedata )
405+ reader = csv .reader (StringIO (filedata ))
405406
406407 # Clear existing plot and set new header
407408 self .__clear_plot__ ()
0 commit comments