def __init__(self, parent=None): "Initialize a image display window" QtGui.QMainWindow.__init__(self, parent) # Setup logging root = logging.getLogger() while len(root.handlers) > 0: root.removeHandler(root.handlers[0]) h = logging.StreamHandler() h.setFormatter(logging.Formatter('%(message)s')) root.addHandler(h) # Build window _logger.info("\rBuilding main window ...") self.ui = Ui_MainWindow() self.ui.setupUi(self) # Setup variables self.lastpath = str(QtCore.QDir.currentPath()) self.loaded_images = [] self.files = [] self.file_index = [] self.color_level = None self.base_level = None self.inifile = '' #'ara_view.ini' self.settings_group = 'ImageViewer' self.imagesize = 0 # Image View self.imageListModel = QtGui.QStandardItemModel(self) self.ui.imageListView.setModel(self.imageListModel) #self.templateListModel = QtGui.QStandardItemModel(self) #self.ui.templateListView.setModel(self.templateListModel) # Empty init self.ui.actionForward.setEnabled(False) self.ui.actionBackward.setEnabled(False) self.setup() self.ui.autopickWidget = AutoPickWidget(self) self.ui.tabWidget.addTab(self.ui.autopickWidget, "AutoPick") self.ui.tabWidget.currentChanged.connect(self.tabValid) # Custom Actions self.ui.dockWidgetAction = self.ui.dockWidget.toggleViewAction() self.ui.whatsThisAction = QtGui.QWhatsThis.createAction(self) icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(":/mini/mini/application_side_list.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ui.dockWidgetAction.setIcon(icon8) self.ui.dockWidgetAction.setToolTip("Show or hide the controls widget") self.ui.dockWidgetAction.setWhatsThis( QtGui.QApplication.translate( "MainWindow", '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">\n<html><head><meta name="qrichtext" content="1" /><style type="text/css">\np, li { white-space: pre-wrap; }\n</style></head><body style=" font-family:\'Lucida Grande\'; font-size:13pt; font-weight:400; font-style:normal;">\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/mini/mini/application_side_list.png" /> Display/Hide the controls widget</p>\n<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This widget can be hidden to increase the number of images that can be shown.</p></body></html>', None, QtGui.QApplication.UnicodeUTF8)) self.ui.toolBar.addAction(self.ui.dockWidgetAction) self.ui.toolBar.addAction(self.ui.whatsThisAction) # Create advanced settings property.setView(self.ui.advancedSettingsTreeView) self.advanced_settings, self.advanced_names = self.ui.advancedSettingsTreeView.model( ).addOptionList(self.advancedSettings()) self.ui.advancedSettingsTreeView.setStyleSheet( 'QTreeView::item[readOnly="true"]{ color: #000000; }') for i in xrange( self.ui.advancedSettingsTreeView.model().rowCount() - 1, 0, -1): if self.ui.advancedSettingsTreeView.model().index( i, 0).internalPointer().isReadOnly( ): # Hide widget items (read only) self.ui.advancedSettingsTreeView.setRowHidden( i, QtCore.QModelIndex(), True) # Help system self.helpDialog = HelpDialog(self) _logger.info("\rLoading settings ...") self.loadSettings()
def __init__(self, parent=None): "Initialize a image display window" QtGui.QMainWindow.__init__(self, parent) # Setup logging root = logging.getLogger() while len(root.handlers) > 0: root.removeHandler(root.handlers[0]) h = logging.StreamHandler() h.setFormatter(logging.Formatter('%(message)s')) root.addHandler(h) # Build window _logger.info("\rBuilding main window ...") self.ui = Ui_MainWindow() self.ui.setupUi(self) # Setup variables self.lastpath = str(QtCore.QDir.currentPath()) self.coordinates_files = [] self.stack_file = "" self.inifile = "" #'ara_view.ini' self.data = None self.header = None self.group_indices = None self.label_cols = [] self.rtsq_cols = [] self.select_col = -1 self.markers = ['s', 'o', '^', '>', 'v', 'd', 'p', 'h', '8', '+', 'x'] self.selectedImage = None # Setup Plotting View self.fig = Figure((6.0, 4.0)) #, dpi=self.ui.dpiSpinBox.value()) self.ui.canvas = FigureCanvas(self.fig) self.ui.canvas.setParent(self.ui.centralwidget) self.axes = self.fig.add_subplot(111) self.ui.centralHLayout.addWidget(self.ui.canvas) self.ui.centralHLayout.setStretchFactor(self.ui.canvas, 4) #self.ui.canvas.mpl_connect('motion_notify_event', self.onHover) self.ui.canvas.mpl_connect('pick_event', self.displayLabel) self.annotation = None # Setup Navigation Tool Bar self.ui.mpl_toolbar = NavigationToolbar(self.ui.canvas, self) self.ui.mpl_toolbar.hide() self.addToolBar(QtCore.Qt.TopToolBarArea, self.ui.mpl_toolbar) if not hasattr(self.ui.mpl_toolbar, 'edit_parameters'): self.ui.toolBar.removeAction(self.ui.actionShow_Options) # Custom Actions self.ui.toggleImageDockAction = self.ui.imageDockWidget.toggleViewAction( ) icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(":/mini/mini/image.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ui.toggleImageDockAction.setIcon(icon8) self.ui.toolBar.insertAction(self.ui.actionShow_Options, self.ui.toggleImageDockAction) self.ui.imageDockWidget.hide() self.ui.toggleImageDockAction.setEnabled(False) action = self.ui.plotDockWidget.toggleViewAction() icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(":/mini/mini/chart_line.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) action.setIcon(icon8) self.ui.toolBar.insertAction(self.ui.actionShow_Options, action) self.ui.toggleAdvancedDockAction = self.ui.advancedDockWidget.toggleViewAction( ) icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(":/mini/mini/cog_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ui.toggleAdvancedDockAction.setIcon(icon8) self.ui.toolBar.insertAction(self.ui.actionShow_Options, self.ui.toggleAdvancedDockAction) self.ui.advancedDockWidget.hide() action = self.ui.fileDockWidget.toggleViewAction() icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(":/mini/mini/folder_explore.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) action.setIcon(icon8) self.ui.toolBar.insertAction(self.ui.actionShow_Options, action) # Create advanced settings property.setView(self.ui.advancedSettingsTreeView) self.advanced_settings, self.advanced_names = self.ui.advancedSettingsTreeView.model( ).addOptionList(self.advancedSettings()) self.ui.advancedSettingsTreeView.setStyleSheet( 'QTreeView::item[readOnly="true"]{ color: #000000; }') for i in xrange( self.ui.advancedSettingsTreeView.model().rowCount() - 1, 0, -1): if self.ui.advancedSettingsTreeView.model().index( i, 0).internalPointer().isReadOnly( ): # Hide widget items (read only) self.ui.advancedSettingsTreeView.setRowHidden( i, QtCore.QModelIndex(), True) # Subset List self.subsetListModel = QtGui.QStandardItemModel() self.ui.subsetListView.setModel(self.subsetListModel) # File List self.fileListModel = QtGui.QStandardItemModel() self.ui.fileTableView.setModel(self.fileListModel) self.fileListModel.setHorizontalHeaderLabels(['file', 'items']) self.connect( self.ui.fileTableView.selectionModel(), QtCore.SIGNAL( "selectionChanged(const QItemSelection &, const QItemSelection &)" ), self.openSelectedFile) # Plot # Create advanced settings #property.setView(self.ui.advancedSettingsTreeView) #self.advanced_settings, self.advanced_names = self.ui.advancedSettingsTreeView.model().addOptionList(self.advancedSettings()) #self.ui.advancedSettingsTreeView.setStyleSheet('QTreeView::item[readOnly="true"]{ color: #000000; }') #for i in xrange(self.ui.advancedSettingsTreeView.model().rowCount()-1, 0, -1): # if self.ui.advancedSettingsTreeView.model().index(i, 0).internalPointer().isReadOnly(): # Hide widget items (read only) # self.ui.advancedSettingsTreeView.setRowHidden(i, QtCore.QModelIndex(), True) # Load the settings _logger.info("\rLoading settings ...") self.loadSettings()