This commit is contained in:
Raoul Snyman 2013-12-10 09:43:03 +02:00
parent c44b362d16
commit 4c13fac132
2 changed files with 29 additions and 19 deletions

1
.bzrignore Normal file
View File

@ -0,0 +1 @@
.idea

View File

@ -4,7 +4,8 @@ import threading
from PyQt4 import QtCore, QtGui
from serial import Serial, SerialException
from colourterm import SettingsDialog, ConnectDialog, SComboBox, Highlight, fromUtf8, translate, create_default_highlights
from colourterm import SettingsDialog, ConnectDialog, SComboBox, Highlight, fromUtf8, translate, \
create_default_highlights
from colourterm.cwebview import CWebView
@ -19,7 +20,9 @@ class Ui_MainWindow(object):
self.centralLayout.setContentsMargins(0, 0, 0, 8)
self.centralLayout.setObjectName(fromUtf8('centralLayout'))
self.outputBrowser = CWebView(self.centralwidget)
self.outputBrowser.setHtml('<html><head><style>body { color: %s; font-family: monospace; margin: 0; padding: 0; }</style></head><body><pre></pre></body></html>' % str(QtGui.QApplication.palette().color(QtGui.QPalette.Text).name()))
self.outputBrowser.setHtml('<html><head><style>body { color: %s; font-family: monospace; margin: 0; '
'padding: 0; }</style></head><body><pre></pre></body></html>' %
str(QtGui.QApplication.palette().color(QtGui.QPalette.Text).name()))
self.outputBrowser.setObjectName(fromUtf8('outputBrowser'))
self.centralLayout.addWidget(self.outputBrowser)
self.sendLayout = QtGui.QHBoxLayout()
@ -52,17 +55,20 @@ class Ui_MainWindow(object):
mainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.openAction = QtGui.QAction(mainWindow)
connectIcon = QtGui.QIcon()
connectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-connect.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
connectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-connect.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.openAction.setIcon(connectIcon)
self.openAction.setObjectName(fromUtf8('openAction'))
self.closeAction = QtGui.QAction(mainWindow)
disconnectIcon = QtGui.QIcon()
disconnectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-disconnect.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
disconnectIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/network-disconnect.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.closeAction.setIcon(disconnectIcon)
self.closeAction.setObjectName(fromUtf8('closeAction'))
self.captureAction = QtGui.QAction(mainWindow)
captureIcon = QtGui.QIcon()
captureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/capture-to-disk.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
captureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/capture-to-disk.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.captureAction.setIcon(captureIcon)
self.captureAction.setCheckable(True)
self.captureAction.setChecked(False)
@ -70,19 +76,22 @@ class Ui_MainWindow(object):
self.followAction = QtGui.QAction(mainWindow)
self.followAction.setShortcut(QtCore.Qt.Key_F)
followIcon = QtGui.QIcon()
followIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/follow-output.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
followIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/follow-output.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.followAction.setIcon(followIcon)
self.followAction.setCheckable(True)
self.followAction.setChecked(True)
self.followAction.setObjectName(fromUtf8('followAction'))
self.configureAction = QtGui.QAction(mainWindow)
configureIcon = QtGui.QIcon()
configureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/configure.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
configureIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/configure.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.configureAction.setIcon(configureIcon)
self.configureAction.setObjectName(fromUtf8('configureAction'))
self.exitAction = QtGui.QAction(mainWindow)
exitIcon = QtGui.QIcon()
exitIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/application-exit.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
exitIcon.addPixmap(QtGui.QPixmap(fromUtf8(':/toolbar/application-exit.png')),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.exitAction.setIcon(exitIcon)
self.exitAction.setObjectName(fromUtf8('exitAction'))
self.toolBar.addAction(self.openAction)
@ -205,8 +214,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
baseDir = os.path.basename(self.captureFileName)
else:
baseDir = u''
self.captureFileName = QtGui.QFileDialog.getSaveFileName(self, u'Capture To File',
baseDir, u'Text files (*.txt *.log);;All files (*)')
self.captureFileName = QtGui.QFileDialog.getSaveFileName(self, u'Capture To File', baseDir,
u'Text files (*.txt *.log);;All files (*)')
self.captureFile = open(self.captureFileName, u'w')
self.statusbar.showMessage(self.captureFileName)
elif self.captureFile and not enabled:
@ -239,7 +248,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.sendComboBox.insertItem(0, output)
self.sendComboBox.setCurrentIndex(0)
self.sendComboBox.clearEditText()
self.device.write(output + u'\r\n')
self.device.write(output + '\r\n')
def onContentsSizeChanged(self, size):
if self.followOutput:
@ -249,7 +258,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def onUpdateOutput(self, output):
#self.terminalLines.append(output)
if self.captureFile:
self.captureFile.write(output + u'\n')
self.captureFile.write(output + '\n')
self.captureFile.flush()
#if len(self.terminalLines) > 5000:
# self.terminalLines = self.terminalLines[-5000:]