gui: cleanup code in modulewidget

- line length
- spacing style
- copyright header

Change-Id: Ib402baf271868e82010e9acdfad4087164d91714
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30647
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
This commit is contained in:
Georg Brandl 2023-03-10 07:07:06 +01:00 committed by Markus Zolliker
parent c3bfc0a930
commit efad0e2079

View File

@ -1,3 +1,26 @@
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2015-2023 by the authors, see LICENSE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Module authors:
# Alexander Zaft <a.zaft@fz-juelich.de>
#
# *****************************************************************************
import json
from collections import OrderedDict
@ -45,7 +68,8 @@ class Console(QWidget):
einfo = e.args[0] if len(e.args) == 1 else json.dumps(e.args)
self._addLogEntry('%s: %s' % (e.name, einfo), error=True)
except Exception as e:
self._addLogEntry('error when sending %r: %r' % (msg, e), error=True)
self._addLogEntry('error when sending %r: %r' % (msg, e),
error=True)
self.msgLineEdit.selectAll()
@ -64,11 +88,11 @@ class Console(QWidget):
def _addLogEntry(self, msg, raw=False, error=False):
if not raw:
if error:
msg = '<div style="color:#FF0000"><b><pre>%s</pre></b></div>' % toHtmlEscaped(
str(msg)).replace('\n', '<br />')
msg = ('<div style="color:#FF0000"><b><pre>%s</pre></b></div>'
% toHtmlEscaped(str(msg)).replace('\n', '<br />'))
else:
msg = '<pre>%s</pre>' % toHtmlEscaped(
str(msg)).replace('\n', '<br />')
msg = ('<pre>%s</pre>'
% toHtmlEscaped(str(msg)).replace('\n', '<br />'))
content = ''
if self.logTextBrowser.toPlainText():
@ -85,6 +109,7 @@ class Console(QWidget):
result = self.logTextBrowser.width() / fontMetrics.width('m')
return result
class NodeWidget(QWidget):
noPlots = pyqtSignal(bool)
@ -104,7 +129,8 @@ class NodeWidget(QWidget):
self.top_splitter.setStretchFactor(1, 10)
self.top_splitter.setSizes([180, 500])
self.middle_splitter.setCollapsible(self.middle_splitter.indexOf(self.view), False)
self.middle_splitter.setCollapsible(
self.middle_splitter.indexOf(self.view), False)
self.middle_splitter.setStretchFactor(0, 20)
self.middle_splitter.setStretchFactor(1, 1)
@ -133,7 +159,6 @@ class NodeWidget(QWidget):
self._initNodeInfo()
def _initNodeInfo(self):
self.tree = ModuleOverview(self._node)
infolayout = QVBoxLayout()
@ -162,7 +187,6 @@ class NodeWidget(QWidget):
self.tree.setToDisconnected()
self.setPalette(p)
def _rebuildAdvanced(self, advanced):
self.detailed = advanced
self.tree._rebuildAdvanced(advanced)
@ -213,7 +237,7 @@ class NodeWidget(QWidget):
self.plotParam(module, param, plot)
def _plotPopUp(self, module, param):
plots = {'%s -> %s' % (m,p): (m,p) for (m,p) in self._activePlots}
plots = {'%s -> %s' % mp: mp for mp in self._activePlots}
dialog = QInputDialog()
# dialog.setInputMode()
dialog.setOption(
@ -227,7 +251,6 @@ class NodeWidget(QWidget):
item = dialog.textValue()
self.plotParam(module, param, self._activePlots[plots[item]])
def plotParam(self, module, param, plot=None):
# - liveness?
# - better plot window management?
@ -237,7 +260,8 @@ class NodeWidget(QWidget):
return
if plot:
plot.addCurve(self._node, module, param)
plot.setCurveColor(module, param, Colors.colors[len(plot.curves) % 6])
plot.setCurveColor(module, param,
Colors.colors[len(plot.curves) % 6])
else:
plot = getPlotWidget(self)
plot.addCurve(self._node, module, param)