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))
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...")
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()
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])
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
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
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())))
def _export(self): import os.path files = [] fd = QtGui.QFileDialog() filters = ['IV data (*.iv *.xy *.cur *.fsm)', 'All Files (*)'] filename = str( fd.getSaveFileName(self, caption='Save IV data', directory=os.path.expanduser('~/'), filter=';;'.join(filters), selectedFilter=filters[0])) if filename: plots = self.plots labels = self.legend_labels if len(labels) < len(plots): labels += range(len(labels), len(plots)) for i, curve in enumerate(plots): basename, ext = os.path.splitext(filename) fname = basename + str(labels[i]) + ext with open(fname, 'w') as f: f.write('# {}\n'.format(labels[-1])) x, y = plots[i][0].get_data() for j in range(len(x)): f.write('{:20.6f} {:20.6f}\n'.format(x[j], y[j])) # append on success files.append(fname) return files
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
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
def __init__(self, parent=None): super(GridWidget, self).__init__() color_label = QtGui.QLabel('Line Color') type_label = QtGui.QLabel('Line Type') thickness_label = QtGui.QLabel('Thickness') axes_label = QtGui.QLabel('Axes') lines_label = QtGui.QLabel('Lines') major_grids_check = QtGui.QCheckBox('Major Grids') minor_grids_check = QtGui.QCheckBox('Minor Grids') major_color = QtGui.QPushButton('') minor_color = QtGui.QPushButton('') minor_linetype_combo = self.new_linetype_combo() major_linetype_combo = self.new_linetype_combo()
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)
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)
def __init__(self, parent=None): super(CLEEDConsoleWidget, self).__init__(parent) layout = QtGui.QVBoxLayout(self) edit_layout = QtGui.QVBoxLayout() button_layout = QtGui.QHBoxLayout() self.ipyConsole = QIPythonWidget(customBanner= "*** Welcome to the CLEED embedded IPython console ***\n\n") self.tabWidget = QtGui.QTabWidget() layout.addWidget(self.tabWidget) from highlighter import PythonHighlighter self.save_button = QtGui.QPushButton('Save') self.load_button = QtGui.QPushButton('Load') self.run_button = QtGui.QPushButton('Run...') button_layout.addWidget(self.load_button) button_layout.addWidget(self.save_button) button_layout.addWidget(self.run_button) self.scriptEdit = QtGui.QPlainTextEdit() self.highlighter = PythonHighlighter(self.scriptEdit.document()) edit_layout.addWidget(self.scriptEdit) edit_layout.addLayout(button_layout) edit_widget = QtGui.QWidget() edit_widget.setLayout(edit_layout) self.tabWidget.addTab(self.ipyConsole, 'Console') self.tabWidget.addTab(edit_widget, 'Editor') self.ipyConsole.pushVariables( {"app": self.parent(), "console": self.ipyConsole }) self.ipyConsole.printText("The application handle variable 'app' " "is available. " "Use the 'whos' command for information on " "available variables.") self.setToolTip("CLEED scripting console. \n\n" "Note: type 'whos' for list of variables " "or help($var) for help")
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)
def _save(self): import os.path fd = QtGui.QFileDialog() filters = [ 'Images (*.png *.jpg)', 'Vector Graphics (*.ps *.svg)', 'Portable Document Format (*.pdf)', 'All Files (*)' ] filename = str( fd.getSaveFileName(self, caption='Save graph', directory=os.path.expanduser('~/'), filter=';;'.join(filters), selectedFilter=filters[0])) if filename: return self.save(filename)
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)
def __init__(self, parent=None, title={'text': ''}): QtGui.QWidget.__init__(self, parent) self.canvas = MplCanvas() self.canvas.fig.set_facecolor('white') self.vbl = QtGui.QVBoxLayout() self.vbl.addWidget(self.canvas) self.setLayout(self.vbl) self._init_context_menu() self.canvas.setFocusPolicy(QtCore.Qt.ClickFocus) self.canvas.setFocus() self._plots = [] self._active_obj = None self._active_dataset = None self._old_bbox = None # initialise selection box self._selection_box = mpl.patches.Rectangle((0, 0), 1, 1) for attr in self.HIGHLIGHTER: try: eval("self._selection_box.set_{0}(self.HIGHLIGHTER['{0}'])" "".format(attr)) except: pass self._selection_box.set_visible(False) self.canvas.ax.add_patch(self._selection_box) # initialise title try: title_text = title.pop('text') except KeyError: title_text = '' try: title_bbox = title.pop('boxstyle') except: title_bbox = dict(alpha=0., fc='gray', boxstyle='square,pad=0.1') self.title(title_text, bbox=title_bbox, **title) # initialise connections self.canvas.mpl_connect('button_press_event', self.mousePressEvent) self.canvas.mpl_connect('button_release_event', self.mouseReleaseEvent) self.canvas.mpl_connect('motion_notify_event', self.mouseMoveEvent) self.canvas.mpl_connect('pick_event', self._on_pick) self.canvas.mpl_connect('key_press_event', self.keyPressEvent) self.canvas.mpl_connect('key_release_event', self.keyReleaseEvent)
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_()
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())
def save(self, filename, *args): '''save an image of the model''' self.pymol.cmd.save(filename, *args) def _show_cell(self, show): if show: self.pymol.cmd.do("show cell, {}".format(self.model_name)) else: self.pymol.cmd.do("hide cell, {}".format(self.model_name)) # You don't need anything below this class PyMolWidgetDemo(QtGui.QMainWindow): '''demo class for showing PyMolWidget class''' def __init__(self): QtGui.QMainWindow.__init__(self) usr = os.path.expanduser('~/') widget = PymolQtWidget(self, False, os.path.join( usr, r"Dropbox\Structures\spinel111.xyz"), unit_cell=True) self.setCentralWidget(widget) if __name__ == '__main__': app = QtGui.QApplication(['PyMol Widget Demo']) window = PyMolWidgetDemo() window.show() app.exec_()
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")
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")
def __init__(self, parent=None, legend=None): super(MplLegendDialog, self).__init__(parent) self.setWindowTitle('Edit Legend') self.setWindowIcon(QtGui.QIcon(':/list.png'))
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 = []
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())))
def __init__(self, parent=None): super(AxisScaleWidget, self).__init__(parent) axis_from_spinbox = QtGui.QDoubleSpinBox() axis_from_spinbox.setToolTip('Specifies the axis maximum') axis_from_spinbox.setSingleStep(0.1) axis_to_spinbox = QtGui.QDoubleSpinBox() axis_to_spinbox.setToolTip('Specifies the axis maximum') axis_to_spinbox.setSingleStep(0.1) type_combobox = QtGui.QComboBox() inverted_checkbox = QtGui.QCheckBox('Inverted') step_radio = QtGui.QRadioButton('Step') major_ticks_radio = QtGui.QRadioButton('Step') minor_ticks_label = QtGui.QLabel('Minor Ticks') minor_ticks_combo = QtGui.QComboBox() minor_ticks_combo.setEditable(True) for val in (0, 1, 4, 9, 14, 19): minor_ticks_combo.addItem(str(val)) axis_break_checkbox = QtGui.QCheckBox('Show Axis Break') axis_break_decoration_checkbox = QtGui.QCheckBox('Draw Break Decoration') axis_break_from_spinbox = QtGui.QDoubleSpinBox() axis_break_to_spinbox = QtGui.QDoubleSpinBox()
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)
def main(): app = QtGui.QApplication([]) widget = CLEEDConsoleWidget() widget.show() app.exec_()
class ExperimentalIVCurveItem(IVCurveItem): 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") class TheoreticalIVCurveItem(IVCurveItem): 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()) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) explorer = ProjectTreeWidget() project = ProjectItem() #pro2 = ProjectItem() explorer.addTopLevelItem(project) for child in project.getChildren(project): child.setExpanded(True) #explorer.addTopLevelItem(pro2) explorer.show() app.exec_()