Skip to content

Commit

Permalink
enh: add help menu with link to docs, about, and software used (close #1
Browse files Browse the repository at this point in the history
)
  • Loading branch information
paulmueller committed Sep 10, 2019
1 parent 9946f62 commit 1f2702f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.5.1
- fix: missing title in FD window and missing FD number in export menu
- enh: add help menu with link to docs, about, and software used (#1)
- docs: add quick guide for importing a nanite training set
- docs: add black/white logo
0.5.0
Expand Down
69 changes: 59 additions & 10 deletions pyjibe/head/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
import signal
import sys
import traceback
import webbrowser

from PyQt5 import uic, QtCore, QtWidgets

import appdirs
import h5py
import lmfit
import matplotlib
import nanite
import numpy
import scipy
import sklearn

from PyQt5 import uic, QtWidgets

from . import custom_widgets

from .. import registry
from ..settings import SettingsFile
from .._version import version as __version__

# load QMainWindow from ui file
ui_path = pkg_resources.resource_filename("pyjibe.head", "main_design.ui")
MainBase = uic.loadUiType(ui_path)[0]


class PyJibeQMdiSubWindow(QtWidgets.QMdiSubWindow):
def closeEvent(self, QCloseEvent):
Expand All @@ -25,18 +32,24 @@ def closeEvent(self, QCloseEvent):
super(PyJibeQMdiSubWindow, self).closeEvent(QCloseEvent)


class PyJibe(QtWidgets.QMainWindow, MainBase):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
MainBase.__init__(self)
self.setupUi(self)
class PyJibe(QtWidgets.QMainWindow):
def __init__(self, *args, **kwargs):
super(PyJibe, self).__init__(*args, **kwargs)
path_ui = pkg_resources.resource_filename("pyjibe.head", "main.ui")
uic.loadUi(path_ui, self)

self.setWindowTitle("PyJibe {}".format(__version__))
# Disable native menubar (e.g. on Mac)
self.menubar.setNativeMenuBar(False)
# Connect menu entries
# File menu
self.action_open_bulk.triggered.connect(self.on_open_bulk)
self.action_open_single.triggered.connect(self.on_open_single)
self.action_open_multiple.triggered.connect(self.on_open_multiple)
# Help menu
self.actionDocumentation.triggered.connect(self.on_documentation)
self.actionSoftware.triggered.connect(self.on_software)
self.actionAbout.triggered.connect(self.on_about)
# Add settings
self.settings = SettingsFile()

Expand Down Expand Up @@ -74,6 +87,20 @@ def rem_subwindow(self, title):
self.menuExport.removeAction(action)
break

def on_about(self):
about_text = "PyJibe is a user interface for data analysis in " \
+ "atomic force microscopy with an emphasis on biological " \
+ "specimens, such as tissue sections or single cells.\n\n" \
+ "Author: Paul Müller\n" \
+ "Repository: https://github.com/AFM-analysis/PyJibe\n" \
+ "Documentation: https://pyjibe.readthedocs.io"
QtWidgets.QMessageBox.about(self,
"PyJibe {}".format(__version__),
about_text)

def on_documentation(self):
webbrowser.open("https://pyjibe.readthedocs.io")

def on_open_bulk(self, evt=None):
dlg = custom_widgets.FileDialog(self)
search_dir = self.settings.get_path("load data")
Expand Down Expand Up @@ -111,6 +138,28 @@ def on_open_single(self, evt=None):
self.load_data(files=[n], retry_open=self.on_open_single)
self.settings.set_path(pathlib.Path(n).parent, name="load data")

def on_software(self):
libs = [appdirs,
h5py,
lmfit,
matplotlib,
nanite,
numpy,
sklearn,
scipy,
]
sw_text = "PyJibe {}\n\n".format(__version__)
sw_text += "Python {}\n\n".format(sys.version)
sw_text += "Modules:\n"
for lib in libs:
sw_text += "- {} {}\n".format(lib.__name__, lib.__version__)
sw_text += "- PyQt5 {}\n".format(QtCore.QT_VERSION_STR)
if hasattr(sys, 'frozen'):
sw_text += "\nThis executable has been created using PyInstaller."
QtWidgets.QMessageBox.information(self,
"Software",
sw_text)

def load_data(self, files, retry_open=None, separate_analysis=False):
# approach-retract data files
supfiles = []
Expand Down
25 changes: 25 additions & 0 deletions pyjibe/head/main_design.ui → pyjibe/head/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,18 @@
<string>&amp;Export</string>
</property>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionDocumentation"/>
<addaction name="actionSoftware"/>
<addaction name="separator"/>
<addaction name="actionAbout"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menuExport"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="action_open_bulk">
Expand Down Expand Up @@ -134,6 +144,21 @@
<string>Open each file as a single analysis</string>
</property>
</action>
<action name="actionDocumentation">
<property name="text">
<string>Documentation</string>
</property>
</action>
<action name="actionSoftware">
<property name="text">
<string>Software</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
description=description,
long_description=open('README.rst').read() if exists('README.rst') else '',
install_requires=["appdirs",
"nanite>=1.1.1",
"nanite>=1.1.2",
"matplotlib",
"pyqt5"],
python_requires='>=3.6, <4',
Expand Down

0 comments on commit 1f2702f

Please sign in to comment.