Exemple #1
0
 def SetItems(parentItem, fictiveObjects, level):
     level += 1
     for object in fictiveObjects:
         type = object.type
         if not type in showTypes:
             continue
         # Construct text
         if type in ('cell', '##', '#%%', '# %%'):
             type = 'cell:'
         elif type == 'attribute':
             type = 'attr'
         #
         if type == 'import':
             text = "%s (%s)" % (object.name, object.text)
         elif type == 'todo':
             text = object.name
         else:
             text = "%s %s" % (type, object.name)
         # Create item
         thisItem = QtGui.QTreeWidgetItem(parentItem, [text])
         color = QtGui.QColor(colours[object.type])
         thisItem.setForeground(0, QtGui.QBrush(color))
         font = thisItem.font(0)
         font.setBold(True)
         thisItem.setFont(0, font)
         thisItem.linenr = object.linenr
         # Is this the current item?
         if ln and object.linenr <= ln and object.linenr2 > ln:
             selectedItem[0] = thisItem
         # Any children that we should display?
         if object.children:
             SetItems(thisItem, object.children, level)
         # Set visibility
         thisItem.setExpanded(bool(level < showLevel))
Exemple #2
0
    def onEditorsCurrentChanged(self):
        """ Notify that the file is being parsed and make
        sure that not the structure of a previously selected
        file is shown. """

        # Get editor and clear list
        editor = pyzo.editors.getCurrentEditor()
        self._tree.clear()

        if editor is None:
            # Set editor id
            self._currentEditorId = 0

        if editor is not None:
            # Set editor id
            self._currentEditorId = id(editor)

            # Notify
            text = translate('pyzoSourceStructure',
                             'Parsing ' + editor._name + ' ...')
            thisItem = QtGui.QTreeWidgetItem(self._tree, [text])

            # Try getting the  structure right now
            self.updateStructure()