Python PyQt5.QtWidgets.QTreeView() Examples

The following are 22 code examples of PyQt5.QtWidgets.QTreeView(). 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 also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: TreeView.py    From pyleecan with Apache License 2.0 7 votes vote down vote up
def __init__(self):
        super(QtWidgets.QTreeView, self).__init__()

        # self.__typeWidgets = {}
        # self.__typeWrappers = {}

        model = QtGui.QStandardItemModel(0, 1)
        model.setHorizontalHeaderLabels(
            ["Name", "Value", "Unit", "Class", "Description"]
        )

        self.rootNode = model.invisibleRootItem()

        self.setModel(model)
        self.setColumnWidth(0, 150)

        self.setAlternatingRowColors(True) 
Example #2
Source File: project_explorer.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, widget):
        """
        Initialize the project explorer view.
        :type widget: ProjectExplorerWidget
        """
        super().__init__(widget)
        self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
        self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
        self.setFocusPolicy(QtCore.Qt.NoFocus)
        self.setHeaderHidden(True)
        self.setHorizontalScrollMode(QtWidgets.QTreeView.ScrollPerPixel)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
        self.setSortingEnabled(True)
        self.setWordWrap(True)

    #############################################
    #   PROPERTIES
    ################################# 
Example #3
Source File: reqtree.py    From guppy-proxy with MIT License 5 votes vote down vote up
def __init__(self):
        QWidget.__init__(self)

        self.setLayout(QVBoxLayout())
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.nodes = {}
        self.tree_view = QTreeView()
        self.tree_view.header().close()
        self.root = QStandardItemModel()
        self.tree_view.setModel(self.root)
        self.layout().addWidget(self.tree_view) 
Example #4
Source File: Directory.py    From Hydra with GNU General Public License v3.0 5 votes vote down vote up
def focusOutEvent(self, event):
        # If we un focus from the QTreeView then we make the highlighted item color white
        self.palette.setColor(
            QPalette.Highlight, QColor(editor["UnfocusedHighlightColor"]).lighter()
        )
        # self.clearSelection() Uncomment this if you want to remove all highlighting when unfocused
        self.app.setPalette(self.palette) 
Example #5
Source File: multiple_file_dialog.py    From spimagine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args):
        QtWidgets.QFileDialog.__init__(self, *args)
        self.setOption(self.DontUseNativeDialog, False)
        self.setFileMode(self.ExistingFiles)
        btns = self.findChildren(QtWidgets.QPushButton)
        self.openBtn = [x for x in btns if 'open' in str(x.text()).lower()][0]
        self.openBtn.clicked.disconnect()
        self.openBtn.clicked.connect(self.openClicked)
        self.tree = self.findChild(QtWidgets.QTreeView) 
Example #6
Source File: ontology_explorer.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, widget):
        """
        Initialize the ontology explorer view.
        :type widget: OntologyExplorerWidget
        """
        super().__init__(widget)
        self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
        self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
        self.setFont(Font('Roboto', 12))
        self.setFocusPolicy(QtCore.Qt.NoFocus)
        self.setHeaderHidden(True)
        self.setHorizontalScrollMode(QtWidgets.QTreeView.ScrollPerPixel)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
        self.setSortingEnabled(True)
        self.setWordWrap(True)

    #############################################
    #   PROPERTIES
    ################################# 
Example #7
Source File: treeview.py    From mhw_armor_edit with The Unlicense 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.setWindowTitle("Treeview for nested dict/list")
        self.setGeometry(300, 300, 600, 800)
        tree_view = QTreeView()
        tree_view.setModel(TreeModel(data))
        self.setCentralWidget(tree_view) 
Example #8
Source File: OpenGDriveDialog.py    From fb2mobi with MIT License 5 votes vote down vote up
def setupUi(self, GDriveDialog):
        GDriveDialog.setObjectName("GDriveDialog")
        GDriveDialog.resize(528, 348)
        self.gridLayout = QtWidgets.QGridLayout(GDriveDialog)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.tree = QtWidgets.QTreeView(GDriveDialog)
        self.tree.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.tree.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
        self.tree.setObjectName("tree")
        self.tree.header().setVisible(False)
        self.verticalLayout.addWidget(self.tree)
        self.buttonBox = QtWidgets.QDialogButtonBox(GDriveDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Open)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

        self.retranslateUi(GDriveDialog)
        self.buttonBox.accepted.connect(GDriveDialog.accept)
        self.buttonBox.rejected.connect(GDriveDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(GDriveDialog) 
Example #9
Source File: ext_item_model.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def get_view_horizontal_header(self):
        if isinstance(self.view, QTableView):
            return self.view.horizontalHeader()
        elif isinstance(self.view, QTreeView):
            return self.view.header()
        else:
            raise Exception('Unsupported view type: %s', str(type(self.view))) 
Example #10
Source File: menu_bar.py    From CHATIMUSMAXIMUS with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, model, parent=None):
        super().__init__(parent)
        self.setWindowTitle('CHATIMUS Settings')
        self.setStyleSheet('background: black; color: white;')
        ok_button = QtWidgets.QPushButton('Ok')
        ok_button.setDefault(True)
        cancel_button = QtWidgets.QPushButton('Cancel')
        apply_button = QtWidgets.QPushButton('Apply')
        layout = QtWidgets.QVBoxLayout()
        tree_view = QtWidgets.QTreeView()
        # tree_view.setHeaderHidden(True)
        tree_view.setModel(model)
        tree_view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        tree_view.setUniformRowHeights(True)
        tree_view.setAnimated(False)
        tree_view.setAllColumnsShowFocus(True)

        tree_view.resizeColumnToContents(0)
        layout.addWidget(tree_view)

        horizontal_button_widget = QtWidgets.QWidget()
        horizontal_layout = QtWidgets.QHBoxLayout()
        horizontal_layout.addWidget(ok_button)
        horizontal_layout.addWidget(cancel_button)
        horizontal_layout.addWidget(apply_button)
        horizontal_button_widget.setLayout(horizontal_layout)

        layout.addWidget(horizontal_button_widget)

        ok_button.clicked.connect(self.done)
        cancel_button.clicked.connect(self.reject)
        # TODO: add in apply button connection

        self.setLayout(layout) 
Example #11
Source File: bap_trace.py    From bap-ida-python with MIT License 5 votes vote down vote up
def __init__(self, parent=None):
        super(IncidentView, self).__init__(parent)
        self.view = QtWidgets.QTreeView()
        self.view.setAllColumnsShowFocus(True)
        self.view.setUniformRowHeights(True)
        box = QtWidgets.QVBoxLayout()
        box.addWidget(self.view)
        self.load_trace = QtWidgets.QPushButton('&Trace')
        self.load_trace.setToolTip('Load into the Trace Window')
        self.load_trace.setEnabled(False)
        for activation_signal in [
                self.view.activated,
                self.view.entered,
                self.view.pressed]:
            activation_signal.connect(lambda _: self.update_controls_state())
        self.load_trace.clicked.connect(self.load_current_trace)
        self.view.doubleClicked.connect(self.jump_to_index)
        hbox = QtWidgets.QHBoxLayout()
        self.filter = QtWidgets.QLineEdit()
        self.filter.textChanged.connect(self.filter_model)
        filter_label = QtWidgets.QLabel('&Search')
        filter_label.setBuddy(self.filter)
        hbox.addWidget(filter_label)
        hbox.addWidget(self.filter)
        hbox.addWidget(self.load_trace)
        box.addLayout(hbox)
        self.setLayout(box)
        self.model = None
        self.proxy = None 
Example #12
Source File: recipestab.py    From Openroast with GNU General Public License v3.0 5 votes vote down vote up
def create_recipe_browser(self):
        """Creates the side panel to browse all the files in the recipe folder.
        This method also adds a button to create new recipes to the layout."""
        # Creates model with all information about the files in ./recipes
        self.model = customqtwidgets.RecipeModel()
        self.model.setRootPath(os.path.expanduser('~/Documents/Openroast/Recipes/'))

        # Create a TreeView to view the information from the model
        browser = QtWidgets.QTreeView()
        browser.setModel(self.model)
        browser.setRootIndex(self.model.index(os.path.expanduser('~/Documents/Openroast/Recipes/')))
        browser.setFocusPolicy(QtCore.Qt.NoFocus)
        browser.header().close()

        browser.setAnimated(True)
        browser.setIndentation(0)

        # Hides all the unecessary columns created by the model
        browser.setColumnHidden(0, True)
        browser.setColumnHidden(1, True)
        browser.setColumnHidden(2, True)
        browser.setColumnHidden(3, True)

        browser.clicked.connect(self.on_recipeBrowser_clicked)

        return browser 
Example #13
Source File: values_display.py    From pySPM with Apache License 2.0 5 votes vote down vote up
def __init__(self, data):
        QWidget.__init__(self)
        self.treeView = QTreeView()
        self.model = QStandardItemModel()
        self.addItems(self.model, data)
        self.treeView.setModel(self.model)
        layout = QVBoxLayout()
        layout.addWidget(self.treeView)
        self.setLayout(layout) 
Example #14
Source File: dockwidgets.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def populate_combo_box(self):
        def set_toc_position(tocTree):
            currentIndex = tocTree.currentIndex()
            required_position = currentIndex.data(QtCore.Qt.UserRole)
            self.return_focus()
            self.parent.set_content(required_position, True, True)

        # Create the Combobox / Treeview combination
        tocTree = QtWidgets.QTreeView()
        self.tocComboBox.setView(tocTree)
        self.tocComboBox.setModel(self.parent.tocModel)
        tocTree.setRootIsDecorated(False)
        tocTree.setItemsExpandable(False)
        tocTree.expandAll()

        # Set the position of the QComboBox
        self.parent.set_tocBox_index(None, self.tocComboBox)

        # Make clicking do something
        self.tocComboBox.currentIndexChanged.connect(
            lambda: set_toc_position(tocTree)) 
Example #15
Source File: dockwidgets.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        self.parent = parent
        self.parentTab = self.parent.parent

        self.searchThread = BackGroundTextSearch()
        self.searchOptionsLayout = QtWidgets.QHBoxLayout()
        self.searchTabLayout = QtWidgets.QVBoxLayout()
        self.searchTimer = QtCore.QTimer(self.parent)
        self.searchLineEdit = QtWidgets.QLineEdit(self.parent)
        self.searchBookButton = QtWidgets.QToolButton(self.parent)
        self.caseSensitiveSearchButton = QtWidgets.QToolButton(self.parent)
        self.matchWholeWordButton = QtWidgets.QToolButton(self.parent)
        self.searchResultsTreeView = QtWidgets.QTreeView(self.parent)

        self._translate = QtCore.QCoreApplication.translate
        self.search_string = self._translate('SideDock', 'Search')
        self.search_book_string = self._translate('SideDock', 'Search entire book')
        self.case_sensitive_string = self._translate('SideDock', 'Match case')
        self.match_word_string = self._translate('SideDock', 'Match word')

        self.create_widgets() 
Example #16
Source File: contentwidgets.py    From Lector with GNU General Public License v3.0 4 votes vote down vote up
def generate_combo_box_action(self, contextMenu):
        contextMenu.addSeparator()

        def set_toc_position(tocTree):
            currentIndex = tocTree.currentIndex()
            required_position = currentIndex.data(QtCore.Qt.UserRole)
            self.pw.parent.set_content(required_position, True, True)

        # Create the Combobox / Treeview combination
        tocComboBox = QtWidgets.QComboBox()
        tocTree = QtWidgets.QTreeView()
        tocComboBox.setView(tocTree)
        tocComboBox.setModel(self.pw.parent.tocModel)
        tocTree.setRootIsDecorated(False)
        tocTree.setItemsExpandable(False)
        tocTree.expandAll()

        # Set the position of the QComboBox
        self.pw.parent.set_tocBox_index(None, tocComboBox)

        # Make clicking do something
        tocComboBox.currentIndexChanged.connect(
            lambda: set_toc_position(tocTree))

        comboboxAction = QtWidgets.QWidgetAction(self.pw)
        comboboxAction.setDefaultWidget(tocComboBox)
        contextMenu.addAction(comboboxAction) 
Example #17
Source File: media_library.py    From code-jam-5 with MIT License 4 votes vote down vote up
def init_ui(self):

        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)

        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(0)

        self.title_frame = QtWidgets.QFrame()
        self.title_frame.setStyleSheet('background: #57bd4f;'
                                       'border-top-left-radius: 6px;'
                                       'border-top-right-radius: 6px;'
                                       'color: white;')

        self.title_layout = QtWidgets.QHBoxLayout()
        self.title_frame.setLayout(self.title_layout)
        self.layout().addWidget(self.title_frame)

        self.library_frame = QtWidgets.QFrame()
        self.library_frame.setStyleSheet('background: #78543b;'
                                         'border-bottom-left-radius: 6px;'
                                         'border-bottom-right-radius: 6px;'
                                         'color: white;')
        self.library_layout = QtWidgets.QVBoxLayout()
        self.library_frame.setLayout(self.library_layout)
        self.layout().addWidget(self.library_frame)

        title_font = QtGui.QFont('Raleway', 16)
        title_font.setBold(True)

        self.media_library_title = QtWidgets.QLabel('Media Library')
        self.media_library_title.setFont(title_font)

        self.title_layout.addWidget(self.media_library_title)

        self.filesystem_model = QtWidgets.QFileSystemModel()
        self.filesystem_model.setNameFilters(['*.mp3', '*.m4a', '*.wav', '*.m3u', '*.ogg', '*.wma'])
        self.filesystem_model.setNameFilterDisables(False)
        self.filesystem_model.setFilter(QtCore.QDir.AllEntries | QtCore.QDir.NoDotAndDotDot)

        self.music_tree = QtWidgets.QTreeView(self)
        self.music_tree.setModel(self.filesystem_model)

        self.music_tree.hideColumn(1)  # Size Column
        self.music_tree.hideColumn(2)  # Type Column
        self.music_tree.hideColumn(3)  # Date Modified Column

        self.music_tree.setObjectName('music_library')
        self.music_tree.setHeaderHidden(True)

        # Add slot
        self.music_tree.activated.connect(self.item_clicked)

        # Add widget
        self.library_layout.addWidget(self.music_tree)

        self.change_path_button = QtWidgets.QPushButton('Change Path')
        self.library_layout.addWidget(self.change_path_button)
        self.change_path_button.clicked.connect(self.choose_path) 
Example #18
Source File: ValueViewEx.py    From DIE with MIT License 4 votes vote down vote up
def OnCreate(self, form):
        """
        Called when the view is created
        """
        self.die_db = DIE.Lib.DIEDb.get_db()
        self.function_view = DIE.UI.FunctionViewEx.get_view()

        # Get parent widget
        self.parent = self.FormToPyQtWidget(form)

        self.valueModel = QtGui.QStandardItemModel()
        self.valueTreeView = QtWidgets.QTreeView()
        self.valueTreeView.setExpandsOnDoubleClick(False)

        self.valueTreeView.doubleClicked.connect(self.itemDoubleClickSlot)

        self._model_builder(self.valueModel)
        self.valueTreeView.setModel(self.valueModel)

        # Toolbar
        self.value_toolbar = QtWidgets.QToolBar()

        # Value type combobox
        type_list = []
        if self.die_db:
            type_list = self.die_db.get_all_value_types()
            type_list.insert(0, "All Values")

        self.value_type_combo = QtWidgets.QComboBox()
        self.value_type_combo.addItems(type_list)
        self.value_type_combo.activated[str].connect(self.on_value_type_combobox_change)

        self.value_type_label = QtWidgets.QLabel("Value Type:  ")
        self.value_toolbar.addWidget(self.value_type_label)
        self.value_toolbar.addWidget(self.value_type_combo)

        # Layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.value_toolbar)
        layout.addWidget(self.valueTreeView)

        self.parent.setLayout(layout) 
Example #19
Source File: window_ui.py    From detection with GNU General Public License v2.0 4 votes vote down vote up
def widgetTree(self):
        """Create selected objects tree.
        """
        tree = QTreeView()
        tree.header().setHidden(True)
        tree.setDragEnabled(True)
        tree.setSelectionMode(QAbstractItemView.ExtendedSelection)
        tree.setDefaultDropAction(QtCore.Qt.MoveAction)
        tree.setDragDropMode(QAbstractItemView.InternalMove)
        tree.setAcceptDrops(True)
        tree.setDropIndicatorShown(True)
        return tree 
Example #20
Source File: window_ui.py    From detection with GNU General Public License v2.0 4 votes vote down vote up
def selectionChanged(self, *args, **kwds):
        self.customSelectionChanged.emit(*args, **kwds)
        super(QTreeView, self).selectionChanged(*args, **kwds) 
Example #21
Source File: window_ui.py    From detection with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self):
        super(QTreeView, self).__init__() 
Example #22
Source File: dockwidgets.py    From Lector with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent):
        self.parent = parent
        self.parentTab = self.parent.parent
        self.bookmarkTreeView = QtWidgets.QTreeView(self.parent)

        self._translate = QtCore.QCoreApplication.translate
        self.bookmarks_string = self._translate('SideDock', 'Bookmarks')
        self.bookmark_default = self._translate('SideDock', 'New bookmark')

        self.create_widgets()