def __init__(self, parent=None): super(Manual, self).__init__() self.manual = QWebEngineView() webpage = QtCore.QUrl('https://wingtorres.github.io/morphometrix/') self.manual.setUrl(webpage) self.grid = QGridLayout() self.grid.addWidget(self.manual,1,0) self.setLayout(self.grid)
def select_folder(self): name = QtWidgets.QFileDialog.getExistingDirectory( self, 'Select image folder', self.canvas.directory) if name != '': self.canvas.load([QtCore.QUrl('file:{}'.format(name))])
def __init__(self): super(MainGUI, self).__init__() # Create empty text box # textEdit = QtWidgets.QTextEdit() # self.setCentralWidget(textEdit) # Menubar Quit action: quitAction = QtGui.QAction('&Quit', self) quitAction.setShortcut('Ctrl+Q') quitAction.setStatusTip('Exit application') quitAction.triggered.connect(QtWidgets.QApplication.quit) # Menubar Documentation action: documentationAction = QtGui.QAction('&Documentation', self) documentationAction.setShortcut('F1') documentationAction.setStatusTip('Help and guidelines on NEPyH') documentationAction.triggered.connect( lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(__homepage__))) # Menubar YAML lint action: yamllintAction = QtGui.QAction('&YAML lint', self) yamllintAction.setStatusTip('Online YAML validation tool') yamllintAction.triggered.connect( lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(__YAMLlint__))) # Menubar Issues action: issuesAction = QtGui.QAction('&Issues', self) issuesAction.setStatusTip('Report bugs and issues') issuesAction.triggered.connect( lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(__issues__))) # Menubar SW Upgrade action: swupgradeAction = QtGui.QAction('&SW Upgrade', self) swupgradeAction.setStatusTip('Check for new software versions') # Menubar About action: aboutAction = QtGui.QAction('&About', self) aboutAction.setStatusTip('Information about NEPyH') aboutAction.triggered.connect(lambda: self.about()) # Create a status bar self.statusBar() # Create a menu bar menubar = self.menuBar() # Menubar File fileMenu = menubar.addMenu('&File') fileMenu.addAction(quitAction) # Menubar Help helpMenu = menubar.addMenu('&Help') helpMenu.addAction(documentationAction) helpMenu.addAction(yamllintAction) helpMenu.addAction(issuesAction) helpMenu.addAction(swupgradeAction) helpMenu.addAction(aboutAction) # Create a toolbar # toolbar = self.addToolBar('CFG Gen') # toolbar.addAction(changeLayoutCFG) # toolbar = self.addToolBar('Shut / No Shut') # Create a central Widgets centralWidget = QtWidgets.QWidget() # Create a Layout for the central Widget centralLayout = QtWidgets.QGridLayout() # Config generator Layout elements # Labels self.databaseLb = QtWidgets.QLabel('Database: (YAML)') self.templateLb = QtWidgets.QLabel('Template: (Jinja2)') self.projectLb = QtWidgets.QLabel('Project name:') self.fileExtLb = QtWidgets.QLabel('Output file extension:') # Text lines self.databaseEdit = DragDropQLineEdit( '< Drag & Drop a YAML file or Browse >', self, 'YAML') self.databaseEdit.focusInEvent = bind( lambda w, e: QtCore.QTimer.singleShot(0, w.selectAll), self.databaseEdit ) # This is needed to select all text when click on LineEdit self.templateEdit = DragDropQLineEdit( '< Drag & Drop a Jinja2 file or Browse >', self, 'JINJA') self.templateEdit.focusInEvent = bind( lambda w, e: QtCore.QTimer.singleShot(0, w.selectAll), self.templateEdit ) # This is needed to select all text when click on LineEdit self.projectEdit = QtWidgets.QLineEdit(defFolder) self.projectEdit.focusInEvent = bind( lambda w, e: QtCore.QTimer.singleShot(0, w.selectAll), self.projectEdit ) # This is needed to select all text when click on LineEdit self.fileExtEdit = QtWidgets.QLineEdit('.txt') self.fileExtEdit.focusInEvent = bind( lambda w, e: QtCore.QTimer.singleShot(0, w.selectAll), self.fileExtEdit ) # This is needed to select all text when click on LineEdit # Buttons self.databaseBtn = QtWidgets.QPushButton('Browse') self.databaseBtn.clicked.connect( lambda: self._getFilePath(self.databaseEdit)) self.templateBtn = QtWidgets.QPushButton('Browse') self.templateBtn.clicked.connect( lambda: self._getFilePath(self.templateEdit)) self.projectBtn = QtWidgets.QPushButton('Update') self.projectBtn.clicked.connect(self._updateDefFolder) self.cfgenBtn = QtWidgets.QPushButton('Run') self.cfgenBtn.clicked.connect(self.config_gen) # Config generator Layout - make a grid and stitch all together cfgenLayout = QtWidgets.QGridLayout() cfgenLayout.setSpacing(10) cfgenLayout.addWidget(self.databaseLb, 1, 0) cfgenLayout.addWidget(self.databaseEdit, 1, 1) cfgenLayout.addWidget(self.databaseBtn, 1, 2) cfgenLayout.addWidget(self.templateLb, 2, 0) cfgenLayout.addWidget(self.templateEdit, 2, 1) cfgenLayout.addWidget(self.templateBtn, 2, 2) cfgenLayout.addWidget(self.projectLb, 3, 0) cfgenLayout.addWidget(self.projectEdit, 3, 1) cfgenLayout.addWidget(self.projectBtn, 3, 2) cfgenLayout.addWidget(self.fileExtLb, 4, 0) cfgenLayout.addWidget(self.fileExtEdit, 4, 1) cfgenLayout.addWidget(self.cfgenBtn, 4, 2) # Set the default Layout # centralWidget.setLayout(centralLayout) centralWidget.setLayout(cfgenLayout) # Set the Widget self.setCentralWidget(centralWidget) # Set main windows size, position, title and icons self.resize(600, 10) self.center() self.setWindowTitle(__appName__) self.setWindowIcon(QtGui.QIcon(__icon__)) self.show() # Override system excepthook to show error within the GUI sys.excepthook = self._excepthook