-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d24121f
commit d71a1d1
Showing
3 changed files
with
357 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from importlib import import_module, resources | ||
import sys | ||
import webbrowser | ||
|
||
from PyQt6 import uic, QtCore, QtWidgets | ||
|
||
from .._version import version | ||
|
||
|
||
class ChipStream(QtWidgets.QMainWindow): | ||
plots_changed = QtCore.pyqtSignal() | ||
|
||
def __init__(self, *arguments): | ||
"""Initialize ChipStream GUI | ||
If you pass the "--version" command line argument, the | ||
application will print the version after initialization | ||
and exit. | ||
""" | ||
QtWidgets.QMainWindow.__init__(self) | ||
ref_ui = resources.files("chipstream.gui") / "main_window.ui" | ||
with resources.as_file(ref_ui) as path_ui: | ||
uic.loadUi(path_ui, self) | ||
|
||
# Settings are stored in the .ini file format. Even though | ||
# `self.settings` may return integer/bool in the same session, | ||
# in the next session, it will reliably return strings. Lists | ||
# of strings (comma-separated) work nicely though. | ||
QtCore.QCoreApplication.setOrganizationName("DC-Analysis") | ||
QtCore.QCoreApplication.setOrganizationDomain( | ||
"https://github.com/DC-analysis") | ||
QtCore.QCoreApplication.setApplicationName("ChipStream") | ||
QtCore.QSettings.setDefaultFormat(QtCore.QSettings.Format.IniFormat) | ||
#: Shape-Out settings | ||
self.settings = QtCore.QSettings() | ||
# GUI | ||
self.setWindowTitle(f"ChipStream {version}") | ||
# Disable native menu bar (e.g. on Mac) | ||
self.menubar.setNativeMenuBar(False) | ||
# File menu | ||
self.actionQuit.triggered.connect(self.on_action_quit) | ||
# Help menu | ||
self.actionDocumentation.triggered.connect(self.on_action_docs) | ||
self.actionSoftware.triggered.connect(self.on_action_software) | ||
self.actionAbout.triggered.connect(self.on_action_about) | ||
|
||
# if "--version" was specified, print the version and exit | ||
if "--version" in arguments: | ||
print(version) | ||
QtWidgets.QApplication.processEvents( | ||
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 300) | ||
sys.exit(0) | ||
|
||
# finalize | ||
self.show() | ||
self.activateWindow() | ||
self.setWindowState(QtCore.Qt.WindowState.WindowActive) | ||
|
||
def on_action_about(self) -> None: | ||
"""Show imprint.""" | ||
gh = "DC-analysis/ChipStream" | ||
rtd = "chipstream.readthedocs.io" | ||
about_text = (f"GUI for DC data postprocessing (background " | ||
f"computation, segmentation, feature extraction)<br><br>" | ||
f"Author: Paul Müller and others<br>" | ||
f"GitHub: " | ||
f"<a href='https://github.com/{gh}'>{gh}</a><br>" | ||
f"Documentation: " | ||
f"<a href='https://{rtd}'>{rtd}</a><br>") # noqa 501 | ||
QtWidgets.QMessageBox.about(self, | ||
f"ChipStream {version}", | ||
about_text) | ||
|
||
@QtCore.pyqtSlot() | ||
def on_action_docs(self): | ||
webbrowser.open("https://chipstream.readthedocs.io") | ||
|
||
@QtCore.pyqtSlot() | ||
def on_action_software(self) -> None: | ||
"""Show used software packages and dependencies.""" | ||
libs = ["dcnum", | ||
"h5py", | ||
"numpy", | ||
] | ||
|
||
sw_text = f"ChipStream {version}\n\n" | ||
sw_text += f"Python {sys.version}\n\n" | ||
sw_text += "Modules:\n" | ||
for lib in libs: | ||
try: | ||
mod = import_module(lib) | ||
except ImportError: | ||
pass | ||
else: | ||
sw_text += f"- {mod.__name__} {mod.__version__}\n" | ||
sw_text += f"- PyQt6 {QtCore.QT_VERSION_STR}\n" | ||
|
||
QtWidgets.QMessageBox.information(self, "Software", sw_text) | ||
|
||
@QtCore.pyqtSlot() | ||
def on_action_quit(self) -> None: | ||
"""Determine what happens when the user wants to quit""" | ||
QtCore.QCoreApplication.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>800</width> | ||
<height>600</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<layout class="QVBoxLayout" name="verticalLayout_5"> | ||
<item> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="text"> | ||
<string>Input files</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QTreeView" name="treeView_2"/> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QVBoxLayout" name="verticalLayout_6"> | ||
<item> | ||
<spacer name="verticalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item alignment="Qt::AlignTop"> | ||
<widget class="QGroupBox" name="groupBox_4"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="title"> | ||
<string>Event Segmentation</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout_2"> | ||
<item row="1" column="1"> | ||
<widget class="QSpinBox" name="spinBox_2"> | ||
<property name="minimum"> | ||
<number>-10</number> | ||
</property> | ||
<property name="maximum"> | ||
<number>-1</number> | ||
</property> | ||
<property name="value"> | ||
<number>-6</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QRadioButton" name="radioButton_3"> | ||
<property name="text"> | ||
<string>Threshold-based</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0"> | ||
<widget class="QRadioButton" name="radioButton_4"> | ||
<property name="text"> | ||
<string>Disabled (from input file)</string> | ||
</property> | ||
<property name="checked"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item alignment="Qt::AlignTop"> | ||
<widget class="QGroupBox" name="groupBox_5"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="title"> | ||
<string>Feature Extraction</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_7"> | ||
<item> | ||
<widget class="QCheckBox" name="checkBox_4"> | ||
<property name="enabled"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="text"> | ||
<string>Standard features</string> | ||
</property> | ||
<property name="checked"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QCheckBox" name="checkBox_5"> | ||
<property name="text"> | ||
<string>Image brightness features</string> | ||
</property> | ||
<property name="checked"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QCheckBox" name="checkBox_6"> | ||
<property name="text"> | ||
<string>Haralick texture features</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QGroupBox" name="groupBox_6"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="title"> | ||
<string>Output Options</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_8"> | ||
<item> | ||
<widget class="QComboBox" name="comboBox_3"> | ||
<item> | ||
<property name="text"> | ||
<string>Use basins (most efficient)</string> | ||
</property> | ||
</item> | ||
<item> | ||
<property name="text"> | ||
<string>Edit files in-place (only for disabled segmenter)</string> | ||
</property> | ||
</item> | ||
<item> | ||
<property name="text"> | ||
<string>Duplicate input files (increases disk usage)</string> | ||
</property> | ||
</item> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QCommandLinkButton" name="commandLinkButton_2"> | ||
<property name="text"> | ||
<string>Run Pipeline</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>800</width> | ||
<height>22</height> | ||
</rect> | ||
</property> | ||
<widget class="QMenu" name="menuHelp"> | ||
<property name="title"> | ||
<string>Help</string> | ||
</property> | ||
<addaction name="actionDocumentation"/> | ||
<addaction name="actionSoftware"/> | ||
<addaction name="actionAbout"/> | ||
</widget> | ||
<widget class="QMenu" name="menuFile"> | ||
<property name="title"> | ||
<string>File</string> | ||
</property> | ||
<addaction name="actionQuit"/> | ||
</widget> | ||
<addaction name="menuFile"/> | ||
<addaction name="menuHelp"/> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
<action name="actionExit"> | ||
<property name="text"> | ||
<string>Quit</string> | ||
</property> | ||
</action> | ||
<action name="actionAbout"> | ||
<property name="text"> | ||
<string>About</string> | ||
</property> | ||
</action> | ||
<action name="actionSoftware"> | ||
<property name="text"> | ||
<string>Software</string> | ||
</property> | ||
</action> | ||
<action name="actionDocumentation"> | ||
<property name="text"> | ||
<string>Documentation</string> | ||
</property> | ||
</action> | ||
<action name="actionQuit"> | ||
<property name="text"> | ||
<string>Quit</string> | ||
</property> | ||
</action> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |