Skip to content

Commit

Permalink
HTML docs added to main UI #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tlancon committed Jun 4, 2021
1 parent 384b72a commit 8b2b533
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
26 changes: 26 additions & 0 deletions apps/documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from PyQt5.QtWidgets import QWidget, QVBoxLayout
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl

# shamelessly ripped off from: http://zetcode.com/pyqt/qwebengineview/


class Documentation(QWidget):
def __init__(self):
super().__init__()
self.init_UI()

def init_UI(self):
vbox = QVBoxLayout(self)
self.webEngineView = QWebEngineView()
self.load_page()
vbox.addWidget(self.webEngineView)
self.setLayout(vbox)
self.setGeometry(100, 100, 1000, 800)
self.setWindowTitle('CIM Documentation')
self.show()

def load_page(self):
with open('./docs/documentation.html', 'r') as f:
html = f.read()
self.webEngineView.setHtml(html, baseUrl=QUrl('file:///docs/'))
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from PyQt5.QtGui import QColor
from skimage.io import imread
from skimage.transform import SimilarityTransform
from apps import documentation

# Need to be able to find mplwidget.py
custom_app_path = f"{os.path.dirname(os.path.realpath(__file__))}/app/"
custom_app_path = f"{os.path.dirname(os.path.realpath(__file__))}/apps/"
if custom_app_path not in sys.path:
sys.path.append(custom_app_path)

Expand All @@ -20,7 +21,7 @@
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)

# Load Qt Designer file
qt_designer_file = os.path.abspath('./app/interface.ui')
qt_designer_file = os.path.abspath('apps/interface.ui')
Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_designer_file)


Expand All @@ -32,7 +33,7 @@ def __init__(self):
Ui_MainWindow.__init__(self)
self.setupUi(self)

# Need some variables to hold information throughout the app
# Need some variables to hold information throughout the apps
self.images = {
'reference': {
'directory': '',
Expand Down Expand Up @@ -346,9 +347,9 @@ def choose_moving_color(self):

def show_documentation(self):
"""
Displays HTML documentation to the user.
Loads and displays simple HTML documentation.
"""
print('Showing docs')
self.docs = documentation.Documentation()


if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PyQt5
PyQtWebEngine
numpy
matplotlib
scikit-image

0 comments on commit 8b2b533

Please sign in to comment.