Python PyQt5.QtWidgets.QTreeView() Examples

The following are code examples for showing how to use PyQt5.QtWidgets.QTreeView(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    GNU General Public License v3.0 6 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 2
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    GNU General Public License v3.0 6 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 3
Project: eddy   Author: obdasystems   File: ontology_explorer.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, widget):
        """
        Initialize the ontology explorer view.
        :type widget: OntologyExplorerWidget
        """
        super().__init__(widget)
        self.startPos = None
        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 4
Project: eddy   Author: obdasystems   File: project_explorer.py    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 5
Project: eddy   Author: obdasystems   File: Explanation_explorer.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, widget):
        """
        Initialize the Explanation explorer view.
        :type widget: ExplanationExplorerWidget
        """
        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 6
Project: eddy   Author: obdasystems   File: Unsatisfiable_Entity_Explorer.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, widget):
        """
        Initialize the UnsatisfiableEntitiesExplorer view.
        :type widget: UnsatisfiableEntityExplorerWidget
        """
        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
Project: PyRHEED   Author: yux1991   File: browser.py    MIT License 6 votes vote down vote up
def init_UI(self,path=QtCore.QDir.currentPath()):
        self.model = QtWidgets.QFileSystemModel()
        self.model.setRootPath(path)
        self.model.setNameFilters(self.filter)
        self.model.setNameFilterDisables(False)
        self.tree = QtWidgets.QTreeView()
        self.tree.setModel(self.model)
        self.tree.setRootIndex(self.model.index(path))
        self.tree.setAnimated(False)
        self.tree.setIndentation(20)
        self.tree.setSortingEnabled(True)
        self.tree.sortByColumn(0,QtCore.Qt.AscendingOrder)
        self.tree.setColumnWidth(0,200)
        self.tree.setColumnWidth(1,100)
        self.tree.setColumnWidth(2,100)
        self.tree.doubleClicked.connect(self.open_file)
        self.UIgrid = QtWidgets.QGridLayout()
        self.UIgrid.addWidget(self.tree,0,0)
        self.UIgrid.setContentsMargins(0,0,2,0)
        self.setLayout(self.UIgrid)
        self.show() 
Example 8
Project: gaitutils   Author: jjnurminen   File: qt_dialogs.py    GNU General Public License v3.0 6 votes vote down vote up
def qt_dir_chooser():
    """Selector dialog to select dir (or multiple dirs). Always returns a list
    (empty if dialog was canceled)"""
    # native dialog - single dir only
    dir = QtWidgets.QFileDialog.getExistingDirectory(None, 'Select session')
    return [dir] if dir else list()
    # non-native dialog - multiple dirs. a bit messy, currently not in use
    file_dialog = QtWidgets.QFileDialog()
    file_dialog.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
    file_dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
    file_view = file_dialog.findChild(QtWidgets.QListView, 'listView')
    if file_view:
        file_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
    f_tree_view = file_dialog.findChild(QtWidgets.QTreeView)
    if f_tree_view:
        f_tree_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
    return file_dialog.selectedFiles() if file_dialog.exec_() else [] 
Example 9
Project: OnkoDICOM   Author: didymo   File: Add_On_Options.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def create_table_view(self):
        """
        Create a table to hold all the windowing options.
        """
        self.window.table_view = QtWidgets.QTableWidget(self.window.widget)
        # self.window.table_view.setFixedHeight(370)
        self.window.table_view.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.window.table_view.setColumnCount(4)
        self.window.table_view.setHorizontalHeaderLabels([" Window Name ", " Scan ", " Window ", " Level "])
        self.window.table_view.horizontalHeaderItem(0).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_view.horizontalHeaderItem(1).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_view.horizontalHeaderItem(2).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_view.horizontalHeaderItem(3).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_view.verticalHeader().hide()
        header1 = self.window.table_view.horizontalHeader()
        header1.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
        header1.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
        header1.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
        header1.setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch)
        self.window.table_view.setVisible(False)
        #removing the ability to edit tables with immediate click
        self.window.table_view.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers) 
Example 10
Project: OnkoDICOM   Author: didymo   File: Add_On_Options.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def create_table_view(self):
        """
        Create a table to hold all the standard organ entries.
        """
        self.window.table_organ = QtWidgets.QTableWidget(self.window.widget)
        # self.window.table_organ.setFixedHeight(370)
        self.window.table_organ.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.window.table_organ.setColumnCount(4)
        self.window.table_organ.setHorizontalHeaderLabels([" Standard Name ", " FMA ID ", " Organ ", " Url "])
        self.window.table_organ.horizontalHeaderItem(0).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_organ.horizontalHeaderItem(1).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_organ.horizontalHeaderItem(2).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_organ.horizontalHeaderItem(3).setTextAlignment(QtCore.Qt.AlignLeft)

        header2 = self.window.table_organ.horizontalHeader()
        header2.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
        header2.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
        header2.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
        header2.setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch)
        self.window.table_organ.setVisible(False)
        self.window.table_organ.verticalHeader().hide()
        #removing the ability to edit tables with immediate click
        self.window.table_organ.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers) 
Example 11
Project: OnkoDICOM   Author: didymo   File: Add_On_Options.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def create_table_view(self):
        """
        Create a table to hold the volume entries.
        """
        self.window.table_volume = QtWidgets.QTableWidget(self.window.widget)
        # self.window.table_volume.setFixedHeight(370)
        self.window.table_volume.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.window.table_volume.setColumnCount(2)
        self.window.table_volume.setHorizontalHeaderLabels([" Standard Name ", " Volume Name"])
        self.window.table_volume.horizontalHeaderItem(0).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_volume.horizontalHeaderItem(1).setTextAlignment(QtCore.Qt.AlignLeft)
        header3 = self.window.table_volume.horizontalHeader()
        self.window.table_volume.verticalHeader().hide()
        header3.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
        header3.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
        self.window.table_volume.setVisible(False)
        #removing the ability to edit tables with immediate click
        self.window.table_volume.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers) 
Example 12
Project: OnkoDICOM   Author: didymo   File: Add_On_Options.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def create_table_view(self):
        """
        Create a table to hold all the ROI creation by isodose entries.
        """
        self.window.table_roi = QtWidgets.QTableWidget(self.window.widget)
        # self.window.table_roi.setFixedHeight(370)
        self.window.table_roi.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.window.table_roi.setColumnCount(3)
        self.window.table_roi.verticalHeader().hide()
        self.window.table_roi.setHorizontalHeaderLabels([" Isodose Level (cGy) ", " ROI Name ", " Notes "])
        self.window.table_roi.horizontalHeaderItem(0).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_roi.horizontalHeaderItem(1).setTextAlignment(QtCore.Qt.AlignLeft)
        self.window.table_roi.horizontalHeaderItem(2).setTextAlignment(QtCore.Qt.AlignLeft)
        header4 = self.window.table_roi.horizontalHeader()
        header4.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
        header4.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
        header4.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
        self.window.table_roi.setVisible(False)
        # removing the ability to edit tables with immediate click
        self.window.table_roi.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers) 
Example 13
Project: eddy   Author: danielepantaleone   File: ontology_explorer.py    GNU General Public License v3.0 6 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 14
Project: eddy   Author: danielepantaleone   File: project_explorer.py    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 15
Project: fb2mobi   Author: rupor-github   File: OpenGDriveDialog.py    MIT License 6 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 16
Project: cct   Author: awacha   File: calibration.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def onRemovePair(self):
        assert isinstance(self.pairsTreeView, QtWidgets.QTreeView)
        try:
            idx = self.pairsTreeView.selectedIndexes()[0]
            self.pairsStore.removePair(idx.row())
        except IndexError:
            pass
        self.recalculateDistance() 
Example 17
Project: cct   Author: awacha   File: accounting.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setupUi(self, DockWidget):
        assert not self._accountingserviceconnections
        Ui_DockWidget.setupUi(self, DockWidget)
        assert isinstance(self.credo, Instrument)
        a = self.credo.services['accounting']
        assert isinstance(a, AccountingService)
        self.operatorNameLabel.setText(a.get_user().username)
        self.privilegesComboBox.clear()
        self.privilegesComboBox.addItems(a.get_accessible_privlevels_str())
        self.onPrivilegeChanged(a, a.get_privilegelevel())
        self.privilegesComboBox.currentTextChanged.connect(self.onPrivilegeChange)
        self.onProjectChanged(a)
        self.projectsModel = ProjectsModel(self.credo)
        self.projectsView = QtWidgets.QTreeView(self.projectIDComboBox)
        self.projectsView.setRootIsDecorated(False)
        self.projectsView.setHeaderHidden(True)
        self.projectsView.setAllColumnsShowFocus(True)
        self.projectsView.setAlternatingRowColors(True)
        self.projectsView.setWordWrap(True)
        self.projectsView.resizeColumnToContents(0)
        self.projectsView.resizeColumnToContents(1)
        self.projectsView.setMinimumWidth(300)
        self.projectIDComboBox.setModel(self.projectsModel)
        self.projectIDComboBox.setView(self.projectsView)
        self.projectIDComboBox.setSizeAdjustPolicy(self.projectIDComboBox.AdjustToContents)
        self.projectIDComboBox.setModelColumn(0)
        self.projectIDComboBox.currentIndexChanged.connect(self.onProjectChange)
        self.onProjectChanged(a)
        self._accountingserviceconnections = [
            a.connect('privlevel-changed', self.onPrivilegeChanged),
            a.connect('project-changed', self.onProjectChanged)
        ] 
Example 18
Project: Lector   Author: BasioMeusPuga   File: contentwidgets.py    GNU General Public License v3.0 5 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 19
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    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.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() 
Example 20
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_L1_gui(self):
        """ Edit L1 control file GUI."""
        # get a QTreeView and a standard model
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        #self.tree = custom_treeview()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        # do the QTreeView layout
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # set some features of the QTreeView
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        # set the QTreeView model
        self.view.setModel(self.model)
        # enable drag and drop
        #self.view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 200)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 21
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_L2_gui(self):
        """ Edit L2 control file GUI."""
        # get a QTreeView and a standard model
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        # set the QTreeView model
        self.view.setModel(self.model)
        # enable drag and drop
        #self.view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 200)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 22
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_L3_gui(self):
        """ Edit L3 control file GUI."""
        # get a QTreeView and a standard model
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.view.setModel(self.model)
        # enable drag and drop
        #self.view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 200)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 23
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_concatenate_gui(self):
        """ Edit a concatenate control file GUI."""
        # get a QTreeView
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.view.setModel(self.model)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 200)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 24
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_l4_gui(self):
        """ Edit an L4 control file GUI."""
        # get a QTreeView
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.view.setModel(self.model)
        # enable drag and drop
        #self.view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 210)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 25
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_l6_gui(self):
        """ Edit an L6 control file GUI."""
        # get a QTreeView
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.view.setModel(self.model)
        # enable drag and drop
        #self.view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 200)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 26
Project: PyFluxPro   Author: OzFlux   File: pfp_gui.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edit_nc2csv_ecostress_gui(self):
        """ Edit an nc2csv_ecostress control file GUI."""
        # get a QTreeView
        self.view = QtWidgets.QTreeView()
        self.model = QtGui.QStandardItemModel()
        # set the context menu policy
        self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # connect the context menu requested signal to appropriate slot
        self.view.customContextMenuRequested.connect(self.context_menu)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.view)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 600, 400)
        # Tree view
        self.view.setAlternatingRowColors(True)
        #self.tree.setSortingEnabled(True)
        self.view.setHeaderHidden(False)
        self.view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.view.setModel(self.model)
        #self.tree.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
        # build the model
        self.get_model_from_data()
        # set the default width for the first column
        self.view.setColumnWidth(0, 210)
        # expand the top level of the sections
        for row in range(self.model.rowCount()):
            idx = self.model.index(row, 0)
            self.view.expand(idx) 
Example 27
Project: radie   Author: dvincentwest   File: plotlist.py    GNU General Public License v2.0 5 votes vote down vote up
def dropEvent(self, event: QtGui.QDropEvent):
        source = event.source()  # type: QtWidgets.QAbstractItemView
        if source is self:  # internal move operation
            super(DFListView, self).dropEvent(event)
            pos = event.pos()
            dropIndex = source.indexAt(pos)
            source.model().internalMove(dropIndex, source.selectionModel().selectedRows(0))
        else:
            if isinstance(source, QtWidgets.QTreeView):
                invalid_drops = []
                valid_drops = []
                for index in source.selectionModel().selectedRows(column=0):  # type: QtCore.QModelIndex
                    pointer = index.internalPointer()  # type: DFReference
                    if self.isSupported(pointer):
                        valid_drops.append(pointer)
                    elif isinstance(pointer, DFReference):
                        invalid_drops.append(pointer.df.__class__.__name__)
                    else:
                        continue

                if valid_drops:
                    self.addDataFrames(*valid_drops)

                if invalid_drops:
                    fn.error_popup(
                        "Invalid StructuredDataFrame types: \n\t" + "\n\t".join(invalid_drops) +
                        "\n\nOnly DataFrames of the following types are allowed:\n\t" +
                        "\n\t".join(cls.__name__ for cls in self.supportedClasses)
                    ) 
Example 28
Project: OnkoDICOM   Author: didymo   File: Add_On_Options.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def init_tree_list(self):
        """
        Create a tree view that holds the different options.
        """
        self.treeList = QtWidgets.QTreeView(self.widget)
        self.treeList.setGeometry(QtCore.QRect(10, 40, 256, 461))
        self.treeList.setStyleSheet("QTreeView::item { padding: 10px }")
        self.treeList.setHeaderHidden(True)
        #Triggering the view change according to the row selected in the tree
        self.treeList.clicked.connect(self.display)
        self.treeList.setMaximumWidth(250) 
Example 29
Project: OnkoDICOM   Author: didymo   File: DicomTree.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def init_tree(self):
		"""
		:return: An initial tree.
		"""
		self.treeView = QtWidgets.QTreeView(self.window.tab2_DICOM_tree)
		self.treeView.setFocusPolicy(QtCore.Qt.NoFocus)
		self.init_headers_tree()
		self.init_parameters_tree() 
Example 30
Project: OnkoDICOM   Author: didymo   File: test_tree.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def display(self, model):
        app = QApplication.instance()

        # create QApplication if it doesnt exist
        if not app:
            app = QApplication(sys.argv)
        tree = QTreeView()
        tree.setModel(model)
        tree.show()
        app.exec_()
        return tree 
Example 31
Project: mhw_armor_edit   Author: fre-sch   File: treeview.py    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 32
Project: Hydra   Author: CountryTk   File: Directory.py    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 33
Project: event_signal   Author: justengel   File: qt_binder.py    MIT License 5 votes vote down vote up
def get_widget_value(widget):
    """Return the desired value from a widget."""
    if isinstance(widget, QtWidgets.QAbstractButton):
        return widget.isChecked()

    elif isinstance(widget, QtWidgets.QTreeView):
        return widget.selectedData()

    elif isinstance(widget, QtWidgets.QComboBox):
        item_data = widget.itemData(widget.currentIndex())
        if item_data is not None:
            return item_data
        else:
            return widget.currentText()

    elif isinstance(widget, QtWidgets.QTextEdit):
        return widget.toPlainText()

    elif hasattr(widget, "value"):
        return widget.value()

    elif not hasattr(widget, "text"):
        for item in widget.children():
            if isinstance(item, QtWidgets.QLineEdit):
                return item.text()
    else:
        return widget.text() 
Example 34
Project: guppy-proxy   Author: roglew   File: reqtree.py    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 35
Project: bap-ida-python   Author: BinaryAnalysisPlatform   File: bap_trace.py    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 36
Project: Openroast   Author: Roastero   File: recipestab.py    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 37
Project: pySPM   Author: scholi   File: values_display.py    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 38
Project: cct   Author: awacha   File: calibration.py    BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def setupUi(self, MainWindow):
        Ui_MainWindow.setupUi(self, MainWindow)
        self.fsnselectorPage.setLayout(QtWidgets.QVBoxLayout())
        self.fsnSelector = FSNSelector(self.fsnselectorPage, credo=self.credo)
        self.fsnselectorPage.layout().addWidget(self.fsnSelector)
        self.tab2D.setLayout(QtWidgets.QVBoxLayout())
        self.plotImage = PlotImage(self.tab2D, register_instance=False)
        self.tab2D.layout().addWidget(self.plotImage)
        self.fsnSelector.FSNSelected.connect(self.onFSNSelected)
        self.tab1D.setLayout(QtWidgets.QVBoxLayout())
        self.plotCurve = PlotCurve(self.tab1D)
        self.tab1D.layout().addWidget(self.plotCurve)
        self.distCalibFigure = Figure()
        self.distCalibFigureCanvas = FigureCanvasQTAgg(self.distCalibFigure)
        self.tabDistance.setLayout(QtWidgets.QVBoxLayout())
        self.tabDistance.layout().addWidget(self.distCalibFigureCanvas)
        self.distCalibFigureToolbar = NavigationToolbar2QT(self.distCalibFigureCanvas, self.tabDistance)
        self.tabDistance.layout().addWidget(self.distCalibFigureToolbar)
        self.distCalibAxes = self.distCalibFigure.add_subplot(1, 1, 1)
        self.centeringMethodComboBox.addItems(
            ['Gravity', 'Peak amplitude', 'Peak width', 'Power-law', 'Manual (click)'])
        self.centeringMethodComboBox.setCurrentIndex(1)
        self.centeringPushButton.clicked.connect(self.onCenteringRequested)
        self.plotImage.setOnlyAbsPixel()
        self.beamXDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.beamYDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.sdDistDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.beamXErrDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.beamYErrDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.sdDistErrDoubleSpinBox.valueChanged.connect(self.onDoubleSpinBoxValueChanged)
        self.saveBeamXPushButton.clicked.connect(self.onSaveResult)
        self.saveBeamYPushButton.clicked.connect(self.onSaveResult)
        self.saveSDDistPushButton.clicked.connect(self.onSaveResult)
        self.fitLorentzPushButton.clicked.connect(self.onLorentzFit)
        self.fitGaussPushButton.clicked.connect(self.onGaussFit)
        self.calibrantComboBox.addItems(sorted(self.credo.config['calibrants']))
        self.calibrantComboBox.currentIndexChanged.connect(self.onCalibrantChanged)
        self.addPairPushButton.clicked.connect(self.onAddPair)
        self.removePairPushButton.clicked.connect(self.onRemovePair)
        self.peakComboBox.currentIndexChanged.connect(self.onPeakChosen)
        self.calibrantComboBox.setCurrentIndex(0)
        self.onCalibrantChanged()
        assert isinstance(self.pairsTreeView, QtWidgets.QTreeView)
        self.pairsStore = PairStore()
        self.pairsTreeView.setModel(self.pairsStore)
        self.distCalibFigureCanvas.mpl_connect('resize_event', self.onCanvasResize) 
Example 39
Project: iot_honeypot   Author: mukund26   File: Gui5.py    MIT License 4 votes vote down vote up
def createCentralWidget(self):
       # Create table
        self.centralWidget = QSplitter(Qt.Horizontal)
        self.treeView = QTreeView()
        self.treeView.setHeaderHidden(True)
        standardModel = QStandardItemModel()
        rootNode = standardModel.invisibleRootItem()
        self.ports = QStandardItem("Local Ports")
        self.attackerIP = QStandardItem("Attacker IPs")
        self.ports.setEditable(False)
        self.attackerIP.setEditable(False)
        
        rootNode.appendRow(self.ports)
        rootNode.appendRow(self.attackerIP)
   
        self.treeView.setModel(standardModel)

 
        self.tableWidget = QTableWidget(self)
        self.tableWidget.setRowCount(1500) 
        self.tableWidget.setColumnCount(11)
        self.tableWidget.verticalHeader().setVisible(False)
        self.tableWidget.setHorizontalHeaderLabels(['Date', 'Time', 'RemoteIP', 'Remote Port', 'Direction', 'Local IP', 'Local Port', 'Protocol', 'Bytes','Country','Packet Detail'])
        self.tableWidget.setColumnWidth(0,100)
        self.tableWidget.setColumnWidth(2,self.width*0.1)
        self.tableWidget.setColumnWidth(3,self.width*0.07)
        self.tableWidget.setColumnWidth(4,self.width*0.05)
        self.tableWidget.setColumnWidth(5,self.width*0.1)
        self.tableWidget.setColumnWidth(6,self.width*0.06)
        self.tableWidget.setColumnWidth(7,self.width*0.05)
        self.tableWidget.setColumnWidth(8,self.width*0.04)
        self.tableWidget.setColumnWidth(10,self.width*0.095)
#        self.tableWidget.move(30,10)
	

        # table selection change
        self.tableWidget.doubleClicked.connect(self.on_click)
        self.treeView.setMinimumWidth(self.width*0.15)
        self.tableWidget.setMinimumWidth(self.width*0.85) 
        self.centralWidget.addWidget(self.treeView)
        self.centralWidget.addWidget(self.tableWidget)
        self.centralWidget.setMinimumHeight(self.height*0.95) 
Example 40
Project: lnls   Author: lnls-fac   File: dialog.py    MIT License 4 votes vote down vote up
def directories_dialog(path=None,name='Select Directories'):
    ok = True
    def _pressed_cancel():
        nonlocal ok
        Fi.close()
        app.quit()
        ok &= False

    path = path or CURDIR

    app = QCoreApplication.instance() or QApplication([])

    Fi = QFileDialog()
    Fi.setWindowTitle(name)
    Fi.setOption(Fi.DontUseNativeDialog, True)
    qr = Fi.frameGeometry()
    cp = QDesktopWidget().availableGeometry().center()
    qr.moveCenter(cp)
    Fi.move(qr.topLeft())

    Fi.setFileMode(Fi.DirectoryOnly)
    Fi.setDirectory(path)
    for view in Fi.findChildren((QListView,QTreeView)):
        if isinstance(view.model(), QFileSystemModel):
             view.setSelectionMode(QAbstractItemView.MultiSelection)
    for view in Fi.findChildren(QPushButton):
        if view.text().lower().startswith('&cancel'):
            view.clicked.connect(_pressed_cancel)

    Fi.show()
    app.exec_()

    # The folder selection is also selecting its parent:
    sel_files = Fi.selectedFiles()
    sel_files2 = set(sel_files)
    for fi1 in sel_files:
        for fi2 in sel_files:
            if fi2 != fi1 and fi1 in fi2:
                sel_files2 -= {fi1}
                break

    return ok, list(sel_files2)