示例#1
0
 def flags(self, index):
     return Qt.ItemFlags(QAbstractTableModel.flags(self, index) | Qt.ItemIsDropEnabled)
 def flags(self, index):
     if not index.isValid():
         return Qt.ItemIsEnabled
     return Qt.ItemFlags(
         QAbstractListModel.flags(self, index) | Qt.ItemIsUserCheckable)
示例#3
0
	def __init__(self, options):
		
		self.path="tomograms/"
		QtGui.QWidget.__init__(self,None)

		self.win_size=[1000,680]
		self.setMinimumSize(self.win_size[0], self.win_size[1])
		
		# This object is itself a widget we need to set up
		self.gbl = QtGui.QGridLayout(self)
		self.gbl.setMargin(8)
		self.gbl.setSpacing(6)
		self.gbl.setColumnStretch(0,4)
		self.gbl.setColumnStretch(1,1)
		#self.gbl.setColumnStretch(2,1)
		self.gbl.setRowStretch(0,1)

		# Micrograph list
		self.imglst=QtGui.QTableWidget(1, 3, self)
		self.imglst.verticalHeader().hide()
		
		self.gbl.addWidget(self.imglst,0,0,10,1)
		#self.imglst.setColumnWidth(0,50)
		self.imglst.setColumnWidth(1,200)
		self.imglst_srtby=0
		hdr=self.imglst.horizontalHeader()
		self.imglst.cellClicked[int, int].connect(self.select_folder)
		hdr.sectionPressed[int].connect(self.sortlst)
		
		self.dp_folder=QtGui.QComboBox()
		self.dp_folder.setToolTip("Folder suffix")
		self.gbl.addWidget(self.dp_folder, 0,1,1,1)
		sfxlst=["spt", "sptsgd"]
		for i in sfxlst:
			self.dp_folder.addItem(i)
		self.dp_folder.currentIndexChanged[int].connect(self.set_sfx)

		self.wg_thumbnail=EMScene3D()#parent=self)
		#self.wg_thumbnail.set_scale(1)
		self.wg_thumbnail_width=old_div(self.size().width(),4)*.9
		self.wg_thumbnail.resize(self.wg_thumbnail_width,self.wg_thumbnail_width)
		#print self.wg_thumbnail_width
		self.wg_thumbnail.setMinimumHeight(330)
		self.wg_thumbnail.setMinimumWidth(330)
		self.gbl.addWidget(self.wg_thumbnail, 0,1,2,2)

		self.wg_thumbnail.newnode=None

		self.bt_showbs=QtGui.QPushButton("ShowBrowser")
		self.bt_showbs.setToolTip("Show Browser")
		self.gbl.addWidget(self.bt_showbs, 2,1,1,2)
		self.bt_showbs.clicked[bool].connect(self.show_browser)

		self.bt_plotParms=QtGui.QPushButton("PlotParams")
		self.bt_plotParms.setToolTip("Examine particle orientations")
		self.gbl.addWidget(self.bt_plotParms, 3,1,1,2)
		self.bt_plotParms.clicked[bool].connect(self.plot_params)

		self.paramplot = EMPlot2DWidget()
		
		self.bt_plotFSC=QtGui.QPushButton("PlotFSCs")
		self.bt_plotFSC.setToolTip("Examine tightly masked FSCs from this SPT refinement")
		self.gbl.addWidget(self.bt_plotFSC, 4,1,1,2)
		self.bt_plotFSC.clicked[bool].connect(self.plot_fscs)

		self.fscplot = EMPlot2DWidget()

		self.setspanel=QtGui.QListWidget(self)
		self.gbl.addWidget(self.setspanel, 5,1,5,2)
		self.itemflags=	Qt.ItemFlags(Qt.ItemIsEditable)|Qt.ItemFlags(Qt.ItemIsSelectable)|Qt.ItemFlags(Qt.ItemIsEnabled)|Qt.ItemFlags(Qt.ItemIsUserCheckable)
		
		#self.wg_notes=QtGui.QTextEdit(self)
		#self.gbl.addWidget(self.wg_notes, 10,1,1,2)
				
		self.setspanel.itemChanged[QtGui.QListWidgetItem].connect(self.click_set)
		#QtCore.QObject.connect(self.wg_notes,QtCore.SIGNAL("textChanged()"),self.noteupdate)
		
		#self.wg_plot2d=EMPlot2DWidget()
		
		self.update_files()
		self.browser=SPTBrowserWidget(withmodal=False,multiselect=False)
示例#4
0
 def flags(self, index):
     if not index.isValid():
         return Qt.ItemIsEnabled
     return Qt.ItemFlags(
         QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
示例#5
0
 def flags(self, index):
     if self.enabled[index.row()]:
         return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     else:
         return Qt.ItemFlags()
示例#6
0
 def __init__(self, text):
     QListWidgetItem.__init__(self, text)
     self.setFlags(self.flags() | Qt.ItemFlags(Qt.ItemIsEditable))
示例#7
0
    def __init__(self, options):

        self.path = "tomograms/"
        QtGui.QWidget.__init__(self, None)

        self.win_size = [1000, 680]
        self.setMinimumSize(self.win_size[0], self.win_size[1])

        # This object is itself a widget we need to set up
        self.gbl = QtGui.QGridLayout(self)
        self.gbl.setMargin(8)
        self.gbl.setSpacing(6)
        self.gbl.setColumnStretch(0, 4)
        self.gbl.setColumnStretch(1, 1)
        self.gbl.setColumnStretch(2, 1)
        self.gbl.setRowStretch(0, 1)

        # Micrograph list
        self.imglst = QtGui.QTableWidget(1, 3, self)
        self.imglst.verticalHeader().hide()

        self.gbl.addWidget(self.imglst, 0, 0, 11, 1)
        self.imglst.setColumnWidth(0, 50)
        self.imglst.setColumnWidth(1, 200)
        self.imglst_srtby = 0
        hdr = self.imglst.horizontalHeader()
        QtCore.QObject.connect(self.imglst,
                               QtCore.SIGNAL("cellClicked(int,int)"),
                               self.selimg)
        QtCore.QObject.connect(hdr, QtCore.SIGNAL("sectionPressed(int)"),
                               self.sortlst)

        self.wg_thumbnail = EMImage2DWidget(parent=self)
        self.wg_thumbnail.set_scale(1)
        self.wg_thumbnail_width = self.size().width() / 3 * .9
        self.wg_thumbnail.resize(self.wg_thumbnail_width,
                                 self.wg_thumbnail_width)
        #print self.wg_thumbnail_width
        self.wg_thumbnail.setMinimumHeight(330)
        self.gbl.addWidget(self.wg_thumbnail, 0, 1, 3, 2)

        self.bt_show2d = QtGui.QPushButton("Show2D")
        self.bt_show2d.setToolTip("Show 2D images")
        self.gbl.addWidget(self.bt_show2d, 4, 1, 1, 2)

        self.bt_runboxer = QtGui.QPushButton("Boxer")
        self.bt_runboxer.setToolTip("Run spt_boxer")
        self.gbl.addWidget(self.bt_runboxer, 5, 1)

        self.bt_refresh = QtGui.QPushButton("Refresh")
        self.bt_refresh.setToolTip("Refresh")
        self.gbl.addWidget(self.bt_refresh, 5, 2)

        self.bt_showtlts = QtGui.QPushButton("ShowTilts")
        self.bt_showtlts.setToolTip("Show raw tilt series")
        self.gbl.addWidget(self.bt_showtlts, 6, 1)

        self.bt_plottpm = QtGui.QPushButton("TiltParams")
        self.bt_plottpm.setToolTip("Plot tilt parameters")
        self.gbl.addWidget(self.bt_plottpm, 6, 2)

        self.bt_plotloss = QtGui.QPushButton("PlotLoss")
        self.bt_plotloss.setToolTip("Plot alignment loss")
        self.gbl.addWidget(self.bt_plotloss, 7, 1)

        self.bt_plotctf = QtGui.QPushButton("PlotCtf")
        self.bt_plotctf.setToolTip("Plot CTF estimation")
        self.gbl.addWidget(self.bt_plotctf, 7, 2)

        QtCore.QObject.connect(self.bt_show2d, QtCore.SIGNAL("clicked(bool)"),
                               self.show2d)
        QtCore.QObject.connect(self.bt_runboxer,
                               QtCore.SIGNAL("clicked(bool)"), self.runboxer)
        QtCore.QObject.connect(self.bt_plotloss,
                               QtCore.SIGNAL("clicked(bool)"), self.plot_loss)
        QtCore.QObject.connect(self.bt_plottpm, QtCore.SIGNAL("clicked(bool)"),
                               self.plot_tltparams)
        QtCore.QObject.connect(self.bt_showtlts,
                               QtCore.SIGNAL("clicked(bool)"), self.show_tlts)
        QtCore.QObject.connect(self.bt_refresh, QtCore.SIGNAL("clicked(bool)"),
                               self.update_files)
        QtCore.QObject.connect(self.bt_plotctf, QtCore.SIGNAL("clicked(bool)"),
                               self.plot_ctf)

        self.wg_2dimage = EMImage2DWidget()
        self.wg_2dimage.setWindowTitle("Tomo2D")
        self.cur_data = None

        self.wg_tltimage = EMImage2DWidget()
        self.wg_tltimage.setWindowTitle("Tiltseries")
        self.wg_tltimage.set_scale(.2)
        self.cur_tlt = None

        self.setspanel = QtGui.QListWidget(self)
        self.gbl.addWidget(self.setspanel, 8, 1, 2, 2)
        self.itemflags = Qt.ItemFlags(Qt.ItemIsEditable) | Qt.ItemFlags(
            Qt.ItemIsSelectable) | Qt.ItemFlags(
                Qt.ItemIsEnabled) | Qt.ItemFlags(Qt.ItemIsUserCheckable)

        self.wg_notes = QtGui.QTextEdit(self)
        self.gbl.addWidget(self.wg_notes, 10, 1, 1, 2)

        QtCore.QObject.connect(self.setspanel,
                               QtCore.SIGNAL("itemChanged(QListWidgetItem*)"),
                               self.clickset)
        QtCore.QObject.connect(self.wg_notes, QtCore.SIGNAL("textChanged()"),
                               self.noteupdate)

        self.wg_plot2d = EMPlot2DWidget()

        self.update_files()
示例#8
0
 def flags(self, index):
     if index.row() < self.exam_config.num_questions:
         return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable)
     else:
         return Qt.ItemFlags(Qt.ItemIsEnabled)
示例#9
0
 def flags(self, index):
     """
     Set flags
     """
     if not index.isValid(): return Qt.ItemIsEnabled
     return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
示例#10
0
 def flags(self, index):
     if not index.isValid():
         return Qt.ItemIsEnabled
     return Qt.ItemFlags(
         QAbstractItemModel.flags(self, index) | Qt.ItemIsEnabled
         | Qt.ItemIsSelectable)
示例#11
0
    def test_flags(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)

        doc = QDomDocument()
        nname = "definition"
        qdn = doc.createElement(nname)
        doc.appendChild(qdn)
        nkids = self.__rnd.randint(1, 10)
        kds = []
        tkds = []
        for n in range(nkids):
            kds.append(doc.createElement("kid%s" % n))
            kds[-1].setAttribute("name", "myname%s" % n)
            kds[-1].setAttribute("type", "mytype%s" % n)
            kds[-1].setAttribute("units", "myunits%s" % n)
            qdn.appendChild(kds[-1])
            tkds.append(doc.createTextNode("\nText\n %s\n" % n))
            kds[-1].appendChild(tkds[-1])

#        print doc.toString()

        allAttr = True
        cm = ComponentModel(doc, allAttr)
        self.assertTrue(isinstance(cm, QAbstractItemModel))
        self.assertTrue(isinstance(cm.rootIndex, QModelIndex))
        cd = cm.rootIndex.internalPointer()
        self.assertTrue(isinstance(cd, ComponentItem))
        self.assertEqual(cm.rootIndex.row(), 0)
        self.assertEqual(cm.rootIndex.column(), 0)

        self.assertEqual(cm.flags(QModelIndex()), Qt.ItemIsEnabled)
        ri = cm.rootIndex
        self.assertEqual(
            cm.flags(ri),
            Qt.ItemFlags(
                QAbstractItemModel.flags(cm, ri) | Qt.ItemIsEnabled
                | Qt.ItemIsSelectable))
        di = cm.index(0, 0, ri)
        self.assertEqual(
            cm.flags(di),
            Qt.ItemFlags(
                QAbstractItemModel.flags(cm, di) | Qt.ItemIsEnabled
                | Qt.ItemIsSelectable))
        for n in range(nkids):
            allAttr = not allAttr
            cm.setAttributeView(allAttr)
            ki = cm.index(n, 0, di)
            self.assertEqual(
                cm.flags(ki),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ki) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ki = cm.index(n, 1, di)
            self.assertEqual(
                cm.flags(ki),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ki) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ki = cm.index(n, 2, di)
            self.assertEqual(
                cm.flags(ki),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ki) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ki = cm.index(n, 3, di)
            self.assertEqual(cm.flags(ki), Qt.ItemIsEnabled)

            ki = cm.index(n, 0, di)
            ti = cm.index(0, 0, ki)
            self.assertEqual(
                cm.flags(ti),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ti) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ti = cm.index(0, 1, ki)
            self.assertEqual(
                cm.flags(ti),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ti) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ti = cm.index(0, 2, ki)
            self.assertEqual(
                cm.flags(ti),
                Qt.ItemFlags(
                    QAbstractItemModel.flags(cm, ti) | Qt.ItemIsEnabled
                    | Qt.ItemIsSelectable))
            ti = cm.index(0, 3, ki)
            self.assertEqual(cm.flags(ti), Qt.ItemIsEnabled)
示例#12
0
    def __init__(self, row=4, column=3, parent=None):
        QtGui.QTableWidget.__init__(self, parent)
        
        # добавим нужное кол-во элементов
        self.setRowCount(row)
        self.setColumnCount(column)
        
        # сбросим активную ячейку
        self.setCurrentCell(-1, -1)
        
#        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        
        # Пример использования своего делегата
#        myDeligate = articleValidate()
#        self.setItemDelegateForColumn(1, myDeligate)
#        self.setItemDelegateForColumn(2, myDeligate)
        
        # Изменение способов выбора ячеек и воздействия на них
#        self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
#        self.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
                
        # заполнение таблицы
        for i in range(row):
            for j in range(column):
                
                item = QtGui.QTableWidgetItem("R%d C%d" % (i, j))
                item.setTextAlignment(Qt.AlignCenter)
#                if j != 0:
#                    # для выбора/редактирования доступна только 0-ая колонка
# #                    item.setFlags(QtCore.Qt.ItemIsSelectable)
#                    # пример установки флагов
#                    # Qt.ItemIsSelectable
#                    # Qt.ItemIsEnabled
#                    # Qt.ItemIsEditable
#                    flag = Qt.ItemFlags()
#                else:
#                    flag = Qt.ItemFlags(Qt.ItemIsEnabled)
                 
                # ячейка доступна для выбора
                flag = Qt.ItemFlags(Qt.ItemIsEnabled)
                item.setFlags(flag)
                self.setItem(i, j, item)
        
        for j in range(column):
            self.setHorizontalHeaderItem(j, QtGui.QTableWidgetItem())
        
        # запретим изменение размеров столбцов и колонок
        # self.horizontalHeader().setResizeMode(QtGui.QHeaderView.Fixed)
        # self.verticalHeader().setResizeMode(QtGui.QHeaderView.Fixed)
        
        # подгонка ширины колонок / строк под размеры таблицы
        self.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        self.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        
        # установим ширину колонов в зависимости от размеров окна
#        width_column = size.width() - self.verticalHeader().width()
#        width_column = (width_column - 2) / column
#        for i in range(column):
#            self.setColumnWidth(i, width_column)
        
        # установим высоту колонок в зависимости от размеров окна
#        height_row = size.height() - self.horizontalHeader().height()
#        height_row = (height_row - 2) / row
#        for i in range(row):
#            self.setRowHeight(i, height_row)
        
        # установим запрет на появление скролл-баров
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
示例#13
0
 def recordFlags(self, record, column):
     if column == 'Enabled':
         return Qt.ItemFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled
                             | Qt.ItemIsSelectable)
     return Qt.ItemFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)