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