python类QBrush()的实例源码

lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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')
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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')
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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')
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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')
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号