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')
评论列表
文章目录