Python PyQt5.QtWidgets.QTreeWidgetItem() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QTreeWidgetItem(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: idasec   Author: RobinDavid   File: idasec.py    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
def setupUi(self, Master):
        Master.setObjectName("Master")
        Master.resize(718, 477)
        self.verticalLayout = QtWidgets.QVBoxLayout(Master)
        self.verticalLayout.setObjectName("verticalLayout")
        self.splitter = QtWidgets.QSplitter(Master)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")
        self.tab_widget = QtWidgets.QTabWidget(self.splitter)
        self.tab_widget.setObjectName("tab_widget")

        self.docker = QtWidgets.QDockWidget(self.splitter)
        self.docker.setObjectName("docker")
        self.docker.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea)

        self.log_widget = QtWidgets.QTreeWidget(self.docker)
        self.log_widget.setHeaderItem(QtWidgets.QTreeWidgetItem(["date", "origin", "type", "message"]))
        self.docker.setWidget(self.log_widget)

        self.verticalLayout.addWidget(self.splitter)
        self.tab_widget.setCurrentIndex(-1)
        QtCore.QMetaObject.connectSlotsByName(Master)
        Master.setWindowTitle("IDASec") 
Example 2
Project: ddt4all   Author: cedricp   File: ddt4all.py    License: GNU General Public License v3.0 6 votes vote down vote up
def newScreen(self):
        item = self.treeview_params.currentItem()

        if not item:
            self.logview.append("<font color=red>" + _("Please select a category before creating new screen") + "</font>")
            return

        if item.parent() is not None:
            item = item.parent()

        category = utf8(item.text(0))
        nsn = widgets.QInputDialog.getText(self, 'DDT4All', _('Enter screen name'))

        if not nsn[1]:
            return

        newscreenname = utf8(nsn[0])
        if newscreenname:
            self.paramview.createScreen(newscreenname, category)

            item.addChild(widgets.QTreeWidgetItem([newscreenname]))
            self.screennames.append(newscreenname) 
Example 3
Project: heap-viewer   Author: danigargu   File: structs.py    License: GNU General Public License v3.0 6 votes vote down vote up
def add_row(self, offset, name, size, value, is_array):
        parent = QtWidgets.QTreeWidgetItem(self.tree)
        parent.setText(0, "%d" % offset)
        parent.setText(1, "%s" % name)
        parent.setText(2, "%d" % size)

        if is_array:
            parent.setExpanded(self.expand_arrays)
            parent.setText(3, "Array [%d]" % len(value))
            size = sizeof(value._type_)
            for idx, val in enumerate(value):
                child = QtWidgets.QTreeWidgetItem(parent)
                child.setText(0, "%d" % (offset+(size*idx)))
                child.setText(1, "%s[%d]" % (name, idx))
                child.setText(2, "%d" % size)
                child.setText(3, "%#x" % val)
        else:
            parent.setText(3, "%#x" % value) 
Example 4
Project: idamagicstrings   Author: joxeankoret   File: IDAMagicStrings.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def populate_tree(self, d):
    # Clear previous items
    self.tree.clear()

    # Build the tree
    for key in d:
      src_file_item = QtWidgets.QTreeWidgetItem(self.tree)
      src_file_item.setText(0, key)
      src_file_item.ea = BADADDR

      for ea, name, str_data in d[key]:
        item = QtWidgets.QTreeWidgetItem(src_file_item)
        item.setText(0, "%s [0x%08x] %s" % (name, ea, str_data))
        item.ea = ea

    self.tree.itemDoubleClicked.connect(handler) 
Example 5
Project: idamagicstrings   Author: joxeankoret   File: IDAMagicStrings.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def populate_tree(self):
    # Clear previous items
    self.tree.clear()
    self.nodes = {}

    self.classes = sorted(self.classes, key=lambda x: x[1][0])
    for ea, tokens in self.classes:
      for i, node_name in enumerate(tokens):
        full_name = "::".join(tokens[:tokens.index(node_name)+1])
        if full_name not in self.nodes:
          if full_name.find("::") == -1:
            parent = self.tree
          else:
            parent_name = "::".join(tokens[:tokens.index(node_name)])
            try:
              parent = self.nodes[parent_name]
            except:
              print("Error adding node?", self.nodes, parent_name, str(sys.exc_info()[1]))

          node = QtWidgets.QTreeWidgetItem(parent)
          node.setText(0, full_name)
          node.ea = ea
          self.nodes[full_name] = node

    self.tree.itemDoubleClicked.connect(classes_handler) 
Example 6
Project: Miyamoto   Author: aboood40091   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def ParseCategory(self, items):
        """
        Parses a XML category
        """
        nodes = []
        for item in items:
            node = QtWidgets.QTreeWidgetItem()
            node.setText(0, item[0])
            # see if it's a category or a level
            if isinstance(item[1], str):
                # it's a level
                node.setData(0, Qt.UserRole, item[1])
                node.setToolTip(0, item[1])
            else:
                # it's a category
                children = self.ParseCategory(item[1])
                for cnode in children:
                    node.addChild(cnode)
                node.setToolTip(0, item[0])
            nodes.append(node)
        return tuple(nodes) 
Example 7
Project: grid-control   Author: akej74   File: gridcontrol.py    License: GNU General Public License v3.0 6 votes vote down vote up
def add_cpu_sensors(self):
        """Add selected temperature sensor(s) to the "Selected CPU sensor(s)" three widget."""

        items = [item for item in self.ui.treeWidgetHWMonData.selectedItems()]

        # The new items should have the tree widget itself as parent
        parent = self.ui.treeWidgetSelectedCPUSensors

        for item in items:
            sensor_item = QtWidgets.QTreeWidgetItem(parent)
            sensor_item.setText(0, item.text(0))
            sensor_item.setText(1, item.text(1))
            sensor_item.setForeground(0, QtGui.QBrush(QtCore.Qt.blue))  # Text color blue

        # Deselect all items in the HWMon tree widget after they have been added
        self.ui.treeWidgetHWMonData.clearSelection() 
Example 8
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example 9
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 10
Project: universal_tool_template.py   Author: shiningdesign   File: GearBox_template_1010.py    License: MIT License 6 votes vote down vote up
def DataToTree_old_2LevelSearch(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and len(sub_data[1]) == 0:
                    #print(sub_data[0][0]) print(sub_data[1])
                    pass    
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 11
Project: universal_tool_template.py   Author: shiningdesign   File: GearBox_template_1010.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 12
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1112.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example 13
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1100.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 14
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1110.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example 15
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1010.py    License: MIT License 6 votes vote down vote up
def DataToTree_old_2LevelSearch(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and len(sub_data[1]) == 0:
                    #print(sub_data[0][0]) print(sub_data[1])
                    pass    
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 16
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1010.py    License: MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example 17
Project: Grabber   Author: Thomasedv   File: parameter_tree.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _del_option(self, parent: QTreeWidgetItem, child: QTreeWidgetItem):

        self.blockSignals(True)

        parent.removeChild(child)
        selected_option = False
        for i in range(parent.childCount()):
            parent.child(i).setData(0, 35, i)
            if parent.child(i).checkState(0) == Qt.Checked:
                selected_option = True

        if parent.childCount() > 0 and not selected_option:
            parent.child(0).setCheckState(0, Qt.Checked)

        # Deselects if no options left
        if not parent.childCount():
            parent.setCheckState(0, Qt.Unchecked)

        self.blockSignals(False)

        self.update_size() 
Example 18
Project: Grabber   Author: Thomasedv   File: parameter_tree.py    License: GNU General Public License v3.0 6 votes vote down vote up
def check_dependency(self, item: QTreeWidgetItem):
        """
        Looks for mentioned dependents, and enables/disables those depending on checkstate.

        :param item: changed item from QTreeWidget (paramTree)
        :type item: QTreeWidget
        """

        if item.data(0, 33) == 0 and item.data(0, 37):
            for i in item.data(0, 37):
                if item.checkState(0) == Qt.Unchecked:
                    self.blockSignals(True)
                    i.setDisabled(True)
                    i.setExpanded(False)
                    self.blockSignals(False)
                    i.setCheckState(0, Qt.Unchecked)
                else:
                    self.blockSignals(True)
                    i.setDisabled(False)
                    self.blockSignals(False) 
Example 19
Project: PyQt   Author: PyQt5   File: testTree.py    License: GNU General Public License v3.0 6 votes vote down vote up
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(719, 544)
        self.treeWidget = QtWidgets.QTreeWidget(Form)
        self.treeWidget.setGeometry(QtCore.QRect(80, 80, 256, 192))
        self.treeWidget.setObjectName("treeWidget")
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0.setCheckState(0, QtCore.Qt.Unchecked)
        item_1 = QtWidgets.QTreeWidgetItem(item_0)
        item_1.setCheckState(0, QtCore.Qt.Unchecked)
        item_1 = QtWidgets.QTreeWidgetItem(item_0)
        item_1.setCheckState(0, QtCore.Qt.Unchecked)
        item_1 = QtWidgets.QTreeWidgetItem(item_0)
        item_1.setCheckState(0, QtCore.Qt.Unchecked)
        item_1 = QtWidgets.QTreeWidgetItem(item_0)
        item_1.setCheckState(0, QtCore.Qt.Unchecked)
        item_1 = QtWidgets.QTreeWidgetItem(item_0)
        item_1.setCheckState(0, QtCore.Qt.Unchecked)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
Example 20
Project: pandasgui   Author: adamerose   File: gui.py    License: MIT License 6 votes vote down vote up
def add_df_to_nav(self, df_name, parent=None):
        """
        Add DataFrame to the nav by looking up the DataFrame by name in df_dicts

        Args:
            df_name (str): Name of the DataFrame
            parent (QTreeWidgetItem): Parent item in the nav tree hierarchy
        """

        if parent is None:
            parent = self.nav_tree

        # Calculate and format the shape of the DataFrame
        shape = self.df_dicts[df_name]['dataframe'].shape
        shape = str(shape[0]) + ' X ' + str(shape[1])

        item = QtWidgets.QTreeWidgetItem(parent, [df_name, shape])
        self.nav_tree.itemSelectionChanged.emit()
        self.nav_tree.setCurrentItem(item) 
Example 21
Project: functions-plus   Author: ax330d   File: functions_plus.py    License: MIT License 6 votes vote down vote up
def _build_tree(self, function_tree, root):
        '''
        Builds Qt Widget tree.
        '''

        if not function_tree:
            return

        if isinstance(function_tree, FunctionData):
            self._handle_function_data_instance(function_tree, root)
            return

        for name, tree in sorted(function_tree.iteritems()):
            func_item = QtWidgets.QTreeWidgetItem(root)
            if not isinstance(tree, FunctionData):
                name = self._handle_class_name(tree, name, func_item)
            func_item.setText(0, name)
            self._build_tree(tree, func_item) 
Example 22
Project: mushroom-rl   Author: MushroomRL   File: window.py    License: MIT License 6 votes vote down vote up
def deactivate(self, item):
        """
        Deactivate the plots and DataBuffers connected to the given item

        Args:
             item (QTreeWidgetItem): ``QTreeWidgetItem`` that represents the
             plots to be deactivated.

        """
        if self.check_activated(item):
            item.setBackground(0, Window.WhiteBrush)
            callback_func_params = self._dependencies[item.text(0)]
            if isinstance(callback_func_params[0], Window):
                for curve_name in callback_func_params[1].curves_names:
                    self.deactivate(self._activation_items[curve_name])
                self._deactivate_buffer_plots(callback_func_params[1])

            callback_func_params[0].erase(callback_func_params[1]) 
Example 23
Project: mo2-plugins   Author: deorder   File: mergePluginsHide.py    License: MIT License 6 votes vote down vote up
def refreshMergedModList(self):
        self.mergedModList.clear()
        for modName in sorted(self.__mergedModInfo):
            modPluginsState = self.getMergedModPluginsState(modName)
            color = {
                Dc.ModPluginsState.UNKNOWN: Dc.red,
                Dc.ModPluginsState.ACTIVE: None,
                Dc.ModPluginsState.MIXED: Dc.yellow,
                Dc.ModPluginsState.INACTIVE: Dc.green
            }[modPluginsState]
            stateDescription = {
                Dc.ModPluginsState.UNKNOWN: self.__tr("Unknown"),
                Dc.ModPluginsState.ACTIVE: self.__tr("All plugins active"),
                Dc.ModPluginsState.MIXED: self.__tr("Some plugins active"),
                Dc.ModPluginsState.INACTIVE: self.__tr("All plugins inactive")
            }[modPluginsState]
            item = QtWidgets.QTreeWidgetItem(self.mergedModList, [modName, stateDescription])
            for x in range(2):
                if color:
                    item.setBackground(x, color)
                    item.setForeground(x, Qt.black)
                item.setData(x, Qt.UserRole, {"modName": modName, "modPluginsState": modPluginsState})
            self.mergedModList.addTopLevelItem(item)
        self.mergedModList.resizeColumnToContents(0) 
Example 24
Project: crazyflie-clients-python   Author: bitcraze   File: CrtpSharkToolbox.py    License: GNU General Public License v2.0 6 votes vote down vote up
def _packet(self, dir, pk):
        if self.masterCheck.isChecked() and \
           not (pk.port == 15 and pk.channel == 3):
            line = QtWidgets.QTreeWidgetItem()

            ms_diff = int(round(time() * 1000)) - self._ms_offset
            line.setData(0, Qt.DisplayRole, "%d" % ms_diff)
            line.setData(1, Qt.DisplayRole, "%s" % dir)
            line.setData(2, Qt.DisplayRole, "%d/%d" % (pk.port, pk.channel))

            line.setData(3, Qt.DisplayRole, hexlify(pk.data).decode('utf8'))

            s = "%d, %s, %d/%d, %s" % (ms_diff, dir, pk.port, pk.channel,
                                       hexlify(pk.data).decode('utf8'))
            self._data.append(s)

            self.logTree.addTopLevelItem(line)
            self.logTree.scrollToItem(line) 
Example 25
def updateToc(self):
        self.logTree.clear()

        toc = self.helper.cf.log.toc

        for group in list(toc.toc.keys()):
            groupItem = QtWidgets.QTreeWidgetItem()
            groupItem.setData(NAME_FIELD, Qt.DisplayRole, group)
            for param in list(toc.toc[group].keys()):
                item = QtWidgets.QTreeWidgetItem()
                item.setData(NAME_FIELD, Qt.DisplayRole, param)
                item.setData(ID_FIELD, Qt.DisplayRole,
                             toc.toc[group][param].ident)
                item.setData(PTYPE_FIELD, Qt.DisplayRole,
                             toc.toc[group][param].pytype)
                item.setData(CTYPE_FIELD, Qt.DisplayRole,
                             toc.toc[group][param].ctype)
                groupItem.addChild(item)

            self.logTree.addTopLevelItem(groupItem)
            self.logTree.expandItem(groupItem)
        self.sortTrees() 
Example 26
Project: crazyflie-clients-python   Author: bitcraze   File: LogTab.py    License: GNU General Public License v2.0 6 votes vote down vote up
def connected(self, linkURI):
        self.logTree.clear()

        toc = self.cf.log.toc

        for group in list(toc.toc.keys()):
            groupItem = QtWidgets.QTreeWidgetItem()
            groupItem.setData(0, Qt.DisplayRole, group)
            for param in list(toc.toc[group].keys()):
                item = QtWidgets.QTreeWidgetItem()
                item.setData(0, Qt.DisplayRole, param)
                item.setData(1, Qt.DisplayRole, toc.toc[group][param].ident)
                item.setData(2, Qt.DisplayRole, toc.toc[group][param].pytype)
                item.setData(3, Qt.DisplayRole, toc.toc[group][param].ctype)
                groupItem.addChild(item)

            self.logTree.addTopLevelItem(groupItem)
            self.logTree.expandItem(groupItem) 
Example 27
Project: crazyflie-clients-python   Author: bitcraze   File: LogBlockDebugTab.py    License: GNU General Public License v2.0 6 votes vote down vote up
def _update_tree(self, conf, value):
        """Update the block tree"""
        self._block_tree.clear()
        for block in self._helper.cf.log.log_blocks:
            item = QtWidgets.QTreeWidgetItem()
            item.setFlags(Qt.ItemIsEnabled |
                          Qt.ItemIsSelectable)
            item.setData(0, Qt.DisplayRole, block.id)
            item.setData(1, Qt.EditRole, block.name)
            item.setData(2, Qt.DisplayRole, (block.period_in_ms))
            item.setData(3, Qt.DisplayRole, block.added)
            item.setData(4, Qt.EditRole, block.started)
            item.setData(5, Qt.EditRole, block.err_no)
            for var in block.variables:
                subItem = QtWidgets.QTreeWidgetItem()
                subItem.setFlags(Qt.ItemIsEnabled |
                                 Qt.ItemIsSelectable)
                subItem.setData(6, Qt.EditRole, var.name)
                item.addChild(subItem)

            self._block_tree.addTopLevelItem(item)
            self._block_tree.expandItem(item) 
Example 28
Project: tdm   Author: jziolkowski   File: Telemetry.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_nested_item(self, parent, name):
        nested_items = self.tree_items.get(parent)
        if nested_items:
            _top_item = nested_items["_top_item"]
            item = nested_items.get(name)
            if not item:
                item = QTreeWidgetItem()
                item.setText(0, name)
                item.setIcon(0, QIcon("GUI/icons/{}".format(item_icons.get(name, ""))))
                _top_item.addChild(item)
                nested_items[name] = item
            return item
        else:
            _top_item = QTreeWidgetItem()
            _top_item.setText(0, parent)
            self.tree.addTopLevelItem(_top_item)
            self.tree_items[parent] = {"_top_item": _top_item}

            item = QTreeWidgetItem()
            item.setText(0, name)
            _top_item.addChild(item)
            self.tree_items[parent][name] = item
            return item 
Example 29
Project: idasec   Author: RobinDavid   File: idasec.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def log(self, type, message, origin="IDASec"):
        date = datetime.datetime.now().strftime("%H:%M:%S")
        res = re.match("^(\[[A-Za-z]*\])",message)
        if res:
            type = res.groups()[0]
            message = message[len(type):].lstrip()
        message = message.rstrip()
        self.log_widget.addTopLevelItem(QtWidgets.QTreeWidgetItem([date, origin, type, message]))
        self.log_widget.scrollToBottom()


################################################################################
# Usage as plugin
################################################################################ 
Example 30
Project: idasec   Author: RobinDavid   File: TraceWidget.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnCreate(self, _):
        self.setupUi(self)
        self.add_trace_button.clicked.connect(self.load_trace)
        self.disassemble_button.clicked.connect(self.disassemble_from_trace)
        self.colorize_button.clicked.connect(self.colorize_trace)
        self.heatmap_button.clicked.connect(self.heatmap_trace)
        self.dump_button.clicked.connect(self.dump_trace)
        self.refresh_button.clicked.connect(self.refresh_trace_view)
        self.traces_tab.currentChanged.connect(self.trace_switch)
        self.traces_tab.tabCloseRequested.connect(self.unload_trace)
        self.loading_stat.setVisible(False)
        self.progressbar_loading.setVisible(False)
        self.traces_tab.setTabsClosable(True)
        self.reads_view.setHeaderItem(QtWidgets.QTreeWidgetItem(["name", "value"]))
        self.writes_view.setHeaderItem(QtWidgets.QTreeWidgetItem(["name", "value"]))