...
 
Commits (31)
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
from .scriptselector import scriptSelector
__all__ = ['scriptSelector']
import sys
from PySide2.QtWidgets import QDialog, QTreeWidgetItem, QTreeWidget, QTreeWidgetItemIterator
from PySide2.QtCore import Qt
from gui import ui_scriptselector
class scriptSelector(QDialog):
def __init__(self, parent=None):
super().__init__()
if not parent:
sys.exit(5)
self.parent = parent
self.parent.log.debug('scriptSelector init')
self.changed = False
self.initWin()
self.parent.log.debug('scriptSelector finished init')
def initWin(self):
self.ui = ui_scriptselector.Ui_dPlotScripts()
self.ui.setupUi(self)
for cmd in self.parent.expValCmds:
parent = QTreeWidgetItem(self.ui.tCmds)
parent.setText(0, '{}'.format(cmd['name']))
parent.setToolTip(0, '{}'.format(cmd['name']))
parent.setText(1, '{}'.format(cmd['cmd']))
parent.setToolTip(1, '{}'.format(cmd['cmd']))
if cmd['name'] in ['OT20']:
parent.setDisabled(True)
else:
parent.setFlags(parent.flags() | Qt.ItemIsEditable)
self.parent.ui.actionPlotScripts.triggered.connect(self.parent.settings_exp_val_cmds)
self.ui.btnAdd.clicked.connect(self.addCmd)
self.ui.btnDel.clicked.connect(self.delCmd)
self.ui.btnUp.clicked.connect(self.upCmd)
self.ui.btnDown.clicked.connect(self.downCmd)
self.ui.tCmds.itemChanged.connect(lambda item, col: item.setToolTip(col, item.text(col)))
def exec(self):
self.changed = False
return super().exec_()
def accept(self):
if self.changed:
for cmd in QTreeWidgetItemIterator(self.ui.tCmds):
item = cmd.value()
if item.text(0).startswith('<') or item.text(0).endswith('>') or item.text(1).startswith('<') or item.text(1).endswith('>'):
self.ui.tCmds.takeTopLevelItem(self.ui.tCmds.indexOfTopLevelItem(item))
super().accept()
def reject(self):
if self.changed:
self.ui.tCmds.clear()
for cmd in self.parent.expValCmds:
parent = QTreeWidgetItem(self.ui.tCmds)
parent.setText(0, '{}'.format(cmd['name']))
parent.setToolTip(0, '{}'.format(cmd['name']))
parent.setText(1, '{}'.format(cmd['cmd']))
parent.setToolTip(1, '{}'.format(cmd['cmd']))
if cmd['name'] in ['OT20']:
parent.setDisabled(True)
else:
parent.setFlags(parent.flags() | Qt.ItemIsEditable)
super().reject()
def getCmds(self):
return [{'name': cmd.value().text(0), 'cmd': cmd.value().text(1)} for cmd in QTreeWidgetItemIterator(self.ui.tCmds)]
def upCmd(self):
index = self.ui.tCmds.indexOfTopLevelItem(self.ui.tCmds.currentItem())
if index > 0:
item = self.ui.tCmds.takeTopLevelItem(index)
self.ui.tCmds.insertTopLevelItem(index-1, item)
self.ui.tCmds.setCurrentItem(item)
def downCmd(self):
index = self.ui.tCmds.indexOfTopLevelItem(self.ui.tCmds.currentItem())
if index < self.ui.tCmds.model().rowCount() - 1:
item = self.ui.tCmds.takeTopLevelItem(index)
self.ui.tCmds.insertTopLevelItem(index+1, item)
self.ui.tCmds.setCurrentItem(item)
def addCmd(self):
parent = QTreeWidgetItem(self.ui.tCmds)
parent.setText(0, '{}'.format('<Name>'))
parent.setText(1, '{}'.format('<Command>'))
parent.setFlags(parent.flags() | Qt.ItemIsEditable)
self.ui.tCmds.setCurrentItem(parent)
self.ui.tCmds.editItem(parent, 0)
self.changed = True
def delCmd(self):
row = self.ui.tCmds.currentIndex().row()
if row < 0:
return
self.ui.tCmds.takeTopLevelItem(row)
self.changed = True
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>aboutWin</class>
<widget class="QDialog" name="aboutWin">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>253</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">
<string>Info</string>
</attribute>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res.qrc">:/icons/run_local</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>50</x>
<y>10</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Calculation still running (locally)</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Calculation still running (remotely)</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res.qrc">:/icons/run_remote</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>50</x>
<y>90</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Calculation aborted/not finished correctly</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res.qrc">:/icons/aborted</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>50</x>
<y>130</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Calculation finished correctly</string>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res.qrc">:/icons/finished</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>PlotScripts</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Your scripts/wrappers need to match the following requirements:&lt;/p&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:-20px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;have an unique name&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:-20px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;take an argument &lt;span style=&quot; background-color:#d3d3d3;&quot;&gt;-r&lt;/span&gt; for those calculations which are still running&lt;br /&gt;(ignoring the argument might be fine)&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Author</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelContact">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Author&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;: Sebastian Lenz &amp;lt;sebastian@slenz.net&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;This tool was developed during my master thesis at the Burghardt Group (Goethe University Frankfurt, Germany).&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Icons made by &lt;a href=&quot;https://www.flaticon.com/authors/freepik&quot;&gt;&lt;span style=&quot; font-style:italic; text-decoration: underline; color:#000000;&quot;&gt;Freepik&lt;/span&gt;&lt;/a&gt; from &lt;a href=&quot;https://www.flaticon.com/&quot;&gt;&lt;span style=&quot; font-style:italic; text-decoration: underline; color:#000000;&quot;&gt;www.flaticon.com&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="res.qrc"/>
<include location="../../../../.designer/backup/res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>aboutWin</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>aboutWin</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
This diff is collapsed.
<RCC>
<qresource prefix="icons">
<file>res/icons/down_blue.png</file>
<file>res/icons/down_green.png</file>
<file alias="down">res/icons/down_red.png</file>
<file>res/icons/down_yellow.png</file>
<file>res/icons/up_blue.png</file>
<file alias="up">res/icons/up_green.png</file>
<file>res/icons/up_red.png</file>
<file>res/icons/up_yellow.png</file>
<file>res/icons/bar-chart_blue.png</file>
<file alias="bar-chart_green">res/icons/bar-chart_green.png</file>
<file>res/icons/bar-chart_red.png</file>
<file>res/icons/bar-chart_yellow.png</file>
<file>res/icons/plot_blue.png</file>
<file alias="plot_green">res/icons/plot_green.png</file>
<file>res/icons/plot_red.png</file>
<file>res/icons/plot_yellow.png</file>
<file alias="minus_box_red">res/icons/minus_box_red.png</file>
<file alias="minus_red">res/icons/minus_red.png</file>
<file alias="plus_green">res/icons/plus_green.png</file>
<file alias="run_remote">res/icons/play_round_blue.gif</file>
<file>res/icons/cpu-processor.png</file>
<file>res/icons/play_round_blue.gif</file>
<file alias="run_local">res/icons/play_round_orange.gif</file>
<file>res/icons/microchip_black.png</file>
<file>res/icons/play_blue.png</file>
<file>res/icons/play_green.png</file>
<file>res/icons/play_red.png</file>
<file>res/icons/play_round_blue.png</file>
<file>res/icons/play_round_green.gif</file>
<file>res/icons/play_round_green.png</file>
<file>res/icons/play_round_red.png</file>
<file>res/icons/play_round_yellow.png</file>
<file>res/icons/play_yellow.png</file>
<file>res/icons/ram-memory.png</file>
<file>res/icons/stop_blue.png</file>
<file alias="finished">res/icons/stop_green.png</file>
<file alias="aborted">res/icons/stop_red.png</file>
<file>res/icons/stop_round_blue.png</file>
<file>res/icons/stop_round_green.png</file>
<file>res/icons/stop_round_red.png</file>
<file>res/icons/stop_round_yellow.png</file>
<file>res/icons/stop_yellow.png</file>
<file alias="chip">res/icons/chip.png</file>
<file alias="chip_color">res/icons/chip_color.png</file>
<file alias="microchip_color">res/icons/microchip_color.png</file>
<file alias="microchip">res/icons/microchip.png</file>
</qresource>
<qresource prefix="styles">
<file alias="global.qss">res/styles/global.qss</file>
</qresource>
</RCC>
QTreeWidget {
selection-background-color: lightgray;
selection-color: black;
}
QTreeWidget::item:disabled {
color: rgb(85, 87, 83);
}
QPushButton#btnDel:!hover:!pressed, QPushButton#btnAdd:!hover:!pressed, QPushButton#btnUp:!hover:!pressed, QPushButton#btnDown:!hover:!pressed {
border: none;
background: none;
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dPlotScripts</class>
<widget class="QDialog" name="dPlotScripts">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>453</width>
<height>356</height>
</rect>
</property>
<property name="windowTitle">
<string>Plot scripts for expectation values</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="tCmds">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Command</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnDown">
<property name="minimumSize">
<size>
<width>28</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/icons/down</normaloff>:/icons/down</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUp">
<property name="minimumSize">
<size>
<width>28</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/icons/up</normaloff>:/icons/up</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDel">
<property name="minimumSize">
<size>
<width>28</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/minus_red</normalon>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAdd">
<property name="minimumSize">
<size>
<width>28</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/icons/plus_green</normaloff>:/icons/plus_green</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>dPlotScripts</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>dPlotScripts</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'gui/about.ui',
# licensing of 'gui/about.ui' applies.
#
# Created: Thu Sep 12 18:15:39 2019
# by: pyside2-uic running on PySide2 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PySide2 import QtCore, QtGui, QtWidgets
class Ui_aboutWin(object):
def setupUi(self, aboutWin):
aboutWin.setObjectName("aboutWin")
aboutWin.resize(400, 253)
self.verticalLayout = QtWidgets.QVBoxLayout(aboutWin)
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = QtWidgets.QTabWidget(aboutWin)
self.tabWidget.setObjectName("tabWidget")
self.tab_1 = QtWidgets.QWidget()
self.tab_1.setObjectName("tab_1")
self.label = QtWidgets.QLabel(self.tab_1)
self.label.setGeometry(QtCore.QRect(10, 10, 31, 31))
self.label.setText("")
self.label.setPixmap(QtGui.QPixmap(":/icons/run_local"))
self.label.setScaledContents(True)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.tab_1)
self.label_2.setGeometry(QtCore.QRect(50, 10, 321, 31))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.tab_1)
self.label_3.setGeometry(QtCore.QRect(50, 50, 321, 31))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.tab_1)
self.label_4.setGeometry(QtCore.QRect(10, 50, 31, 31))
self.label_4.setText("")
self.label_4.setPixmap(QtGui.QPixmap(":/icons/run_remote"))
self.label_4.setScaledContents(True)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.tab_1)
self.label_5.setGeometry(QtCore.QRect(50, 90, 321, 31))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.tab_1)
self.label_6.setGeometry(QtCore.QRect(10, 90, 31, 31))
self.label_6.setText("")
self.label_6.setPixmap(QtGui.QPixmap(":/icons/aborted"))
self.label_6.setScaledContents(True)
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.tab_1)
self.label_7.setGeometry(QtCore.QRect(50, 130, 321, 31))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(self.tab_1)
self.label_8.setGeometry(QtCore.QRect(10, 130, 31, 31))
self.label_8.setText("")
self.label_8.setPixmap(QtGui.QPixmap(":/icons/finished"))
self.label_8.setScaledContents(True)
self.label_8.setObjectName("label_8")
self.tabWidget.addTab(self.tab_1, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.gridLayout = QtWidgets.QGridLayout(self.tab_2)
self.gridLayout.setObjectName("gridLayout")
self.label_9 = QtWidgets.QLabel(self.tab_2)
self.label_9.setStyleSheet("")
self.label_9.setWordWrap(True)
self.label_9.setObjectName("label_9")
self.gridLayout.addWidget(self.label_9, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_2, "")
self.tab_3 = QtWidgets.QWidget()
self.tab_3.setObjectName("tab_3")
self.gridLayout_2 = QtWidgets.QGridLayout(self.tab_3)
self.gridLayout_2.setObjectName("gridLayout_2")
self.labelContact = QtWidgets.QLabel(self.tab_3)
self.labelContact.setTextFormat(QtCore.Qt.RichText)
self.labelContact.setWordWrap(True)
self.labelContact.setOpenExternalLinks(True)
self.labelContact.setObjectName("labelContact")
self.gridLayout_2.addWidget(self.labelContact, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_3, "")
self.verticalLayout.addWidget(self.tabWidget)
self.buttonBox = QtWidgets.QDialogButtonBox(aboutWin)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(aboutWin)
self.tabWidget.setCurrentIndex(0)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), aboutWin.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), aboutWin.reject)
QtCore.QMetaObject.connectSlotsByName(aboutWin)
def retranslateUi(self, aboutWin):
aboutWin.setWindowTitle(QtWidgets.QApplication.translate("aboutWin", "About", None, -1))
self.label_2.setText(QtWidgets.QApplication.translate("aboutWin", "Calculation still running (locally)", None, -1))
self.label_3.setText(QtWidgets.QApplication.translate("aboutWin", "Calculation still running (remotely)", None, -1))
self.label_5.setText(QtWidgets.QApplication.translate("aboutWin", "Calculation aborted/not finished correctly", None, -1))
self.label_7.setText(QtWidgets.QApplication.translate("aboutWin", "Calculation finished correctly", None, -1))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_1), QtWidgets.QApplication.translate("aboutWin", "Info", None, -1))
self.label_9.setText(QtWidgets.QApplication.translate("aboutWin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Cantarell\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Your scripts/wrappers need to match the following requirements:</p>\n"
"<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;\"><li style=\" margin-top:12px; margin-bottom:0px; margin-left:-20px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">have an unique name</li>\n"
"<li style=\" margin-top:0px; margin-bottom:12px; margin-left:-20px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">take an argument <span style=\" background-color:#d3d3d3;\">-r</span> for those calculations which are still running<br />(ignoring the argument might be fine)</li></ul></body></html>", None, -1))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtWidgets.QApplication.translate("aboutWin", "PlotScripts", None, -1))
self.labelContact.setText(QtWidgets.QApplication.translate("aboutWin", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Cantarell\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:600;\">Author</span><span style=\" font-family:\'Sans Serif\'; font-size:9pt;\">: Sebastian Lenz &lt;sebastian@slenz.net&gt;</span></p>\n"
"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'Sans Serif\'; font-size:9pt;\">This tool was developed during my master thesis at the Burghardt Group (Goethe University Frankfurt, Germany).</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Icons made by <a href=\"https://www.flaticon.com/authors/freepik\"><span style=\" font-style:italic; text-decoration: underline; color:#000000;\">Freepik</span></a> from <a href=\"https://www.flaticon.com/\"><span style=\" font-style:italic; text-decoration: underline; color:#000000;\">www.flaticon.com</span></a></p></body></html>", None, -1))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QtWidgets.QApplication.translate("aboutWin", "Author", None, -1))
import res_rc
import res_rc
This diff is collapsed.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'gui/scriptselector.ui',
# licensing of 'gui/scriptselector.ui' applies.
#
# Created: Wed Sep 11 16:53:54 2019
# by: pyside2-uic running on PySide2 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PySide2 import QtCore, QtGui, QtWidgets
class Ui_dPlotScripts(object):
def setupUi(self, dPlotScripts):
dPlotScripts.setObjectName("dPlotScripts")
dPlotScripts.resize(453, 356)
dPlotScripts.setStyleSheet("")
self.gridLayout = QtWidgets.QGridLayout(dPlotScripts)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.tCmds = QtWidgets.QTreeWidget(dPlotScripts)
self.tCmds.setObjectName("tCmds")
self.verticalLayout.addWidget(self.tCmds)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.btnDown = QtWidgets.QPushButton(dPlotScripts)
self.btnDown.setMinimumSize(QtCore.QSize(28, 24))
self.btnDown.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/down"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btnDown.setIcon(icon)
self.btnDown.setObjectName("btnDown")
self.horizontalLayout.addWidget(self.btnDown)
self.btnUp = QtWidgets.QPushButton(dPlotScripts)
self.btnUp.setMinimumSize(QtCore.QSize(28, 24))
self.btnUp.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/up"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btnUp.setIcon(icon1)
self.btnUp.setObjectName("btnUp")
self.horizontalLayout.addWidget(self.btnUp)
self.btnDel = QtWidgets.QPushButton(dPlotScripts)
self.btnDel.setMinimumSize(QtCore.QSize(28, 24))
self.btnDel.setStyleSheet("")
self.btnDel.setText("")
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/icons/minus_red"), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.btnDel.setIcon(icon2)
self.btnDel.setObjectName("btnDel")
self.horizontalLayout.addWidget(self.btnDel)
self.btnAdd = QtWidgets.QPushButton(dPlotScripts)
self.btnAdd.setMinimumSize(QtCore.QSize(28, 24))
self.btnAdd.setStyleSheet("")
self.btnAdd.setText("")
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/icons/plus_green"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btnAdd.setIcon(icon3)
self.btnAdd.setObjectName("btnAdd")
self.horizontalLayout.addWidget(self.btnAdd)
self.verticalLayout.addLayout(self.horizontalLayout)
self.buttonBox = QtWidgets.QDialogButtonBox(dPlotScripts)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(False)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.retranslateUi(dPlotScripts)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), dPlotScripts.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), dPlotScripts.reject)
QtCore.QMetaObject.connectSlotsByName(dPlotScripts)
def retranslateUi(self, dPlotScripts):
dPlotScripts.setWindowTitle(QtWidgets.QApplication.translate("dPlotScripts", "Plot scripts for expectation values", None, -1))
self.tCmds.headerItem().setText(0, QtWidgets.QApplication.translate("dPlotScripts", "Name", None, -1))
self.tCmds.headerItem().setText(1, QtWidgets.QApplication.translate("dPlotScripts", "Command", None, -1))
import res_rc
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env python3
import sys
import os
from pathlib import Path
import logging
import argparse as ap
import re
import numpy as np
import matplotlib as mpl
import warnings
#warnings.filterwarnings("ignore")
#mpl.use('pgf')
def figsize(scale):
fig_width_pt = 422.52348 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean*0.5 # height in inches
fig_width = 600*inches_per_pt
fig_height = fig_width*golden_mean*0.75
fig_size = [fig_width, fig_height]
return fig_size
pgf_with_latex = { # setup matplotlib to use latex for output
"pgf.texsystem": "lualatex", # change this if using xetex or luatex
"text.usetex": True, # use LaTeX to write all text
"font.family": "serif",
"font.serif": ["Latin Modern Roman"],
# "font.serif": [], # blank entries should cause plots to inherit fonts from the document
# "font.sans-serif": [],
# "font.monospace": [],
"axes.labelsize": 11, # LaTeX default is 10pt font.
"font.size": 11,
"legend.fontsize": 10, # Make the legend/label fonts a little smaller
"xtick.labelsize": 10,
"ytick.labelsize": 10,
"figure.figsize": figsize(1.0), # default fig size of 0.9 textwidth
"pgf.preamble": "\\usepackage{upgreek}",
}
mpl.rcParams.update(pgf_with_latex)
import matplotlib.pyplot as plt
log = logging.getLogger('PlotIntSteps')
log_handler = logging.StreamHandler()
log_handler.setFormatter(logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s'))
log.addHandler(log_handler)
log.setLevel(logging.INFO)
class ArgParser(ap.ArgumentParser):
def error(self, message):
sys.stderr.write('error: {:s}\n\n'.format(message))
self.print_help()
sys.exit(2)
def find_nearest_idx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
parser = ArgParser(description='Plotting the integrator steps of a TLG calculation.')
parser.add_argument('-r', '--refresh', action='store_true', help='Refresh automatically')
parser.add_argument('-D', '--debug', action='store_true', help='Output debug logs')
parser.add_argument('-E', '--external', action='store_true', help='Don\'t output anything for external usage')
parser.add_argument('-p', '--path', default='.', help='Path to calculation directory')
args = parser.parse_args()
if args.debug:
log.setLevel(logging.DEBUG)
if args.external:
log.setLevel(logging.ERROR)
path = Path(args.path)
inp = path/'sorbet.inp'
if not inp.is_file():
log.error('Sorbet input not found!')
sys.exit(3)
with inp.open() as f:
lines = f.readlines()
spfsect = False
for line in lines:
if line.startswith('tmax'):
rex = re.match(r'tmax\s*=\s*(\d+\.?\d*E(?:\+|-)\d+)', line)
#tmax = rex.group(1).split('d')
#tmax = tmax[0]+'e'+tmax[1]
tmax = int(float(rex.group(1)))
log.debug('tmax: {}'.format(tmax))
break
fint = path/'integrator.log'
fps = path/'phase.space'
# read integration step
integdata = np.loadtxt(fint, dtype="S", skiprows=5)[::100]
integdata = list(zip(*integdata))
stepsize = [ float(t[0:-3]) for t in integdata[8] ]
time = [ float(t[0:-2]) for t in integdata[12] ]
average = sum(stepsize)/len(time)
log.info('Plotting...')
fig, axs = plt.subplots(1, 2)
psteps1, = axs[0].plot(time, stepsize, linewidth=1)
avg_line_l = axs[0].axhline(average, linewidth=2, color='r')
ylim = axs[0].get_ylim()
axs[0].set_xlim([0, tmax])
axs[0].set_ylim([0, ylim[1]])
if time[-1] < 50:
s_idx = 0
time_s = 0
else:
s_idx = find_nearest_idx(time, time[-1]-50)
time_s = time[s_idx]
psteps2, = axs[1].plot(time[s_idx:], stepsize[s_idx:], linewidth=1)
avg_line_r = axs[1].axhline(average, linewidth=2, color='r')
axs[1].set_xlim([time_s, time[-1]])
#axs[1].set_ylim([0, ylim[1]])
rect = mpl.patches.Rectangle((time_s, 0), time[-1]-time_s+10, ylim[1]-ylim[0], fill=False, color='k')
axs[0].add_artist(rect)
if args.refresh:
log.info('Refresh active: {}'.format(args.refresh))
live='LIVE: '
else:
live=''
old_time = time[-1]
fig.suptitle(live+r'Integrator steps at {:.0f}fs'.format(old_time))
plt.text(x=0.5, y=0.90, s=r'{}'.format(Path(args.path).resolve()).replace(r'_',r'\_'), fontsize=12, ha="center", transform=fig.transFigure)
log.info('Done.')
plt.ion()
plt.show(block=False)
def newpause(interval):
backend = plt.rcParams['backend']
if backend in mpl.rcsetup.interactive_bk:
figManager = mpl._pylab_helpers.Gcf.get_active()
if figManager is not None:
canvas = figManager.canvas
if canvas.figure.stale:
canvas.draw()
canvas.start_event_loop(interval)
return
while args.refresh and old_time < tmax:
try:
newpause(5)
except:
log.debug('KTHXBYE')
sys.exit(0)
with fps.open('rb') as f:
f.seek(-2, os.SEEK_END) # Jump to the second last byte.
try:
while f.read(1) != b"\n": # Until EOL is found...
f.seek(-2, os.SEEK_CUR) # ...jump back the read byte plus one more.
last = f.readline() # Read last line.
except:
continue
calc_time = np.loadtxt([last], usecols=(1))
if calc_time > old_time:
old_time = calc_time
integdata = np.loadtxt(fint, dtype="S", skiprows=5)[::100]
integdata = list(zip(*integdata))
stepsize = [ float(t[0:-3]) for t in integdata[8] ]
time = [ float(t[0:-2]) for t in integdata[12] ]
average = sum(stepsize)/len(time)
log.debug('Updating Data, t={:.0f} fs'.format(old_time))
fig.suptitle(live+r'Integrator steps at {:.0f}fs'.format(old_time))
psteps1.set_data(time, stepsize)
axs[0].relim()
axs[0].autoscale(axis='y')
ylim = axs[0].get_ylim()
axs[0].set_ylim([0, ylim[1]])
if time[-1] < 50:
s_idx = 0
time_s = 0
else:
s_idx = find_nearest_idx(time, time[-1]-50)
time_s = time[s_idx]
psteps2.set_data(time[s_idx:], stepsize[s_idx:])
axs[1].relim()
axs[1].autoscale(axis='y')
axs[1].set_xlim([time_s, time[-1]])
rect.set_bounds(time_s, 0, time[-1]-time_s+10, ylim[1])
avg_line_l.set_ydata(average)
avg_line_r.set_ydata(average)
else:
continue
plt.ioff()
plt.show()
#plt.savefig(Path(args.path)/'intstep.pdf', bbox_inches='tight')
This diff is collapsed.
import numpy as np
import scipy as sp
import matplotlib as mpl
_clim = [-1, 1]
_clim_mat = np.arange(_clim[0], _clim[1], np.diff(_clim, n=1, axis=0)/62)
_b = np.absolute(_clim_mat).argmin()+1
if _b % 2 == 0:
_clr_ind = [int(_b/2), _b, int((62-_b)/2)+_b, 63]
elif _b % 2 > 0:
_clr_ind = [int((_b-1)/2), _b, int((63-_b)/2)+_b, 63]
_c1 = np.concatenate((np.zeros((1, _clr_ind[0]-1)),
np.array([np.arange(0, 1+1/(_clr_ind[1]-_clr_ind[0]-1), 1/(_clr_ind[1]-_clr_ind[0]-1))]),
np.ones((1, _clr_ind[2]-_clr_ind[1])),
np.array([np.arange(1, 0.5238-0.4762/(_clr_ind[3]-_clr_ind[2]), -0.4762/(_clr_ind[3]-_clr_ind[2]))])), axis=1)
_c2 = np.concatenate((np.zeros((1, _clr_ind[0]-1)),
np.array([np.arange(0, 1+1/(_clr_ind[1]-_clr_ind[0]-1), 1/(_clr_ind[1]-_clr_ind[0]-1))]),
np.array([np.arange(1, 0.5238- 0.4762/(_clr_ind[2]-_clr_ind[1]), -0.4762/(_clr_ind[2]-_clr_ind[1]-1))]),
np.zeros((1, _clr_ind[3]-_clr_ind[2]+1))), axis=1)
_c3 = np.concatenate((np.array([np.arange(0.5238, 1+0.4762/(_clr_ind[0]-1), 0.4762/(_clr_ind[0]-2))]),
np.ones((1, _clr_ind[1]-_clr_ind[0]+1)),
np.array([np.arange(1, 0, -1/(_clr_ind[2]-_clr_ind[1]-1))]),
np.zeros((1, _clr_ind[2]-_clr_ind[1]+2))), axis=1)
_rwb_colors = np.concatenate((_c1.T, _c2.T, _c3.T), axis=1)
cmap = mpl.colors.ListedColormap(colors=_rwb_colors, name='rwb3D')
class MidpointNormalize(mpl.colors.Normalize):
def __init__(self, vmin, vmax, midpoint=0, clip=False):
self.midpoint = midpoint
mpl.colors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
if self.vmin != 0 and self.vmax != 0:
normalized_min = max(0, 1 / 2 * (1 - abs((self.midpoint - self.vmin) / (self.midpoint - self.vmax))))
normalized_max = min(1, 1 / 2 * (1 + abs((self.vmax - self.midpoint) / (self.midpoint - self.vmin))))
else:
normalized_min = 0
normalized_max = 1
normalized_mid = 0.5
x, y = [self.vmin, self.midpoint, self.vmax], [normalized_min, normalized_mid, normalized_max]
return sp.ma.masked_array(sp.interp(value, x, y))
set term qt size 1000,500
stats [0:1010] '< ~/projects/utility-scripts/OT20TLG/scripts/pint.sh' u 1:2 nooutput
LASTTIME=sprintf("%d",floor(STATS_max_x))
set multiplot layout 1,2 title "Integrator stepsize at ".LASTTIME." fs\n".GPVAL_PWD
MEAN=STATS_mean_y
set object 1 rect from STATS_max_x-50,0 to STATS_max_x+10,1 lw 2 fs empty front
p [0:1010] '< ~/projects/utility-scripts/OT20TLG/scripts/pint.sh' u 1:2 w l lc 'blue' t 'intsteps', '' u 1:(MEAN) w l lw 2 lc 'red' t 'mean intstep'
stats '< ~/projects/utility-scripts/OT20TLG/scripts/plastint.sh' u 1:2 nooutput
unset object 1
p[STATS_max_x-50:STATS_max_x+10] '< ~/projects/utility-scripts/OT20TLG/scripts/plastint.sh' u 1:2 w l lc 'blue' t 'intsteps', '' u 1:(MEAN) w l lw 2 lc 'red' t 'mean intstep'
unset multiplot
set term qt size 1000,500
stats [0:1010] '< ~/projects/utility-scripts/OT20TLG/scripts/pint.sh' u 1:2 nooutput
LASTTIME=sprintf("%d",floor(STATS_max_x))
set multiplot layout 1,2 title "LIVE: Integrator stepsize at ".LASTTIME." fs\n".GPVAL_PWD
MEAN=STATS_mean_y
set object 1 rect from STATS_max_x-50,0 to STATS_max_x+10,1 lw 2 fs empty front
p [0:1010] '< ~/projects/utility-scripts/OT20TLG/scripts/pint.sh' u 1:2 w l lc 'blue' t 'intsteps', '' u 1:(MEAN) w l lw 2 lc 'red' t 'mean intstep'
stats '< ~/projects/utility-scripts/OT20TLG/scripts/plastint.sh' u 1:2 nooutput
unset object 1
p[STATS_max_x-50:STATS_max_x+10] '< ~/projects/utility-scripts/OT20TLG/scripts/plastint.sh' u 1:2 w l lc 'blue' t 'intsteps', '' u 1:(MEAN) w l lw 2 lc 'red' t 'mean intstep'
unset multiplot
pause 5
reread
#!/bin/sh
awk '{print substr($13, 1, length($13)-2), substr($9, 1, length($9)-3)}' integrator.log
#!/bin/sh
tail -n 2000 integrator.log | awk '{print substr($13, 1, length($13)-2), substr($9, 1, length($9)-3)}'
#!/usr/bin/env python3
import sys
import logging
import argparse as ap
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QFile, QIODevice, QTextStream
import res_rc
loglevel = logging.INFO
log = logging.getLogger(__name__)
log_handler = logging.StreamHandler()
log_handler.setFormatter(logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s'))
log.addHandler(log_handler)
log.setLevel(loglevel)
class ArgParser(ap.ArgumentParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.log = logging.getLogger('ArgParser')
self.log.addHandler(log_handler)
self.log.setLevel(loglevel)
def error(self, message):
self.log.error('{:s}\n\n'.format(message))
self.print_help()
sys.exit(2)
parser = ArgParser(description='Analyzer for TLG dynamics.')
parser.add_argument('-D', '--debug', action='store_true', help='Output debug logs')
args = parser.parse_args()
if args.debug:
loglevel = logging.DEBUG
log.setLevel(loglevel)
if __name__ == '__main__':
from mainWindow import TLGanalyzer
app = QApplication(sys.argv)
app.setApplicationName('TLGanalyzer')
app.setOrganizationName('2LGMCTDH')
qssf = QFile(':/styles/global.qss')
qssf.open(QIODevice.ReadOnly | QIODevice.Text)
qss = qssf.readAll()
qssf.close()
app.setStyleSheet(QTextStream(qss).readAll())
mainWin = TLGanalyzer(loglevel, log_handler)
sys.exit(app.exec_())