Exemplo n.º 1
0
    def __init__(self, parent=None, iv_pair=None):
        super(IVInfoItem, self).__init__(parent)
        self.setIcon(0, QtGui.QIcon(":/index.svg"))
        self.setText(0, '(h, k)')

        self.expt = ExperimentalIVCurveItem()
        self.theory = TheoreticalIVCurveItem()

        self.id = QtGui.QTreeWidgetItem()
        self.id.setText(0, 'ID')
        self.id.setIcon(0, QtGui.QIcon(":/id.svg"))

        self.weight = QtGui.QTreeWidgetItem()
        self.weight.setText(0, 'Weight')
        self.weight.setIcon(0, QtGui.QIcon(":/eject.svg"))

        self.rfactor = QtGui.QTreeWidgetItem()
        self.rfactor.setText(0, 'Rfactor')
        self.rfactor.setIcon(0, QtGui.QIcon(':/rf.svg'))

        self.addChildren(
            [self.expt, self.theory, self.id, self.weight, self.rfactor])

        try:
            if isinstance(iv_pair, IVCurvePair):
                self.load(iv_pair)
        except:
            pass

        def load(self, iv_pair):
            pass
Exemplo n.º 2
0
    def __init__(self, parent=None, path=None, ivs=[]):
        super(IVGroupItem, self).__init__(parent)
        self.setIcon(0, QtGui.QIcon(":/list.svg"))
        self.setText(0, 'IV_Group')

        # initialise actions
        self.iv_pairs = [IVInfoItem()]

        for iv in self.iv_pairs:
            self.addChild(iv)

        # initialise other aspects
        self.theta = QtGui.QTreeWidgetItem()
        self.theta.setText(0, 'Theta')
        self.theta.setIcon(0, QtGui.QIcon(':/theta.svg'))

        self.phi = QtGui.QTreeWidgetItem()
        self.phi.setText(0, 'Phi')
        self.phi.setIcon(0, QtGui.QIcon(':/phi.svg'))

        self.enabled = QtGui.QTreeWidgetItem()
        self.enabled.setText(0, 'Enabled')
        self.enabled.setIcon(0, QtGui.QIcon(':/check.svg'))

        self.rfactor = QtGui.QTreeWidgetItem()
        self.rfactor.setText(0, 'Rfactor')
        self.rfactor.setIcon(0, QtGui.QIcon(':/rf.svg'))

        self.addChildren([self.theta, self.phi, self.enabled, self.rfactor])
Exemplo n.º 3
0
 def printer(self):
     '''send document to printer'''
     printer = QtGui.QPrinter()
     document  = QtGui.QTextDocument(self.userFriendlyCurrentFile())
     document.setHtml(self.renderHtml())
     document.print_(printer)
     dialog = QtGui.QPrintDialog(printer)
     dialog.setModal(True)
     dialog.setWindowTitle("Print %s" % self.userFriendlyCurrentFile())
     dialog.setWindowIcon(QtGui.QIcon(":print.svg"))
     pdialog = QtGui.QPrintPreviewDialog(printer)
     pdialog.setWindowIcon(QtGui.QIcon(":print.svg"))
     pdialog.setWindowFlags(QtCore.Qt.Window)
     pdialog.exec_()
Exemplo n.º 4
0
    def __init__(self, parent=None, input=None):
        super(InputItem, self).__init__(parent)
        self.setIcon(0, QtGui.QIcon(":/minus.svg"))
        self.setText(0, 'Surface_Model')
        self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)

        self.model = None
Exemplo n.º 5
0
 def __init__(self, parent=None, axis=None):
     super(MplFigureDialog, self).__init__(parent)
     
     axis = mpl.axis.Axis()
     
     if isinstance(axis, mpl.axis.XAxis):
         ax = 'X-Axis'
     elif isinstance(axis, mpl.axis.YAxis):
         ax = 'Y-Axis'
     else:
         ax = 'Axis'
     self.setWindowTitle('Edit {}'.format(ax))
     self.setWindowIcon(QtGui.QIcon(':/graph_dash.png'))
     
     
     self.text = axis
 
     self.text_edit.textChanged.connect(lambda x: self.callback(self._set_text(x)))
     self.color_combo.currentIndexChanged.connect(lambda x: 
         self.callback(self.text.set_color(str(self.color_combo.itemText(x)))))
     self.font_combo.currentIndexChanged.connect(lambda x: 
         self.callback(self.text.set_family(str(self.font_combo.itemText(x)))))
     self.size_spin_box.valueChanged.connect(lambda x: 
                                     self.callback(self.text.set_size(x)))
     self.alpha_spin_box.valueChanged.connect(lambda x:
                                     self.callback(self.text.set_alpha(x)))
     
     self.bold_check.toggled.connect(lambda x:
             self.callback(self.text.set_weight('bold' if x else 'normal')))
     self.italics_check.toggled.connect(lambda x:
             self.callback(self.text.set_style('italic' if x else 'normal')))
     self.underline_check.toggled.connect(lambda x:
             self.callback(self.text.set_text('\\underline{%s}'
                                              % self.text.get_text() if x 
                                              else self.text.get_text())))
Exemplo n.º 6
0
    def __init__(self, parent=None, bulk=None):
        super(BulkItem, self).__init__(parent)
        self.setIcon(0, QtGui.QIcon(":/layers.svg"))
        self.setText(0, "Bulk_Model")
        self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)

        self.model = None
Exemplo n.º 7
0
 def _init_context_menu(self):
     MatplotlibWidget._init_context_menu(self)
     self._graph_menu.addSeparator()
     self._graph_menu.addAction(
         QtGui.QAction(QtGui.QIcon(":/graph_smooth.svg"),
                       "S&mooth...",
                       self,
                       triggered=self._smooth))
Exemplo n.º 8
0
 def _createActions(self):
     self.generateControlAction = QtGui.QAction(
         QtGui.QIcon(":/document_edit_24x32.png"),
         "&Edit ctr file...",
         self,
         triggered=self.viewControl,
         shortcut='Ctrl+E')
     self.generateControlAction.setToolTip("Edit LEED control file...")
Exemplo n.º 9
0
 def __init__(self, parent=None, figure=None):
     super(MplFigureDialog, self).__init__(parent)
     
     self.setWindowTitle('Edit plot')
     self.setWindowIcon(QtGui.QIcon(':/graph_dash.png'))
     
     self.bkgnd_color_label = QtGui.QLabel("Background color:")
     self.bkgnd_color_button = ColorButton()
Exemplo n.º 10
0
    def _init_context_menu(self):
        import res_rc

        self._graph_menu = QtGui.QMenu()

        self._graph_menu.addAction(
            QtGui.QAction(QtGui.QIcon(":/arrow_right.svg"),
                          "&Export graph",
                          self,
                          triggered=self._export,
                          shortcut='Ctrl+Shift+E'))
        self._graph_menu.addAction(
            QtGui.QAction(QtGui.QIcon(":/save.svg"),
                          "&Save data",
                          self,
                          triggered=self._save,
                          shortcut='Ctrl+S'))

        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._popupMenu)
Exemplo n.º 11
0
 def _populate_colors(self):
     import matplotlib as mpl
     self.colors = dict()
     i = 0
     for name, hex_code in mpl.colors.cnames.iteritems():
         rgb = [channel * 255  for channel in mpl.colors.hex2color(hex_code)]
         pixmap = QtGui.QPixmap(100,100)
         pixmap.fill(QtGui.QColor(*rgb))
         self.color_combo.addItem(name)
         self.color_combo.setItemIcon(i, QtGui.QIcon(pixmap))
         self.colors[name] = i
         i += 1
Exemplo n.º 12
0
    def __init__(self, parent=None, path=None):
        super(ProjectItem, self).__init__(parent)
        self.setProjectPath(path)
        self.setIcon(0, QtGui.QIcon(":/folder_fill.svg"))
        self.name = "New_Project{}".format(len(self.projects))
        self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)
        #self.setProjectPath(path)

        self.models = []

        #add children
        self._init_children()

        ProjectItem.projects.append(self)
Exemplo n.º 13
0
    def __init__(self, parent=None, path=None):
        super(ModelItem, self).__init__(parent)
        self.setIcon(0, QtGui.QIcon(":/blocks.svg"))
        self.setText(0, "New_Model")
        self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)
        #self.setModelName(path)

        # init items
        self.surface = InputItem()
        self.bulk = BulkItem()
        self.iv_groups = IVGroupItem()

        self.addChild(self.surface)
        self.addChild(self.bulk)

        self.addChild(self.iv_groups)
Exemplo n.º 14
0
    def __init__(self, parent=None):
        super(SmoothDialog, self).__init__(parent)

        self.setWindowTitle('Smooth IV')
        self.setWindowIcon(QtGui.QIcon(':/graph_smooth.svg'))

        layout = QtGui.QVBoxLayout(self)

        # combo box for multiple plots
        layout.addWidget(QtGui.QLabel('Data set:'))
        self.combo = QtGui.QComboBox()
        layout.addWidget(self.combo)
        for item in self.parent().legend_labels:
            self.combo.addItem(item)

        # OK and Cancel buttons
        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | 
                                         QtGui.QDialogButtonBox.Cancel,
                                         QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)
Exemplo n.º 15
0
 def __init__(self, parent=None, path=None):
     super(TheoreticalIVCurveItem, self).__init__(parent)
     self.setIcon(0, QtGui.QIcon(":/iv_theory.svg"))
     self.setText(0, "Theoretical IV")
     self.setFlags(self.flags())
Exemplo n.º 16
0
 def __init__(self, parent=None, path=None):
     super(ExperimentalIVCurveItem, self).__init__(parent)
     self.setIcon(0, QtGui.QIcon(":/iv_expt.svg"))
     self.setText(0, "Experimental IV")
Exemplo n.º 17
0
 def __init__(self, parent=None, path=None):
     super(IVCurveItem, self).__init__(parent)
     self.setIcon(0, QtGui.QIcon(":/graph_dash.svg"))
     self.setText(0, "IV curve")
Exemplo n.º 18
0
    def __init__(self, parent=None):
        super(ProjectTreeWidget, self).__init__(parent)

        self.setColumnCount(1)
        self.setHeaderLabel("Projects")

        # explorer actions
        self.renameAction = QtGui.QAction(QtGui.QIcon(":/tag_stroke.svg"),
                                          "&Rename",
                                          self,
                                          triggered=self.rename)
        self.renameAction.setToolTip("Rename project...")

        self.refreshAction = QtGui.QAction(QtGui.QIcon(":/spin.svg"),
                                           "Refresh",
                                           self,
                                           triggered=self.refresh,
                                           shortcut="F5")
        self.refreshAction.setToolTip("Refresh")

        self.newProjectAction = QtGui.QAction(
            QtGui.QIcon(":/document_alt_stroke.svg"),
            "&New Project",
            self,
            triggered=self.newProject)
        self.newProjectAction.setToolTip("Create new project...")

        self.importProjectAction = QtGui.QAction(QtGui.QIcon(":/import.svg"),
                                                 "&Import Project",
                                                 self,
                                                 triggered=self.importProject)
        self.importProjectAction.setToolTip("Import existing project...")

        self.newModelAction = QtGui.QAction(QtGui.QIcon(":/atoms.svg"),
                                            "&New Model",
                                            self,
                                            triggered=self.newModel)
        self.newModelAction.setToolTip("Create new model...")

        self.importModelAction = QtGui.QAction(QtGui.QIcon(":/import.svg"),
                                               "&Import Model",
                                               self,
                                               triggered=self.importModel)
        self.importModelAction.setToolTip("Import existing model...")

        self.removeProjectAction = QtGui.QAction(QtGui.QIcon(":/x.svg"),
                                                 "&Remove Project",
                                                 self,
                                                 triggered=self.removeProject,
                                                 shortcut='Del')
        self.newProjectAction.setToolTip("Remove project")

        self.removeProjectAction = QtGui.QAction(
            QtGui.QIcon(":/folder_fill.svg"),
            "Open Project &Location",
            self,
            triggered=self.removeProject)
        self.newProjectAction.setToolTip(
            "Opens project location in file explorer")

        # explorer menus
        self.explorerDefaultMenu = QtGui.QMenu()
        self.explorerDefaultMenu.addAction(self.newProjectAction)
        self.explorerDefaultMenu.addAction(self.importProjectAction)
        self.explorerDefaultMenu.addSeparator()
        #self.explorerDefaultMenu.addAction(self.copyAction)
        #self.explorerDefaultMenu.addAction(self.cutAction)
        #self.explorerDefaultMenu.addAction(self.pasteAction)
        self.explorerDefaultMenu.addAction(self.renameAction)
        self.explorerDefaultMenu.addSeparator()
        self.explorerDefaultMenu.addAction(self.refreshAction)

        self.explorerProjectMenu = QtGui.QMenu()
        self.explorerProjectMenu.addAction(self.newModelAction)
        self.explorerProjectMenu.addAction(self.importModelAction)
        #self.explorerProjectMenu.addSeparator()
        #self.explorerProjectMenu.addAction(self.copyAction)
        #self.explorerProjectMenu.addAction(self.cutAction)
        #self.explorerProjectMenu.addAction(self.pasteAction)
        self.explorerProjectMenu.addAction(self.renameAction)
        self.explorerProjectMenu.addAction(self.removeProjectAction)
        self.explorerProjectMenu.addSeparator()
        self.explorerProjectMenu.addAction(self.refreshAction)

        self.explorerFileMenu = QtGui.QMenu()
        #self.explorerFileMenu.addAction(self.newAction)
        self.explorerFileMenu.addAction(self.refreshAction)

        #setup signals and slots
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.explorerPopupMenu)

        #recent projects
        self.recent_projects = []
Exemplo n.º 19
0
    def __init__(self, parent=None, legend=None):
        super(MplLegendDialog, self).__init__(parent)

        self.setWindowTitle('Edit Legend')
        self.setWindowIcon(QtGui.QIcon(':/list.png'))
Exemplo n.º 20
0
    def __init__(self, parent=None, text=None):
        super(MplLabelDialog, self).__init__(parent)
        
        self.setWindowTitle('Edit text')
        self.setWindowIcon(QtGui.QIcon(':/font_32x32.png'))
        
        layout = QtGui.QVBoxLayout(self)
        
        #self.tab_widget = QtGui.QTabWidget()
        #self.tab_widget.addTab(self, 'test')
        #
        self.font_label = QtGui.QLabel('Font Family:')
        self.size_label = QtGui.QLabel('Size:')
        self.text_label = QtGui.QLabel('Label:')
        self.color_label = QtGui.QLabel('Color:')
        self.alpha_label = QtGui.QLabel('Alpha:')
        self.fill_color_label = QtGui.QLabel("Background color:")
        self.fill_alpha_label = QtGui.QLabel("Background alpha:")
        
        self.font_combo = QtGui.QComboBox()
        self.color_combo = QtGui.QComboBox()
        self.text_edit = QtGui.QLineEdit()
        self.size_spin_box = QtGui.QSpinBox()
        self.alpha_spin_box = QtGui.QDoubleSpinBox()
        self.fill_alpha_spin_box = QtGui.QDoubleSpinBox()
        
        try:
            from matplotlib.backends.qt4_editor.formlayout import ColorButton
            self.color_button = ColorButton()
            self.color_button.colorChanged.connect(lambda x:
                self.callback(self.text.set_color(self.color_button.color)))
        except:
            pass
        
        self.bold_check = QtGui.QPushButton('B')
        self.italics_check = QtGui.QPushButton('I')
        self.underline_check = QtGui.QPushButton('U')
        self.underline_check.setVisible(False)  # not yet implemented
        
        font = QtGui.QFont()
        font.setWeight(600)
        self.bold_check.setFont(font)
        self.bold_check.setCheckable(True)
        self.bold_check.setMinimumWidth(25)
        self.bold_check.setSizePolicy(QtGui.QSizePolicy.Minimum, 
                                      QtGui.QSizePolicy.Preferred)
        
        font = QtGui.QFont()
        font.setItalic(True)
        self.italics_check.setFont(font)
        self.italics_check.setCheckable(True)
        self.italics_check.setMinimumWidth(25)
        self.italics_check.setSizePolicy(QtGui.QSizePolicy.Minimum, 
                                         QtGui.QSizePolicy.Preferred)
        
        
        font = QtGui.QFont()
        font.setUnderline(True)
        self.underline_check.setFont(font)
        self.underline_check.setCheckable(True)
        self.underline_check.setMinimumWidth(25)
        self.underline_check.setSizePolicy(QtGui.QSizePolicy.Minimum, 
                                           QtGui.QSizePolicy.Preferred)
        
        self.alpha_spin_box.setMinimum(0.)
        self.alpha_spin_box.setMaximum(1.)
        self.alpha_spin_box.setSingleStep(0.1)
        
        self.fill_alpha_spin_box.setMinimum(0.)
        self.fill_alpha_spin_box.setMaximum(1.)
        self.fill_alpha_spin_box.setSingleStep(0.1)
        
        self.size_spin_box.setMinimum(1)
        self.size_spin_box.setMaximum(200)
        self.size_spin_box.setSingleStep(1)

        self._populate_fonts()
        self._populate_colors()
        
        spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, 
                                   QtGui.QSizePolicy.Minimum)
        layout.addWidget(self.font_label)
        font_layout = QtGui.QHBoxLayout()
        font_layout.addWidget(self.font_combo)
        font_layout.addWidget(self.bold_check)
        font_layout.addWidget(self.italics_check)
        font_layout.addWidget(self.underline_check)
        font_layout.addItem(spacer)
        layout.addLayout(font_layout)
        
        layout.addWidget(self.size_label)
        layout.addWidget(self.size_spin_box)
        
        layout.addWidget(self.color_label)
        color_layout = QtGui.QHBoxLayout()
        color_layout.addWidget(self.color_combo)
        if hasattr(self, 'color_button'):
            color_layout.addWidget(self.color_button)
        layout.addLayout(color_layout)
        
        layout.addWidget(self.alpha_label)
        layout.addWidget(self.alpha_spin_box)
        
        #layout.addWidget(self.fill_alpha_label)
        #layout.addWidget(self.fill_alpha_spin_box)
        
        layout.addWidget(self.text_label)
        layout.addWidget(self.text_edit)    
        
        #self.addLayout(layout)
        
        self.text = text
        
        try:
            import matplotlib as mpl
        
            self.size_spin_box.setValue(text.get_size() or 12)
            self.text_edit.setText(text.get_text() if text.get_text() != '____' else '')
            self.font_combo.setCurrentIndex(self.families.index(text.get_family()[0]))
            self.font_combo.update()
            color = text.get_color()
            try:
                self.font_combo.setCurrentIndex(self.colors[color])
            except KeyError:
                from matplotlib.colors import ColorConverter, rgb2hex, cnames
                code = rgb2hex(ColorConverter.colors[color])
                
                for name in cnames:
                    if cnames[name] == code:
                        color = name
                
                try:        
                    self.font_combo.setCurrentIndex(self.colors[color])
                except KeyError:
                    self.font_combo.setCurrentIndex(self.colors['black'])
            finally:
                pass
            
            try:
                self.bold_check.setChecked((text.get_weight() >= 600))
            except:
                pass
            
            try: 
                self.italics_check.setChecked(text.get_style() == 'italic')
            except:
                pass
            
        except ImportWarning:
            pass
        
        self.text_edit.textChanged.connect(lambda x: self.callback(self._set_text(x)))
        self.color_combo.currentIndexChanged.connect(lambda x: 
            self.callback(self.text.set_color(str(self.color_combo.itemText(x)))))
        self.font_combo.currentIndexChanged.connect(lambda x: 
            self.callback(self.text.set_family(str(self.font_combo.itemText(x)))))
        self.size_spin_box.valueChanged.connect(lambda x: 
                                        self.callback(self.text.set_size(x)))
        self.alpha_spin_box.valueChanged.connect(lambda x:
                                        self.callback(self.text.set_alpha(x)))
        
        self.bold_check.toggled.connect(lambda x:
                self.callback(self.text.set_weight('bold' if x else 'normal')))
        self.italics_check.toggled.connect(lambda x:
                self.callback(self.text.set_style('italic' if x else 'normal')))
        self.underline_check.toggled.connect(lambda x:
                self.callback(self.text.set_text('\\underline{%s}'
                                                 % self.text.get_text() if x 
                                                 else self.text.get_text())))
Exemplo n.º 21
0
 def __init__(self, parent=None, path=None):
     #super(InputItem, self).__init__(parent)
     self.setIcon(0, QtGui.QIcon(":/wrench.svg"))
     self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)