def setupGUI(self, app): ''' :return: ''' # ## Create Main GUI Menu Bar # menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(self.openFileAction) #fileMenu.addAction(self.saveProjectAction) fileMenu.addAction(self.showProjectSettingsDialogAction) fileMenu.addSeparator() exportMenu = fileMenu.addMenu("&Export") exportMenu.addAction(self.exportSampleReportAction) exportMenu.addAction(self.exportSegmentReportAction) exportMenu.addSeparator() self.customReportActions=[] for custom_report in custom_report_classes: a = exportMenu.addAction(custom_report.reportlabel(), lambda: self.exportCustomReport(custom_report)) a.setEnabled(False) self.customReportActions.append(a) self.exportSampleReportAction.enableActionsList.append(a) fileMenu.addSeparator() fileMenu.addAction(self.exitAction) segmentMenu = menubar.addMenu('&Segment') segmentMenu.addAction(self.createSegmentAction) segmentMenu.addAction(self.removeSegmentAction) helpMenu = menubar.addMenu('&Help') helpMenu.addAction(self.aboutAction) self.toolbarFile = self.addToolBar('File') self.toolbarFile.addAction(self.openFileAction) #self.toolbarFile.addAction(self.saveProjectAction) self.toolbarFile.addAction(self.showProjectSettingsDialogAction) self.toolbarFile.addAction(self.exportSampleReportAction) self.toolbarFile.addAction(self.exportSegmentReportAction) self.toolbarsegment = self.addToolBar('Segment') self.toolbarsegment.addAction(self.createSegmentAction) self.toolbarsegment.addAction(self.removeSegmentAction) self.toolbartimelineview = self.addToolBar('Timeline View') self.toolbartimelineview.addAction(self.zoomInTimelineAction) self.toolbartimelineview.addAction(self.zoomOutTimelineAction) self.toolbarsegment = self.addToolBar('Timeline Selection') self.toolbarsegment.addAction(self.gotoSelectedTimePeriodAction) self.toolbarsegment.addAction(self.decreaseSelectionStartPointAction) self.toolbarsegment.addAction(self.increaseSelectionStartPointAction) self.toolbarsegment.addAction(self.backwardSelectionAction) self.toolbarsegment.addAction(self.forwardSelectionAction) self.toolbarsegment.addAction(self.decreaseSelectionEndPointAction) self.toolbarsegment.addAction(self.increaseSelectionEndPointAction) self.toolbarHelp = self.addToolBar('Help') self.toolbarHelp.addAction(self.aboutAction) # ## Create App Dock Area # self._dockarea = DockArea() self.setCentralWidget(self._dockarea) # Enable antialiasing for prettier plots pg.setConfigOptions(antialias=True) # Create Docking Layout def addDock(name, inner_widget=None): ww, wh = DEFAULT_WIN_SIZE dpos, (dw, dh) = DEFAULT_DOCK_PLACEMENT[name] if isinstance(dpos, basestring): self._dockarea.addDock(Dock(name, size=[ww * dw, wh * dh]), dpos) else: self._dockarea.addDock(Dock(name, size=[ww * dw, wh * dh]), dpos[0], self._dockarea.docks[dpos[1]]) if inner_widget: self._dockarea.docks[name].addWidget(inner_widget) from markwrite.gui.selecteddataview import SelectedPointsPlotWidget from markwrite.gui.spatialview import PenDataSpatialPlotWidget from markwrite.gui.timelineplot import PenDataTemporalPlotWidget from markwrite.gui.segmenttree import SegmentInfoDockArea self._segmenttree = SegmentInfoDockArea() addDock(u"Segment Tree", self._segmenttree) self._penDataTimeLineWidget = PenDataTemporalPlotWidget() self._penDataSpatialViewWidget = PenDataSpatialPlotWidget() addDock(u"Timeline", self._penDataTimeLineWidget) addDock(u"Spatial View", self._penDataSpatialViewWidget) self._selectedPenDataViewWidget = SelectedPointsPlotWidget() addDock(u"Selected Data", self._selectedPenDataViewWidget) # ## Do Misc. GUI setup. # self.setWindowIcon(QtGui.QIcon(getIconFilePath('edit&32.png'))) self.statusBar().showMessage('Ready') self.updateAppTitle() self.resize(*DEFAULT_WIN_SIZE)
# -*- coding: utf-8 -*- """ Created on Mon Nov 13 09:16:38 2017 @author: sol """ import os import pyqtgraph import markwrite from pyqtgraph import QtCore, QtGui from markwrite.util import get_resource_folder_path, getIconFilePath icon_folder = os.path.join(get_resource_folder_path(), 'icons') ifiles = os.listdir(icon_folder) for i in ifiles: newi = i[1:] ipath = getIconFilePath(i) print ipath image = QtGui.QImage() image.load(ipath) image.save(getIconFilePath(newi))
def createGuiActions(self): # # File Menu / Toolbar Related Actions # atext = 'Open a supported digitized pen position ' \ 'file format.' aicon = 'folder&32.png' self.openFileAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), '&Open', self) self.openFileAction.setShortcut('Ctrl+O') self.openFileAction.setEnabled(True) self.openFileAction.setStatusTip(atext) self.openFileAction.triggered.connect(self.openFile) #atext = 'Save Current Project.' #aicon = 'save&32.png' #self.saveProjectAction = ContextualStateAction( # QtGui.QIcon(getIconFilePath(aicon)), # 'Save', # self) #self.saveProjectAction.setShortcut('Ctrl+S') #self.saveProjectAction.setEnabled(False) #self.saveProjectAction.setStatusTip(atext) #self.saveProjectAction.triggered.connect(self.saveProject) atext = 'Export Pen Sample Level Report to a File.' aicon = 'sample_report&32.png' self.exportSampleReportAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Sample Report', self) #self.exportSampleReportAction.setShortcut('Ctrl+S') self.exportSampleReportAction.setEnabled(False) self.exportSampleReportAction.setStatusTip(atext) self.exportSampleReportAction.triggered.connect( self.createPenSampleLevelReportFile) atext = 'Export Segment Level Report to a File.' aicon = 'segment_report&32.png' self.exportSegmentReportAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Segment Report', self) #self.exportSampleReportAction.setShortcut('Ctrl+S') self.exportSegmentReportAction.setEnabled(False) self.exportSegmentReportAction.setStatusTip(atext) self.exportSegmentReportAction.triggered.connect( self.createSegmentLevelReportFile) self.exportSampleReportAction.enableActionsList.append(self.exportSegmentReportAction) atext = 'Open the Application Settings Dialog.' aicon = 'settings&32.png' self.showProjectSettingsDialogAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), '&Settings', self) self.showProjectSettingsDialogAction.setShortcut('Alt+S') self.showProjectSettingsDialogAction.setEnabled(True) self.showProjectSettingsDialogAction.setStatusTip(atext) self.showProjectSettingsDialogAction.triggered.connect( self.handleDisplayAppSettingsDialogEvent) atext = 'Close the MarkWrite Application. Any data segmention will be lost!' aicon = 'shut_down&32.png' self.exitAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Exit', self) self.exitAction.setShortcut('Ctrl+Alt+Q') self.exitAction.setEnabled(True) self.exitAction.setStatusTip(atext) self.exitAction.triggered.connect(self.closeEvent) # # Selection Menu / Toolbar Related Actions # atext = 'Create a Segment Using Currently Selected Pen Data.' aicon = 'accept&32.png' self.createSegmentAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Create &New', self) self.createSegmentAction.setShortcut(QtCore.Qt.Key_Return) self.createSegmentAction.setEnabled(False) self.createSegmentAction.setStatusTip(atext) self.createSegmentAction.triggered.connect(self.createSegment) atext = 'Delete the Selected Segment and any of the segments children.' aicon = 'delete&32.png' self.removeSegmentAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), '&Delete', self) self.removeSegmentAction.setShortcut('Ctrl+D') self.removeSegmentAction.setEnabled(False) self.removeSegmentAction.setStatusTip(atext) self.removeSegmentAction.triggered.connect(self.removeSegment) # # Timeline Plot Zoom Related Actions # atext = 'Increase Timeplot Horizontal Magnification 2x' aicon = 'zoom_in&32.png' self.zoomInTimelineAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Zoom In 2x', self) self.zoomInTimelineAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus) self.zoomInTimelineAction.setEnabled(False) self.zoomInTimelineAction.setStatusTip(atext) self.zoomInTimelineAction.triggered.connect(self.zoomInTimeline) atext = 'Decrease Timeplot Horizontal Magnification 2x' aicon = 'zoom_out&32.png' self.zoomOutTimelineAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Zoom Out 2x', self) self.zoomOutTimelineAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Minus) self.zoomOutTimelineAction.setEnabled(False) self.zoomOutTimelineAction.setStatusTip(atext) self.zoomOutTimelineAction.triggered.connect(self.zoomOutTimeline) self.exportSampleReportAction.enableActionsList.append(self.zoomInTimelineAction) self.exportSampleReportAction.enableActionsList.append(self.zoomOutTimelineAction) atext = 'Reposition Views around Selected Time Period' aicon = 'target&32.png' self.gotoSelectedTimePeriodAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Go To Selected Time Period', self) self.gotoSelectedTimePeriodAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Home) self.gotoSelectedTimePeriodAction.setEnabled(False) self.gotoSelectedTimePeriodAction.setStatusTip(atext) self.gotoSelectedTimePeriodAction.triggered.connect(self.gotoSelectTimelinePeriod) atext = "Move selected time period forward, so that it's start time is one sample after the current selection's end time" aicon = 'move_selection_forward&32.png' self.forwardSelectionAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Jump Forward', self) self.forwardSelectionAction.setShortcut(QtCore.Qt.Key_Right) self.forwardSelectionAction.setEnabled(False) self.forwardSelectionAction.setStatusTip(atext) self.forwardSelectionAction.triggered.connect(self.jumpTimeSelectionForward) atext = "Move selected time period backward, so that it's end time is one sample prior to the current selection's start time." aicon = 'move_selection_backward&32.png' self.backwardSelectionAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Jump Backward', self) self.backwardSelectionAction.setShortcut(QtCore.Qt.Key_Left) self.backwardSelectionAction.setEnabled(False) self.backwardSelectionAction.setStatusTip(atext) self.backwardSelectionAction.triggered.connect(self.jumpTimeSelectionBackward) atext = 'Increase Timeline Selection End Time' aicon = 'increase_select_endtime&32.png' self.increaseSelectionEndPointAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Increase Selection End', self) self.increaseSelectionEndPointAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Right) self.increaseSelectionEndPointAction.setEnabled(False) self.increaseSelectionEndPointAction.setStatusTip(atext) self.increaseSelectionEndPointAction.triggered.connect(self.increaseSelectionEndPointTime) atext = 'Decrease Timeline Selection End Time' aicon = 'descrease_select_endtime&32.png' self.decreaseSelectionEndPointAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Decrease Selection End', self) self.decreaseSelectionEndPointAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Left) self.decreaseSelectionEndPointAction.setEnabled(False) self.decreaseSelectionEndPointAction.setStatusTip(atext) self.decreaseSelectionEndPointAction.triggered.connect(self.decreaseSelectionEndPointTime) #====================================== atext = 'Increase Timeline Selection Start Time' aicon = 'increase_select_starttime&32.png' self.increaseSelectionStartPointAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Increase Selection Start', self) self.increaseSelectionStartPointAction.setShortcut(QtCore.Qt.ALT + QtCore.Qt.Key_Right) self.increaseSelectionStartPointAction.setEnabled(False) self.increaseSelectionStartPointAction.setStatusTip(atext) self.increaseSelectionStartPointAction.triggered.connect(self.increaseSelectionStartPointTime) atext = 'Decrease Timeline Selection Start Time' aicon = 'decrease_select_starttime&32.png' self.decreaseSelectionStartPointAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'Decrease Selection Start', self) self.decreaseSelectionStartPointAction.setShortcut(QtCore.Qt.ALT + QtCore.Qt.Key_Left) self.decreaseSelectionStartPointAction.setEnabled(False) self.decreaseSelectionStartPointAction.setStatusTip(atext) self.decreaseSelectionStartPointAction.triggered.connect(self.decreaseSelectionStartPointTime) self.exportSampleReportAction.enableActionsList.append(self.zoomInTimelineAction) self.exportSampleReportAction.enableActionsList.append(self.zoomOutTimelineAction) self.exportSampleReportAction.enableActionsList.append(self.gotoSelectedTimePeriodAction) self.exportSampleReportAction.enableActionsList.append(self.decreaseSelectionEndPointAction) self.exportSampleReportAction.enableActionsList.append(self.increaseSelectionEndPointAction) self.exportSampleReportAction.enableActionsList.append(self.decreaseSelectionStartPointAction) self.exportSampleReportAction.enableActionsList.append(self.increaseSelectionStartPointAction) self.exportSampleReportAction.enableActionsList.append(self.forwardSelectionAction) self.exportSampleReportAction.enableActionsList.append(self.backwardSelectionAction) # # Help Menu / Toolbar Related Actions # atext = 'Displays the MarkWrite About Dialog.' aicon = 'info&32.png' self.aboutAction = ContextualStateAction( QtGui.QIcon(getIconFilePath(aicon)), 'About', self) self.aboutAction.setEnabled(True) self.aboutAction.setStatusTip(atext) self.aboutAction.triggered.connect(self.showAboutDialog)
# -*- coding: utf-8 -*- """ Created on Mon Nov 13 09:16:38 2017 @author: sol """ import os import pyqtgraph import markwrite from pyqtgraph import QtCore, QtGui from markwrite.util import get_resource_folder_path, getIconFilePath icon_folder = os.path.join(get_resource_folder_path(),'icons') ifiles = os.listdir(icon_folder) for i in ifiles: newi = i[1:] ipath = getIconFilePath(i) print ipath image = QtGui.QImage() image.load(ipath) image.save(getIconFilePath(newi))