Mercurial > lcfOS
diff python/ide.py @ 259:ac603eb66b63
Added function call
author | Windel Bouwman |
---|---|
date | Mon, 05 Aug 2013 20:41:25 +0200 |
parents | 04c19282a5aa |
children | 046017431c6a |
line wrap: on
line diff
--- a/python/ide.py Mon Aug 05 19:46:11 2013 +0200 +++ b/python/ide.py Mon Aug 05 20:41:25 2013 +0200 @@ -16,11 +16,13 @@ import zcc import outstream + class BuildOutput(QTextEdit): """ Build output component """ def __init__(self, parent=None): super(BuildOutput, self).__init__(parent) fmt = logging.Formatter(fmt=zcc.logformat) + class MyHandler(logging.Handler): def emit(self2, x): self.append(str(fmt.format(x))) @@ -33,6 +35,7 @@ class BuildErrors(QTreeView): sigErrorSelected = pyqtSignal(object) + def __init__(self, parent=None): super(BuildErrors, self).__init__(parent) model = QStandardItemModel() @@ -44,16 +47,16 @@ self.setModel(self.model) def setErrorList(self, errorlist): - c = self.model.rowCount() - self.model.removeRows(0, c) - for e in errorlist: - item = QStandardItem(self.errorIcon, str(e.msg)) - item.setData(e) - irow = QStandardItem(str(e.loc.row)) - irow.setData(e) - icol = QStandardItem(str(e.loc.col)) - icol.setData(e) - self.model.appendRow([item, irow, icol]) + c = self.model.rowCount() + self.model.removeRows(0, c) + for e in errorlist: + item = QStandardItem(self.errorIcon, str(e.msg)) + item.setData(e) + irow = QStandardItem(str(e.loc.row)) + irow.setData(e) + icol = QStandardItem(str(e.loc.col)) + icol.setData(e) + self.model.appendRow([item, irow, icol]) def itemSelected(self, index): if not index.isValid(): @@ -87,6 +90,7 @@ def __init__(self, parent=None): super(Ide, self).__init__(parent) self.to_open_files = [] + self.logger = logging.getLogger('ide') self.setWindowTitle('LCFOS IDE') icon = QIcon('icons/logo.png') @@ -107,12 +111,12 @@ # Create components: def addComponent(name, widget): - dw = QDockWidget(name) - dw.setWidget(widget) - dw.setObjectName(name) - self.addDockWidget(Qt.RightDockWidgetArea, dw) - self.viewMenu.addAction(dw.toggleViewAction()) - return widget + dw = QDockWidget(name) + dw.setWidget(widget) + dw.setObjectName(name) + self.addDockWidget(Qt.RightDockWidgetArea, dw) + self.viewMenu.addAction(dw.toggleViewAction()) + return widget self.buildOutput = addComponent('Build output', BuildOutput()) self.astViewer = addComponent('AST viewer', AstViewer()) @@ -135,13 +139,14 @@ # About dialog: self.aboutDialog = AboutDialog() self.aboutDialog.setWindowIcon(icon) + # Create actions: def addMenuEntry(name, menu, callback, shortcut=None): - a = QAction(name, self) - menu.addAction(a) - a.triggered.connect(callback) - if shortcut: - a.setShortcut(shortcut) + a = QAction(name, self) + menu.addAction(a) + a.triggered.connect(callback) + if shortcut: + a.setShortcut(shortcut) addMenuEntry("New", self.fileMenu, self.newFile, shortcut=QKeySequence(QKeySequence.New)) addMenuEntry("Open", self.fileMenu, self.openFile, shortcut=QKeySequence(QKeySequence.Open)) @@ -149,7 +154,7 @@ addMenuEntry("Build", self.fileMenu, self.buildFile, shortcut=QKeySequence("F7")) addMenuEntry("Build and flash", self.fileMenu, self.buildFileAndFlash, shortcut=QKeySequence("F8")) - self.helpAction = QAction('Help', self) + self.helpAction = QAction('Help', self) self.helpAction.setShortcut(QKeySequence('F1')) self.helpMenu.addAction(self.helpAction) addMenuEntry('About', self.helpMenu, self.aboutDialog.open) @@ -170,7 +175,7 @@ def openFile(self): filename = QFileDialog.getOpenFileName(self, "Open C3 file...", "*.c3", - "C3 source files (*.c3)") + "C3 source files (*.c3)") if filename: self.loadFile(filename) @@ -274,7 +279,7 @@ self.builderrors.setErrorList(self.diag.diags) ce.setErrors(self.diag.diags) self.astViewer.setAst(pkg) - logging.info('Done!') + self.logger.info('Done!') def buildFile(self): ce = self.activeMdiChild() @@ -310,7 +315,9 @@ stl.reset() stl.halt() stl.run() - logging.info('Done!') + logging.info('Done!') + else: + self.logger.warning('Not connected to device, skipping flash') if __name__ == '__main__': @@ -318,6 +325,6 @@ app = QApplication(sys.argv) ide = Ide() ide.show() - logging.info('IDE started') + ide.logger.info('IDE started') app.exec_()