我们从Python开源项目中,提取了以下44个代码示例,用于说明如何使用PySide.QtGui.QTableWidgetItem()。
def update_table(self, row): rowPosition = self.tableWidget.rowCount() self.tableWidget.insertRow(rowPosition) player = row[0] name = row[1] coord = row[2] points = int(row[3]) self.tableWidget.setItem(rowPosition, 0, QtGui.QTableWidgetItem(player)) self.tableWidget.setItem(rowPosition, 1, QtGui.QTableWidgetItem(name)) self.tableWidget.setItem(rowPosition, 2, QtGui.QTableWidgetItem(coord)) points_item = QtGui.QTableWidgetItem() points_item.setData(QtCore.Qt.DisplayRole, points) self.tableWidget.setItem(rowPosition, 3, points_item)
def add_data_to_table(self, route): self.tableWidget_path.setRowCount(len(route)) for i, row in enumerate(route): for j, col in enumerate(row): item = QtGui.QTableWidgetItem("{}".format(col)) self.tableWidget_path.setItem(i, j, item) if j in [1, 2]: self.tableWidget_path.item(i, j).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) if row[1] == "HS": color = QtGui.QColor(223, 240, 216) elif row[1] == "LS": color = QtGui.QColor(252, 248, 227) elif row[1] == "NS": color = QtGui.QColor(242, 222, 222) else: color = QtGui.QColor(210, 226, 242) if j == 3 and "wormhole" in col: self.tableWidget_path.item(i, j).setIcon(self.icon_wormhole) self.tableWidget_path.item(i, j).setBackground(color) self.tableWidget_path.item(i, j).setForeground(QtGui.QColor(0, 0, 0))
def rsAdd(self): row = self.rstable.rowCount() str = "" if self.rslist.currentText() == "Kriging" or self.rslist.currentText() == "MARS": str = self.rslist.currentText() else: str = self.rslist.currentText() + ", " str += self.taillist.currentText() if self.rsclist.currentText() == "RSCapped": str += ", Median Cap" elif self.rsclist.currentText() == "RSUnitBox": str += ", Unit Box" # Check if string already exists for r in range(self.rstable.rowCount()): if str == self.rstable.item(r, 0).text(): return self.rstable.insertRow(row) self.rstable.setItem(row, 0, QtGui.QTableWidgetItem(str)) self.rsremove.setEnabled(True) if self.rstable.rowCount() > 1: self.rsup.setEnabled(True) self.rsdown.setEnabled(True)
def __init__(self,gui): QObject.__init__(self) self.sonar = Sonar() self.gui = gui self.ui = gui.ui self.post = Post(self) self.ui.btn_sonar_enable.clicked.connect(self.sonar.enable) self.ui.btn_sonar_disable.clicked.connect(self.sonar.disable) self.updateDistances.connect(self.updateGui) self.ui.btn_sonar_reset.clicked.connect(self.reset) for i in range(12): newItem = QtGui.QTableWidgetItem("Sensor "+str(i)) self.ui.tbl_sonar.setItem(i, 0, newItem) self.reset() self.post.callback()
def initialize(self,pop_obj): self.pop_obj = pop_obj self.ui.user_email.setText(self.pop_obj.username) self.message_count = self.pop_obj.get_message_count() self.lastrow = self.ui.received_email.rowCount() senders,subjects,dates = self.pop_obj.get_message_list(self.lastrow,self.lastrow+10) for sender,subject,date in zip(senders,subjects,dates): self.ui.received_email.insertRow(self.lastrow) send = QtGui.QTableWidgetItem(self.clean(sender)) date = QtGui.QTableWidgetItem(self.clean(date)) sub = QtGui.QTableWidgetItem(self.clean(subject)) self.ui.received_email.setItem(self.lastrow,0,send) self.ui.received_email.setItem(self.lastrow,1,date) self.ui.received_email.setItem(self.lastrow,2,sub) self.lastrow+=1 self.ui.showing_label.setText("Showing "+str(self.lastrow)+" of "+str(self.message_count)+" emails") self.ui.received_email.resizeColumnsToContents() #Adds action to load the email data on click of table button
def showShotAssets(self,*args): for r in range(self.AssetsTable.rowCount()): self.AssetsTable.removeRow(0) if self.selShot in self.shotgunAssetData.keys(): assets=self.shotgunAssetData[self.selShot] assets.sort() for asset in assets: rowNum=self.AssetsTable.rowCount() self.AssetsTable.insertRow(rowNum) self.AssetsTable.setRowHeight(rowNum, 15) #set itemName item=QtGui.QTableWidgetItem() item.setText(asset) self.AssetsTable.setItem(rowNum,0,item) #set itemStatus #item=QtGui.QTableWidgetItem() #item.setText(qubeJob['status']) #self.qubeTable.setItem(rowNum,1,item)
def setupTable(self,*args): self.shotTable.setColumnCount(len(self.columns)) colCount=0 self.columns.sort() self.rows.sort() for y,c in enumerate(self.columns): self.shotTable.setColumnCount(y+1) item = QtGui.QTableWidgetItem() item.setText(c) self.shotTable.setHorizontalHeaderItem(y, item) for x,r in enumerate(self.rows): rowNum=self.shotTable.rowCount() self.shotTable.insertRow(rowNum) self.shotTable.setRowHeight(rowNum, 15) for y,c in enumerate(self.columns): for k in self.assetData.keys(): if r in k and c in k: item=QtGui.QTableWidgetItem() item.setText(k) self.shotTable.setItem(x,y,item)
def __init__(self,m,n,LowVerticalHeader,HighVerticalHeader,LowHoizontalHeader,HighHorizontalHeader,CorrelationTable,regionIDS): super(NewWindowCorrelationTableDisplay, self).__init__(m, n) CellSize = 18 if CorrelationTable.CommunityMode: self.setVerticalHeaderLabels([''.join(CorrelationTable.ClusteredOrder[key]) for key in range(LowVerticalHeader ,HighVerticalHeader+1)]) self.setHorizontalHeaderLabels(['\n'.join(CorrelationTable.ClusteredOrder[key]) for key in range(LowHoizontalHeader,HighHorizontalHeader+1)]) else: self.setVerticalHeaderLabels([''.join(CorrelationTable.Brain_Regions[key]) for key in range(LowVerticalHeader ,HighVerticalHeader+1)]) self.setHorizontalHeaderLabels(['\n'.join(CorrelationTable.Brain_Regions[key]) for key in range(LowHoizontalHeader,HighHorizontalHeader+1)]) for i in range(n+1): self.setColumnWidth(i,CellSize) for i in range(m+1): self.setRowHeight(i,CellSize) for column in range(n): for row in range(m): table_item = CorrelationTable.item(regionIDS[column*m + row][0],regionIDS[column*m + row][1]) table_item_new = QtGui.QTableWidgetItem() table_item_new.setBackground(table_item.background()) table_item_new.setToolTip(table_item.toolTip()) self.setItem(row, column, table_item_new) self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding) self.setShowGrid(False) self.setStyleSheet("selection-background-color: transparent;") self.setItemDelegate(self.BackgroundDelegate()) # Counter 2 is community correlation table # Counter 1 is Correlation Table
def loadCategories(self): for i in range(self.categoriesTable.rowCount(), 0, -1): self.categoriesTable.removeRow(i - 1) ## self.tabs.setTabEnabled(1, True) for i in self.newDtabase.getElementsByTagName('categories')[0].getElementsByTagName('category'): rowNumber = self.categoriesTable.rowCount() self.categoriesTable.insertRow(rowNumber) ###### widgetActive = QtGui.QCheckBox('') widgetActive.setStyleSheet('margin-left:18px;') self.categoriesTable.setCellWidget(rowNumber, 0, widgetActive) # itemID = QtGui.QTableWidgetItem(i.getAttribute("number")) self.categoriesTable.setItem(rowNumber, 1, itemID) # itemName = QtGui.QTableWidgetItem(i.getAttribute("name")) self.categoriesTable.setItem(rowNumber, 2, itemName) # try: cDescription = i.firstChild.data except: cDescription = '' itemDescription = QtGui.QTableWidgetItem(cDescription) self.categoriesTable.setItem(rowNumber, 3, itemDescription) # new category widgetAction = QtGui.QComboBox() widgetAction.addItem('New category', [-1, '']) # new category # nr = 1 for j, k in readCategories().items(): widgetAction.addItem('Move all objects to existing category: {0}'.format(k[0]), [j, k[0]]) if k[0] == i.getAttribute("name"): widgetAction.setCurrentIndex(nr) nr += 1 self.categoriesTable.setCellWidget(rowNumber, 4, widgetAction)
def addNewModelCell(self, text, num): a = QtGui.QTableWidgetItem(str(text)) a.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) a.setTextAlignment(QtCore.Qt.AlignCenter) self.setItem(self.rowCount() - 1, num, a)
def spisWarstwAddRow(self, ID, layerColor, layerTransparent, layerName): self.spisWarstw.insertRow(self.spisWarstw.rowCount()) check = QtGui.QCheckBox() check.setStyleSheet("QCheckBox {margin:7px;}") self.spisWarstw.setCellWidget(self.spisWarstw.rowCount() - 1, 0, check) # num = QtGui.QTableWidgetItem(str(ID)) num.setTextAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.spisWarstw.setItem(self.spisWarstw.rowCount() - 1, 1, num) # if layerColor: color = kolorWarstwy() color.setColor(layerColor) color.setToolTip(u"Click to change color") else: color = QtGui.QLabel("") self.spisWarstw.setCellWidget(self.spisWarstw.rowCount() - 1, 2, color) # if layerTransparent: if layerTransparent[0] == 'int': transparent = transpSpinBox() else: transparent = transpDoubleSpinBox() transparent.setRange(layerTransparent[3], layerTransparent[4]) transparent.setSuffix(layerTransparent[1]) transparent.setValue(layerTransparent[2]) else: transparent = QtGui.QLabel("") self.spisWarstw.setCellWidget(self.spisWarstw.rowCount() - 1, 3, transparent) # name = QtGui.QTableWidgetItem(layerName) name.setTextAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) name.setToolTip(u"Click to change name") self.spisWarstw.setItem(self.spisWarstw.rowCount() - 1, 4, name)
def _add_table_row(self,items): new_row = self._table.rowCount()+1 self._table.setRowCount(new_row) for i, item in enumerate(items): if type(item) != bool: if i == 4: self.new_item = QtGui.QPushButton('Backup!') self.new_item.clicked.connect(self.handle_manual_backup) self._table.setCellWidget(new_row-1,i,self.new_item) continue elif i == 5 and item != None: if item != '...': new_item = QtGui.QTableWidgetItem('{}'.format(item)) link_font = QtGui.QFont(new_item.font()) link_font.setUnderline(True) new_item.setFont(link_font) new_item.setTextAlignment(QtCore.Qt.AlignCenter) new_item.setForeground(QtGui.QBrush(QtGui.QColor("teal"))) else: new_item = QtGui.QTableWidgetItem('{}'.format(item)) new_item.setTextAlignment(QtCore.Qt.AlignCenter) elif i == 1 and item == None: new_item = QtGui.QTableWidgetItem('no backups') new_item.setForeground(QtGui.QBrush(QtGui.QColor("grey"))) else: new_item = QtGui.QTableWidgetItem(item) new_item.setFlags(QtCore.Qt.ItemIsEnabled) elif type(item) == bool: new_item = QtGui.QTableWidgetItem() if i == 3 and items[2] == False: new_item.setFlags(QtCore.Qt.ItemFlags() != QtCore.Qt.ItemIsEnabled) new_item.setCheckState(QtCore.Qt.Unchecked) else: new_item.setFlags(QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled) new_item.setCheckState(QtCore.Qt.Unchecked if item == False else QtCore.Qt.Checked) self._table.setItem(new_row-1,i,new_item)
def newLang_action(self): if len(self.memoData['fileList'].keys()) == 0: print("You need have UI name structure loaded in order to create a new language.") else: text, ok = QtWidgets.QInputDialog.getText(self, 'New Translation Creation', 'Enter language file name (eg. lang_cn):') if ok: if text in self.memoData['fileList'].keys(): print("This Language already in the table.") else: self.uiList['dict_table'].insertColumn(self.uiList['dict_table'].columnCount()) index = self.uiList['dict_table'].columnCount() - 1 self.uiList['dict_table'].setHorizontalHeaderItem(index, QtWidgets.QTableWidgetItem(text) )
def changeTableHeader(self, index): table = self.uiList["dict_table"] oldHeader = str(table.horizontalHeaderItem(index).text()) text, ok = QtWidgets.QInputDialog.getText(self, 'Change header label for column %d' % index,'Header:',QtWidgets.QLineEdit.Normal, oldHeader) if ok: if text in self.memoData['fileList'].keys(): print("This Language already in the table.") else: table.setHorizontalHeaderItem(index, QtWidgets.QTableWidgetItem(text) )
def memory_to_source_ui(self): # update ui once memory gets update txt='\n'.join([row for row in self.memoData['fileList']]) self.uiList['source_txtEdit'].setText(txt) # table table = self.uiList['dict_table'] table.clear() table.setRowCount(0) table.setColumnCount(0) headers = ["UI Name"] table.insertColumn(table.columnCount()) for key in self.memoData['fileList']: headers.append(key) table.insertColumn(table.columnCount()) table.setHorizontalHeaderLabels(headers) ui_name_ok = 0 translate = 1 for file in self.memoData['fileList']: for row, ui_name in enumerate(self.memoData['fileList'][file]): #create ui list if ui_name_ok == 0: ui_item = QtWidgets.QTableWidgetItem(ui_name) table.insertRow(table.rowCount()) table.setItem(row, 0, ui_item) translate_item = QtWidgets.QTableWidgetItem(self.memoData['fileList'][file][ui_name]) table.setItem(row, translate, translate_item) ui_name_ok = 1 translate +=1
def changeTableHeader(self, index): table = self.uiList["dict_table"] oldHeader = str(table.horizontalHeaderItem(index).text()) text, ok = QtGui.QInputDialog.getText(self, 'Change header label for column %d' % index,'Header:',QtGui.QLineEdit.Normal, oldHeader) if ok: if text in self.memoData['fileList'].keys(): print("This Language already in the table.") else: table.setHorizontalHeaderItem(index, QtGui.QTableWidgetItem(text) ) #~~~~~~~~~~~~~~ # default ui function
def memory_to_source_ui(self): # update ui once memory gets update txt='\n'.join([row for row in self.memoData['fileList']]) self.uiList['source_txtEdit'].setText(txt) # table table = self.uiList['dict_table'] table.clear() table.setRowCount(0) table.setColumnCount(0) headers = ["UI Name"] table.insertColumn(table.columnCount()) for key in self.memoData['fileList']: headers.append(key) table.insertColumn(table.columnCount()) table.setHorizontalHeaderLabels(headers) ui_name_ok = 0 translate = 1 for file in self.memoData['fileList']: for row, ui_name in enumerate(self.memoData['fileList'][file]): #create ui list if ui_name_ok == 0: ui_item = QtGui.QTableWidgetItem(ui_name) table.insertRow(table.rowCount()) table.setItem(row, 0, ui_item) translate_item = QtGui.QTableWidgetItem(self.memoData['fileList'][file][ui_name]) table.setItem(row, translate, translate_item) ui_name_ok = 1 translate +=1
def searchAdd(self): row = self.searchtable.rowCount() self.searchtable.insertRow(row) self.searchtable.setItem(row, 0, QtGui.QTableWidgetItem(self.searchlist.currentText())) self.searchremove.setEnabled(True) if self.searchtable.rowCount() > 1: self.searchup.setEnabled(True) self.searchdown.setEnabled(True)
def fill_project_table(self, table): #copy = db.studio() # self.db_studio self.db_group.get_list_projects() if not self.db_group.list_projects: return projects = [] for key in self.db_group.list_projects.keys(): projects.append({'name' : key,'status' : self.db_group.list_projects[key]['status'], 'path': self.db_group.list_projects[key]['path']}) # get table data columns = ('name', 'status', 'path') num_row = len(projects) num_column = len(columns) headers = columns # make table table.setColumnCount(num_column) table.setRowCount(num_row) table.setHorizontalHeaderLabels(headers) # fill table for i, project in enumerate(projects): for j,key in enumerate(headers): newItem = QtGui.QTableWidgetItem() newItem.setText(project[key]) if key == 'name': color = self.project_color brush = QtGui.QBrush(color) newItem.setBackground(brush) table.setItem(i, j, newItem) table.resizeRowsToContents() table.resizeColumnsToContents() print('fill project table')
def tm_edit_readers_ui_reload_table(self): table = self.editReadersDialog.select_from_list_data_list_table # load table headers = ['nik_name'] num_column = len(headers) num_row = 0 if self.cleaned_readers_list: num_row = len(self.cleaned_readers_list) table.setColumnCount(num_column) table.setRowCount(num_row) table.setHorizontalHeaderLabels(headers) if self.cleaned_readers_list: for i,reader_name in enumerate(self.cleaned_readers_list): if reader_name == 'first_reader': continue for j,key in enumerate(headers): newItem = QtGui.QTableWidgetItem() if key == 'nik_name': newItem.setText(reader_name) if 'first_reader' in self.current_readers_list: if self.current_readers_list['first_reader'] == reader_name: newItem.setText((reader_name + ' (***)')) color = self.artist_color brush = QtGui.QBrush(color) newItem.setBackground(brush) newItem.reader_name = reader_name table.setItem(i, j, newItem)
def tm_add_readers_ui_load_artist_list(self, workrom_name): table = self.selectReadersDialog.select_from_list_data_list_table workroom_dict = self.selectReadersDialog.workroom_dict self.clear_table(table) result = self.db_workroom.read_artist_of_workroom(workroom_dict[workrom_name]['id']) if not result[0]: self.message(result[1], 2) artirs_dict = result[1] # load table headers = ['nik_name', 'level'] num_column = len(headers) num_row = 0 if artirs_dict: num_row = len(artirs_dict) table.setColumnCount(num_column) table.setRowCount(num_row) table.setHorizontalHeaderLabels(headers) if artirs_dict: for i,reader_name in enumerate(artirs_dict): for j,key in enumerate(headers): newItem = QtGui.QTableWidgetItem() newItem.setText(artirs_dict[reader_name][key]) newItem.reader_name = reader_name if key == 'nik_name': color = self.artist_color brush = QtGui.QBrush(color) newItem.setBackground(brush) if self.current_readers_list: if reader_name in self.current_readers_list.keys(): color = self.grey_color brush = QtGui.QBrush(color) newItem.setBackground(brush) table.setItem(i, j, newItem)
def updateState(self,*args): # print args state = args[0] if len(args) > 2: button_name = args[1].split("_") if len(button_name) > 1: side = button_name[1] button_name = button_name[0]+"_" else: side = button_name[0] button_name = "" if args[2] == "button": id = args[3] if id == 0: button_name+="ok" elif id==2: button_name+="rethink" elif id==1: button_name+="back" else: button_name+="wheel" state = args[3] else: button_name = args[1].split("_") side = button_name[0] button_name = "_".join(button_name[1:]) newItem = QtGui.QTableWidgetItem(str(state)) for i,button in enumerate(self.button_names): if button == button_name: if side == "left": column = 1 else: column = 2 old = self.ui.tbl_buttons.item(i,column).text() # if not old == "N/A" and not str(state) == old: if old == "N/A": self.removeButtonFromList(side, button) self.ui.tbl_buttons.setItem(i, column, newItem)
def reset(self): for i in range(12): newItem = QtGui.QTableWidgetItem("None") self.ui.tbl_sonar.setItem(i, 1, newItem)
def updateGui(self,distances): for i,distance in enumerate(distances): if distance is None: continue newItem = QtGui.QTableWidgetItem(str(distance)) self.ui.tbl_sonar.setItem(i, 1, newItem)
def retrieve(self): senders,subjects,dates = self.pop_obj.get_message_list(self.lastrow,self.lastrow+10) for sender,subject,date in zip(senders,subjects,dates): self.ui.received_email.insertRow(self.lastrow) send = QtGui.QTableWidgetItem(self.clean(sender)) date = QtGui.QTableWidgetItem(self.clean(date)) sub = QtGui.QTableWidgetItem(self.clean(subject)) self.ui.received_email.setItem(self.lastrow,0,send) self.ui.received_email.setItem(self.lastrow,1,date) self.ui.received_email.setItem(self.lastrow,2,sub) self.lastrow+=1 self.ui.showing_label.setText("Showing "+str(self.lastrow)+" of "+str(self.message_count)+" emails") self.ui.received_email.resizeColumnsToContents() #Cleans the string and removes trailing and leading whitespaces
def createAssetsTab(self,*args): ###Assets TAB self.AssetsTab = QtGui.QWidget() self.AssetsTab.setObjectName("assetsTab") #Assets Layout self.AssetshorizontalLayout = QtGui.QHBoxLayout(self.AssetsTab) self.AssetshorizontalLayout.setObjectName("AssetshorizontalLayout") #AssetsTable self.AssetsTable = QtGui.QTableWidget(self.AssetsTab) self.AssetsTable.setObjectName("AssetsTable") self.AssetsTable.verticalHeader().hide() #self.AssetsTable.horizontalHeader().hide() self.AssetsTable.setColumnCount(2) item = QtGui.QTableWidgetItem() item.setText("name") self.AssetsTable.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.AssetsTable.setAlternatingRowColors(True) self.AssetsTable.setSortingEnabled(True) self.AssetsTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.AssetsTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.AssetsTable.horizontalHeader().stretchLastSection() self.AssetshorizontalLayout.addWidget(self.AssetsTable) self.getAssetData() self.bottomTab.addTab(self.AssetsTab,"assetsTab") self.tabs.append("assetsTab") self.bottomTab.setCurrentIndex(self.tabs.index("assetsTab"))
def showQubeStatus(self,*args): import datetime self.getQubeStatus() #add qubeStatus column self.shotTable.setColumnCount(self.shotTable.columnCount()+1) item = QtGui.QTableWidgetItem() item.setText('qubeStatus') self.shotTable.setHorizontalHeaderItem(self.shotTable.columnCount()-1, item) for r in range(self.shotTable.rowCount()): shot=self.shotTable.item(r,0).text() runningFound=0 mostRecent=0 for k in self.qubeStatus.keys(): if shot in k: if 'running' in self.qubeStatus[k]['status']: runningFound=1 if 'complete' in self.qubeStatus[k]['status']: if self.qubeStatus[k]['timecomplete']>mostRecent: mostRecent=self.qubeStatus[k]['timecomplete'] item=QtGui.QTableWidgetItem() if mostRecent: date = datetime.datetime.fromtimestamp(mostRecent) item.setText('Completed:'+date.strftime("%m/%d %I:%M%p")) if runningFound: item.setText('Running') self.shotTable.setItem(r,self.shotTable.columnCount()-1,item)
def updateSequenceNofications(self,*args): self.bottomTab.setCurrentIndex(0) task = nuke.ProgressTask('updating table') for r in range(self.shotTable.rowCount()): self.shotTable.setCurrentCell(r,0) task.setMessage( 'shot:' + self.selShot) nukeFiles=[] if os.path.exists(self.template_nukeScriptPath.replace("shotNum",self.selShot)): scriptFiles=os.listdir(self.template_nukeScriptPath.replace("shotNum",self.selShot)) for sfile in scriptFiles: if sfile.endswith(".nk") and self.fileFilterText in sfile: nukeFiles.append(self.template_nukeScriptPath.replace("shotNum",self.selShot)+"/"+sfile) if len(nukeFiles)>0: #select latest project file latest=self.getLatestFile(nukeFiles) self.selScript=latest.split("/")[-1] self.buildTreeB() self.resetTreeBColors() self.buildTreeA() found,renderLayers=self.compareRenders() if found: color=QtGui.QColor(200,0,0) item=QtGui.QTableWidgetItem() item.setBackground(color) item.setText("update "+str(len(renderLayers))) self.shotTable.setItem(r,4,item) if not found: item=QtGui.QTableWidgetItem() self.shotTable.setItem(r,4,item) task.setProgress( int( float(r) / float(self.shotTable.rowCount()) *100) ) del(task)
def updateNotesTable(self,*args): for i in range(self.sendTaskCombo.count()): #self.sendTaskCombo.addItems(["Composite","Lighting","Animation",]) self.sendTaskCombo.removeItem(0) tasks=self.shotgunShotData[self.selShot]['tasks'].keys() self.sendTaskCombo.addItems(tasks) self.sendTaskCombo.setCurrentIndex(tasks.index("comp")) self.notesTable.clearContents() self.notesTable.setRowCount(0) self.notesTable.setSortingEnabled(False) #for r in range(self.notesTable.rowCount()): # self.notesTable.removeRow(0) if self.selShot in self.shotgunNotes.keys(): for note in self.shotgunNotes[self.selShot]: columns=note.split("<,>") status=columns[2] task=columns[4] valid=1 if self.notesShowClosedChbox.checkState() and "clsd" in status: valid=0 if self.notesShowCompOnlyChbox.checkState() and not "comp" in task: valid=0 if valid: rowNum=self.notesTable.rowCount() self.notesTable.insertRow(rowNum) self.notesTable.setRowHeight(rowNum, 15) for i,col in enumerate(columns[1:]): item=QtGui.QTableWidgetItem() item.setText(col) self.notesTable.setItem(rowNum,i,item) self.notesTable.setSortingEnabled(True)
def floatAsItem(self, value): item = QTableWidgetItem() item.setData(Qt.EditRole, value) return item #Change commmand string when combo box changes
def addButton_onClicked(self): if(len(self.poseName.text()) > 0): rowPosition = self.table.rowCount() self.table.insertRow(rowPosition) self.table.setVerticalHeaderItem(rowPosition, QtGui.QTableWidgetItem(self.poseName.text())) self.poseName.setText('') self.table.setItem(rowPosition , 0, self.floatAsItem(0.5)) self._updateWidgetSize() # Delete selected row
def __init__(self, correlationTable, colorTable,GraphDataStructure): n = len(correlationTable.header) super(CommunityCorrelationTableDisplay, self).__init__(n, n) from collections import defaultdict self.CommunityMode = False self.MouseReleased = True self.colorTable = colorTable self.sortedDict= defaultdict(list) self.newWindowWidget = [] self.Selectionmode = True self.GraphDataStructure = weakref.ref(GraphDataStructure) self.data = self.GraphDataStructure().ThresholdData self.Order = [] self.i = 0 self.newwidget = None self.Brain_Regions = correlationTable.RegionName[0] self.First = True self.g= [] self.isElementsSorted = False self.setMinimumSize(800,400) self.setContentsMargins(0, 0, 0, 0) self.correlationTable = correlationTable self.setVerticalHeaderLabels(self.correlationTable.header) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.correlationTable.header]) font = QtGui.QFont() font.setPointSize(8) self.horizontalHeader().setFont(font) self.verticalHeader().setFont(font) if n < 50: CellSize= 40 else: CellSize = 4 for i in range(n): self.setColumnWidth(i,CellSize) self.setRowHeight(i, CellSize) self.resizeRowToContents(i) self.horizontalHeaderItem(i).setToolTip(self.correlationTable.header[i]) self.verticalHeaderItem(i).setToolTip(self.correlationTable.header[i]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = QtGui.QTableWidgetItem() self.setItem(i, j, table_item) self.resizeColumnsToContents() self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding) self.setShowGrid(False) self.setStyleSheet("selection-background-color: transparent;") self.setItemDelegate(self.BackgroundDelegate()) self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.itemSelectionChanged.connect(self.handleSelectionChange)
def findEntries(self): for i in range(self.categoriesTable.rowCount(), 0, -1): self.categoriesTable.removeRow(i - 1) ## self.sql.reloadList() for i in self.sql.packages(): dane = self.sql.getValues(i) software = eval(dane["soft"]) for j in software: if j[1] == self.fromSoftware.currentText(): rowNumber = self.categoriesTable.rowCount() self.categoriesTable.insertRow(rowNumber) # widgetActive = QtGui.QCheckBox('') widgetActive.setStyleSheet('margin-left:18px;') self.categoriesTable.setCellWidget(rowNumber, 0, widgetActive) # item0 = QtGui.QTableWidgetItem(i) self.categoriesTable.setItem(rowNumber, 1, item0) # item1 = QtGui.QTableWidgetItem(dane["name"]) item1.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.categoriesTable.setItem(rowNumber, 2, item1) # item2 = QtGui.QTableWidgetItem(j[0]) self.categoriesTable.setItem(rowNumber, 3, item2) # itemCat = QtGui.QTableWidgetItem(readCategories()[int(dane['category'])][0]) itemCat.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.categoriesTable.setItem(rowNumber, 4, itemCat) # item3 = QtGui.QTableWidgetItem(str(j[2])) item3.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 5, item3) # item4 = QtGui.QTableWidgetItem(str(j[3])) item4.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 6, item4) # item5 = QtGui.QTableWidgetItem(str(j[4])) item5.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 7, item5) # item6 = QtGui.QTableWidgetItem(str(j[5])) item6.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 8, item6) # item7 = QtGui.QTableWidgetItem(str(j[6])) item7.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 9, item7) # item8 = QtGui.QTableWidgetItem(str(j[7])) item8.setTextAlignment(QtCore.Qt.AlignCenter) self.categoriesTable.setItem(rowNumber, 10, item8)
def addRow(self, rowType): self.insertRow(self.rowCount()) row = self.rowCount() - 1 b = QtGui.QCheckBox("") b.setToolTip(u"Active") self.setCellWidget(row, 0, b) a = QtGui.QTableWidgetItem(rowType) a.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.setItem(row, 1, a) c = QtGui.QComboBox() c.addItems(["True", "False"]) self.setCellWidget(row, 2, c) d = QtGui.QDoubleSpinBox() d.setSingleStep(0.1) d.setRange(-1000, 1000) d.setSuffix("mm") self.setCellWidget(row, 3, d) e = QtGui.QDoubleSpinBox() e.setSingleStep(0.1) e.setRange(-1000, 1000) e.setSuffix("mm") self.setCellWidget(row, 4, e) f = QtGui.QDoubleSpinBox() f.setSingleStep(0.1) f.setRange(-1000, 1000) f.setSuffix("mm") self.setCellWidget(row, 5, f) g = QtGui.QDoubleSpinBox() g.setSingleStep(0.1) g.setValue(1.27) g.setSuffix("mm") self.setCellWidget(row, 6, g) color = kolorWarstwy() color.setToolTip(u"Click to change color") self.setCellWidget(row, 7, color) i = QtGui.QComboBox() i.addItems(["bottom-left", "bottom-center", "bottom-right", "center-left", "center", "center-right", "top-left", "top-center", "top-right"]) i.setCurrentIndex(4) self.setCellWidget(row, 8, i) # self.setColumnWidth(0, 25)
def __init__(self, correlationTable, colorTable,GraphDataStructure): n = len(correlationTable.header) super(CommunityCorrelationTableDisplay, self).__init__(n, n) from collections import defaultdict self.CommunityMode = False self.MouseReleased = True self.colorTable = colorTable self.sortedDict= defaultdict(list) self.newWindowWidget = [] self.Selectionmode = True self.GraphDataStructure = weakref.ref(GraphDataStructure) self.data = self.GraphDataStructure().ThresholdData self.Order = [] self.i = 0 self.newwidget = None self.Brain_Regions = correlationTable.RegionName[0] self.First = True self.g= [] self.isElementsSorted = False self.setMinimumSize(800,400) self.setContentsMargins(0, 0, 0, 0) self.correlationTable = correlationTable self.setVerticalHeaderLabels(self.correlationTable.header) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.correlationTable.header]) font = QtGui.QFont() font.setPointSize(8) self.horizontalHeader().setFont(font) self.verticalHeader().setFont(font) if n < 50: CellSize= 18 else: CellSize = 4 for i in range(n): self.setColumnWidth(i,CellSize) self.setRowHeight(i, CellSize) # self.resizeRowToContents(i) self.horizontalHeaderItem(i).setToolTip(self.correlationTable.header[i]) self.verticalHeaderItem(i).setToolTip(self.correlationTable.header[i]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = QtGui.QTableWidgetItem() self.setItem(i, j, table_item) # self.resizeColumnsToContents() self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding) self.setShowGrid(False) self.setStyleSheet("selection-background-color: transparent;") self.setItemDelegate(self.BackgroundDelegate()) self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.itemSelectionChanged.connect(self.handleSelectionChange)
def fill_artist_table(self): #copy = self.db_artist artists = self.db_workroom.read_artist('all') if not artists[0]: return # get workroom data wr_id_dict = {} wr_name_dict = {} result = self.db_workroom.get_list_workrooms(DICTONARY = 'by_id_by_name') if not result[0]: self.message(result[1], 3) #return else: wr_id_dict = result[1] wr_name_dict = result[2] # get table data num_row = len(artists[1]) num_column = len(self.db_workroom.artists_keys) headers = [] for item in self.db_workroom.artists_keys: headers.append(item[0]) # make table self.myWidget.studio_editor_table.setColumnCount(num_column) self.myWidget.studio_editor_table.setRowCount(num_row) self.myWidget.studio_editor_table.setHorizontalHeaderLabels(headers) # fill table for i, artist in enumerate(artists[1]): for j,key in enumerate(headers): if key == 'date_time': continue newItem = QtGui.QTableWidgetItem() newItem.setText(artist[key]) if key == 'nik_name': color = self.artist_color brush = QtGui.QBrush(color) newItem.setBackground(brush) if key == 'workroom': if artist[key]: wr_list = json.loads(artist[key]) wr_string = '' for wr_id in wr_list: if wr_id in wr_id_dict: wr_string = wr_string + wr_id_dict[wr_id]['name'] + ', ' newItem.setText(wr_string) newItem.artist = artist self.myWidget.studio_editor_table.setItem(i, j, newItem) self.myWidget.studio_editor_table.wr_id_dict = wr_id_dict self.myWidget.studio_editor_table.wr_name_dict = wr_name_dict print('fill artist table')
def fill_workroom_table(self, table): copy = self.db_workroom workrooms = copy.get_list_workrooms() if not workrooms[0]: return self.set_self_workrooms(workrooms = workrooms) # look_keys look_keys = ['name'] # get table data num_row = len(workrooms[1]) num_column = len(look_keys) headers = [] for item in look_keys: headers.append(item) # make table table.setColumnCount(num_column) table.setRowCount(num_row) table.setHorizontalHeaderLabels(headers) # fill table for i, workroom in enumerate(workrooms[1]): for j,key in enumerate(headers): if key == 'date_time': continue newItem = QtGui.QTableWidgetItem() newItem.setText(workroom[key]) newItem.workroom = workroom if key == 'name': color = self.workroom_color brush = QtGui.QBrush(color) newItem.setBackground(brush) table.setItem(i, j, newItem) table.resizeRowsToContents() table.resizeColumnsToContents() print('fill workroom table')
def fill_active_artist_table_at_workroom(self, wr_name): copy = self.db_workroom artists = copy.read_artist('all') if not artists[0]: print(artists[1]) return # get worktoom_id result = copy.get_id_by_name(wr_name) if not result[0]: self.message(result[1], 2) return wr_id = result[1] # get artist list active_artists = [] for artist in artists[1]: # get workroom wr_list = [] if artist['workroom']: wr_list = json.loads(artist['workroom']) if wr_id in wr_list and artist['status'] == 'active': active_artists.append(artist) # get table data num_row = len(active_artists) num_column = len(self.look_keys) headers = self.look_keys # make table self.myWidget.studio_editor_table.setColumnCount(num_column) self.myWidget.studio_editor_table.setRowCount(num_row) self.myWidget.studio_editor_table.setHorizontalHeaderLabels(headers) # fill table for i, artist in enumerate(active_artists): for j,key in enumerate(headers): if not (key in self.look_keys): continue newItem = QtGui.QTableWidgetItem() newItem.setText(artist[key]) if key == 'nik_name': color = self.artist_color brush = QtGui.QBrush(color) newItem.setBackground(brush) self.myWidget.studio_editor_table.setItem(i, j, newItem) print('fill active artist table')
def fill_active_artist_table_for_workroom(self, wr_name, window): copy = self.db_workroom artists = copy.read_artist('all') if not artists[0]: return # get active list active_artists = [] for artist in artists[1]: if artist['status'] == 'active': active_artists.append(artist) # get worktoom_id result = copy.get_id_by_name(wr_name) if not result[0]: self.message(result[1], 2) return wr_id = result[1] # get table data num_row = len(active_artists) num_column = len(self.look_keys) headers = self.look_keys # make table window.select_from_list_data_list_table.setColumnCount(num_column) window.select_from_list_data_list_table.setRowCount(num_row) window.select_from_list_data_list_table.setHorizontalHeaderLabels(headers) # fill table for i, artist in enumerate(active_artists): wr_list = [] if artist['workroom']: wr_list = json.loads(artist['workroom']) for j,key in enumerate(headers): if not (key in self.look_keys): continue newItem = QtGui.QTableWidgetItem() newItem.setText(artist[key]) if key == 'nik_name' and not wr_id in wr_list: color = self.artist_color brush = QtGui.QBrush(color) newItem.setBackground(brush) elif wr_id in wr_list: color = self.grey_color brush = QtGui.QBrush(color) newItem.setBackground(brush) window.select_from_list_data_list_table.setItem(i, j, newItem) print('fill active artist table')
def look_set_of_task_from_library(self, table, data): name = table.currentItem().name right_data = data[name]['sets'] # widget loader = QtUiTools.QUiLoader() file = QtCore.QFile(self.select_from_list_dialog_path) file.open(QtCore.QFile.ReadOnly) window = self.selectWorkroomDialog = loader.load(file, self) file.close() # -- get table data num_row = len(right_data) num_column = len(self.db_set_of_tasks.set_of_tasks_keys) headers = self.db_set_of_tasks.set_of_tasks_keys # -- make table window.select_from_list_data_list_table.setColumnCount(num_column) window.select_from_list_data_list_table.setRowCount(num_row) window.select_from_list_data_list_table.setHorizontalHeaderLabels(headers) # fill table for i, set_of_tasks in enumerate(right_data): for j,key in enumerate(headers): if not (key in self.db_set_of_tasks.set_of_tasks_keys): continue newItem = QtGui.QTableWidgetItem() try: newItem.setText(set_of_tasks[key]) except: pass if key == 'task_name': color = self.tasks_color brush = QtGui.QBrush(color) newItem.setBackground(brush) elif key == 'workroom': try: newItem.setText('') except: pass window.select_from_list_data_list_table.setItem(i, j, newItem) # edit widjet window.setWindowTitle(('Set Of Tasks: ' + name)) window.select_from_list_cansel_button.clicked.connect(partial(self.close_window, window)) window.select_from_list_apply_button.setVisible(False) # set modal window window.setWindowModality(QtCore.Qt.WindowModal) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.show()
def fill_series_table(self, *args): table = args[0] project = args[1] if project == '-- select project --': self.current_project = False self.default_state_series_table(table) return else: self.current_project = project # get table data series = [] #copy = db.series() #result = copy.get_list(project) result = self.db_series.get_list(project) if result[0]: series = result[1] columns = self.series_columns num_row = len(series) num_column = len(columns) headers = columns # make table table.setColumnCount(num_column) table.setRowCount(num_row) table.setHorizontalHeaderLabels(headers) # fill table for i, data in enumerate(series): for j,key in enumerate(headers): newItem = QtGui.QTableWidgetItem() newItem.setText(data[key]) if key == 'name': color = self.series_color brush = QtGui.QBrush(color) newItem.setBackground(brush) table.setItem(i, j, newItem) # edit label self.myWidget.studio_editor_label.setText(('Series Editor / \"' + project + '\"')) table.resizeRowsToContents() table.resizeColumnsToContents() print('fill series table', result)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(1262, 529) self.user_email = QtGui.QLabel(Form) self.user_email.setGeometry(QtCore.QRect(1030, 20, 221, 31)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.user_email.setFont(font) self.user_email.setObjectName("user_email") self.retrieve_button = QtGui.QPushButton(Form) self.retrieve_button.setGeometry(QtCore.QRect(10, 50, 103, 34)) self.retrieve_button.setObjectName("retrieve_button") self.compose_button = QtGui.QPushButton(Form) self.compose_button.setGeometry(QtCore.QRect(140, 50, 103, 34)) self.compose_button.setObjectName("compose_button") self.received_email = QtGui.QTableWidget(Form) self.received_email.setGeometry(QtCore.QRect(10, 90, 821, 431)) self.received_email.setObjectName("received_email") self.received_email.setColumnCount(3) self.received_email.setRowCount(0) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(2, item) self.email_body = QtGui.QTextBrowser(Form) self.email_body.setGeometry(QtCore.QRect(840, 120, 411, 401)) self.email_body.setObjectName("email_body") self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(930, 80, 91, 41)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.label.setFont(font) self.label.setObjectName("label") self.app_title = QtGui.QLabel(Form) self.app_title.setGeometry(QtCore.QRect(10, 0, 101, 41)) font = QtGui.QFont() font.setPointSize(18) font.setWeight(75) font.setBold(True) self.app_title.setFont(font) self.app_title.setObjectName("app_title") self.showing_label = QtGui.QLabel(Form) self.showing_label.setGeometry(QtCore.QRect(560, 60, 271, 20)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.showing_label.setFont(font) self.showing_label.setObjectName("showing_label") self.open_browser = QtGui.QPushButton(Form) self.open_browser.setGeometry(QtCore.QRect(1100, 80, 151, 34)) self.open_browser.setObjectName("open_browser") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def findQubeItems(self,*args): import datetime self.qubeTable.setSortingEnabled(False) omit=['killed','failed','blocked'] if self.qubeCompleteChbox.isChecked(): omit.append('complete') #reset table for r in range(self.qubeTable.rowCount()): self.qubeTable.removeRow(0) for k in self.qubeStatus.keys(): qubeJob=self.qubeStatus[k] if self.seqSelection.currentText() in qubeJob['seq']: if not qubeJob['status'] in omit: if self.qubeGroupCombo.currentText() in qubeJob['groups']: if not self.qubeShotChbox.checkState() or self.selShot in qubeJob['name']: if datetime.datetime.fromtimestamp(qubeJob['timecomplete']) > self.qubeDateTimeEdit.dateTime().toPython() or qubeJob['timecomplete']==946702800: self.qubeDateTimeEdit.dateTime().toPython() rowNum=self.qubeTable.rowCount() self.qubeTable.insertRow(rowNum) self.qubeTable.setRowHeight(rowNum, 15) #set itemName item=QtGui.QTableWidgetItem() item.setText(qubeJob['name']) self.qubeTable.setItem(rowNum,0,item) #set itemStatus item=QtGui.QTableWidgetItem() item.setText(qubeJob['status']) self.qubeTable.setItem(rowNum,1,item) #set percentage item=QtGui.QTableWidgetItem() progBar=QtGui.QProgressBar() progBar.setMaximum(int(qubeJob['todo'])) progBar.setValue(int(qubeJob['todotally']['complete'])) #item.addWidget(progBar) #item.setText(str(qubeJob['todo'])) self.qubeTable.setCellWidget(rowNum,2,progBar) if qubeJob['status']=='complete': #set complete time item=QtGui.QTableWidgetItem() date = datetime.datetime.fromtimestamp(qubeJob['timecomplete']) item.setText(date.strftime("%m/%d %I:%M%p")) self.qubeTable.setItem(rowNum,3,item) self.qubeTable.setSortingEnabled(True)