示例#1
0
 def hideBits(self):
     for _ in range(len(
             self.hq)):  # get all highlighted cells in showBitsTableWidget
         i, j = self.hq.pop(0)  # remove from list
         item = QTableWidgetItem()  # get blank color
         self.showBitsTableWidget.item(i - 1, j).setBackground(
             item.background())  #set blank color
示例#2
0
文件: widgets.py 项目: ocaner/pe3
    def update(self):
        for i in range(self.count):
            old_value = self.values[i]
            new_value = self.registers[i]

            x = self.item(i, 0)
            d = self.item(i, 1)
            b = self.item(i, 2)
            
            if x is None:
                x = QTableWidgetItem("", 1)
                x.setFont(self.mono)
                self.setItem(i, 0, x)

            if d is None:
                d = QTableWidgetItem("", 1)
                d.setFont(self.mono)
                self.setItem(i, 1, d)
            
            if b is None:
                b = QTableWidgetItem("", 1)
                b.setFont(self.mono)
                self.setItem(i, 2, b)
            
            x.setText(f"{new_value:08x}")
            d.setText(f"{new_value:d}")
            b.setText(f"{new_value:32b}")
            #self.table.setCellWidget(i, 0, d)
            #self.table.setCellWidget(i, 1, x)
            
            #di = self.table.itemAt(i, 0)
            #xi = self.table.itemAt(i, 1)

            if old_value != new_value:
                if self.old_background is None:
                    self.old_background = d.background()
                
                if self.old_foreground is None:
                    self.old_foreground = d.foreground()

                x.setForeground(self.black)
                x.setBackground(self.change)

                d.setForeground(self.black)
                d.setBackground(self.change)

                b.setForeground(self.black)
                b.setBackground(self.change)
            else:
                if self.old_background is not None:
                    x.setBackground(self.old_background)
                    d.setBackground(self.old_background)
                    b.setBackground(self.old_background)
                
                if self.old_foreground is not None:
                    x.setForeground(self.old_foreground)
                    d.setForeground(self.old_foreground)
                    b.setForeground(self.old_foreground)
示例#3
0
 def open_color_dialog(self, item: QTableWidgetItem):
     """A method that creates a color dialog window and shows it
     when the user presses the 'Color' button. At the confirmation
     of the color dialog, set the color in the current row."""
     if item.column() == 3:
         initial_color = item.background().color()
         color = QgsColorDialog.getColor(
             initialColor=initial_color,
             parent=self.dlg.tableWidget,
             allowOpacity=False
         )
         self.log(str(color.getRgb()))
         if color.isValid():
             item.setBackground(color)
示例#4
0
    def _item_activated(self, item: QTableWidgetItem):
        """
        When an item is activated in the table signal_item_activated containing
        the content string of the item and the group name is emitted.

        :param item: QTableWidget item from TableWidget
        """
        text = item.text()
        fg_color = item.foreground().color().name()
        bg_color = item.background().color().name()
        group_name = ""
        for key, value in self.color_map.items():
            logging.debug(key + " " + value[0] + " " + str(type(value[0]))
                          + " " + value[1])
            logging.debug(fg_color + " " + bg_color)
            if value[0] == fg_color and value[1] == bg_color:
                group_name = key
                break

        self.signal_item_activated.emit(text, group_name)