Python PyQt5.QtCore.QStringListModel() Examples

The following are 19 code examples for showing how to use PyQt5.QtCore.QStringListModel(). 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.QtCore , or try the search function .

Example 1
Project: Traffic-Rules-Violation-Detection   Author: rahatzamancse   File: SearchWindow.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, search_result, parent=None):
        super(SearchWindow, self).__init__(parent)
        loadUi("UI/Search.ui", self)

        self.search_result = search_result

        self.color.addItems(["None"])
        self.color.addItems(Database.get_instance().get_car_color_list())

        completer = QCompleter()
        self.substring.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        licenseList = Database.get_instance().get_licenses()
        model.setStringList(licenseList)

        self.search_button.clicked.connect(self.search)

        cams = Database.get_instance().get_cam_list(None)
        self.camera.clear()
        self.camera.addItems(["None"])
        self.camera.addItems(id for id, cam, feed in cams)
        self.camera.setCurrentIndex(0) 
Example 2
Project: IDAngr   Author: andreafioraldi   File: main_gui.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self, folder, title):
        QtWidgets.QDialog.__init__(self)
        
        self.ui = Ui_IDAngrSavedsDialog()
        self.ui.setupUi(self)
        
        self.setWindowTitle(title)
        self.h = PythonHighlighter(self.ui.codeView.document())
        
        self.folder = folder
        self.files_list = []
        for path in glob.glob(os.path.join(folder, "*.py")):
            self.files_list.append(os.path.basename(path)[:-3])
        
        self.ui.selectorList.setModel(QtCore.QStringListModel(self.files_list))
        self.model = self.ui.selectorList.selectionModel()
        self.model.selectionChanged.connect(self.selector_clicked) 
Example 3
Project: uPyLoader   Author: BetaRavener   File: main_window.py    License: MIT License 6 votes vote down vote up
def list_mcu_files(self):
        file_list = []
        try:
            file_list = self._connection.list_files()
        except OperationError:
            QMessageBox().critical(self, "Operation failed", "Could not list files.", QMessageBox.Ok)
            return

        self._mcu_files_model = QStringListModel()

        for file in file_list:
            idx = self._mcu_files_model.rowCount()
            self._mcu_files_model.insertRow(idx)
            self._mcu_files_model.setData(self._mcu_files_model.index(idx), file)

        self.mcuFilesListView.setModel(self._mcu_files_model)
        self.mcu_file_selection_changed() 
Example 4
def __init__(self, search_result, parent=None):
        super(SearchWindow, self).__init__(parent)
        loadUi("UI/Search.ui", self)

        self.search_result = search_result

        self.color.addItems(["None"])
        self.color.addItems(Database.getInstance().getCarColorsList())

        completer = QCompleter()
        self.substring.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        licenseList = Database.getInstance().getLicenseList()
        model.setStringList(licenseList)

        self.search_button.clicked.connect(self.search)

        cams = Database.getInstance().getCamList(None)
        self.camera.clear()
        self.camera.addItems(["None"])
        self.camera.addItems(id for id, cam, feed in cams)
        self.camera.setCurrentIndex(0) 
Example 5
Project: tdm   Author: jziolkowski   File: Console.py    License: GNU General Public License v3.0 6 votes vote down vote up
def eventFilter(self, obj, e):
        if obj == self.command and e.type() == QEvent.KeyPress:
            history = self.device.history
            if e.modifiers() & Qt.ControlModifier:
                if e.key() == Qt.Key_H:
                    d = DeviceConsoleHistory(self.device.env.devices)
                    if d.exec_() == QDialog.Accepted:
                        self.command.setText(d.command)

                elif len(history) > 0:
                    if e.key() == Qt.Key_E:
                        self.command.setText(history[0])

                    if e.key() == Qt.Key_Down:
                        self.command.completer().setModel(QStringListModel(history))
                        self.command.setText(' ')
                        self.command.completer().complete()
            return False

        return QDockWidget.eventFilter(self, obj, e) 
Example 6
Project: ANGRYsearch   Author: DoTheEvo   File: angrysearch.py    License: GNU General Public License v2.0 5 votes vote down vote up
def tutorial(self):
        self.center.search_input.setDisabled(True)
        conf_file = self.settings.fileName()
        chat = [
            '   • config file is in {}'.format(conf_file),
            '   • database is in {}/angrysearch/angry_database.db'.format(
                  CACHE_PATH),
            '   • one million files can take ~200MB and ~2 min to index',
            '',
            '   • double-click on name opens it in associated application',
            '   • double-click on path opens the location in file manager',
            '',
            '   • checkbox in the right top corner changes search behavior',
            '   • by default checked, it provides very fast searching',
            '   • drawback is that it can\'t do word bound substrings',
            '   • it would not find "Pi<b>rate</b>s", or Whip<b>lash</b>"',
            '   • it would find "<b>Pir</b>ates", or "The-<b>Fif</b>th"',
            '   • unchecking it provides substring searches, but slower',
        ]

        self.center.table.setModel(Qc.QStringListModel(chat))
        self.center.table.setDisabled(True)
        self.status_bar.showMessage(
            'Press the update button in the top right corner')

    # CREATE INSTANCE OF UPDATE THE DATABASE DIALOG WINDOW 
Example 7
Project: uPyLoader   Author: BetaRavener   File: main_window.py    License: MIT License 5 votes vote down vote up
def execute_mcu_code(self):
        idx = self.mcuFilesListView.currentIndex()
        assert isinstance(idx, QModelIndex)
        model = self.mcuFilesListView.model()
        assert isinstance(model, QStringListModel)
        file_name = model.data(idx, Qt.EditRole)
        self._connection.run_file(file_name) 
Example 8
Project: uPyLoader   Author: BetaRavener   File: main_window.py    License: MIT License 5 votes vote down vote up
def remove_file(self):
        idx = self.mcuFilesListView.currentIndex()
        assert isinstance(idx, QModelIndex)
        model = self.mcuFilesListView.model()
        assert isinstance(model, QStringListModel)
        file_name = model.data(idx, Qt.EditRole)
        try:
            self._connection.remove_file(file_name)
        except OperationError:
            QMessageBox().critical(self, "Operation failed", "Could not remove the file.", QMessageBox.Ok)
            return
        self.list_mcu_files() 
Example 9
Project: uPyLoader   Author: BetaRavener   File: main_window.py    License: MIT License 5 votes vote down vote up
def read_mcu_file(self, idx):
        assert isinstance(idx, QModelIndex)
        model = self.mcuFilesListView.model()
        assert isinstance(model, QStringListModel)
        file_name = model.data(idx, Qt.EditRole)

        progress_dlg = FileTransferDialog(FileTransferDialog.DOWNLOAD)
        progress_dlg.finished.connect(lambda: self.finished_read_mcu_file(file_name, progress_dlg.transfer))
        progress_dlg.show()
        self._connection.read_file(file_name, progress_dlg.transfer) 
Example 10
Project: uPyLoader   Author: BetaRavener   File: main_window.py    License: MIT License 5 votes vote down vote up
def transfer_to_pc(self):
        idx = self.mcuFilesListView.currentIndex()
        assert isinstance(idx, QModelIndex)
        model = self.mcuFilesListView.model()
        assert isinstance(model, QStringListModel)
        remote_path = model.data(idx, Qt.EditRole)
        local_path = self.localPathEdit.text() + "/" + remote_path

        progress_dlg = FileTransferDialog(FileTransferDialog.DOWNLOAD)
        progress_dlg.finished.connect(lambda: self.finished_transfer_to_pc(local_path, progress_dlg.transfer))
        progress_dlg.show()
        self._connection.read_file(remote_path, progress_dlg.transfer) 
Example 11
Project: KStock   Author: aseylys   File: Helpers.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, ticks, parent = None):
        QtWidgets.QDialog.__init__(self, parent)

        self.setupUi(self)
        completer = QtWidgets.QCompleter()
        completer.setCaseSensitivity(False)
        self.tickEdit.setCompleter(completer)

        model = QtCore.QStringListModel()
        completer.setModel(model)
        model.setStringList(ticks)

        self.okBut.clicked.connect(self.accept)
        self.cancelBut.clicked.connect(self.close) 
Example 12
Project: dash-masternode-tool   Author: Bertrand256   File: hw_word_dlg.py    License: MIT License 5 votes vote down vote up
def setupUi(self):
        ui_hw_word_dlg.Ui_HardwareWalletWordDlg.setupUi(self, self)
        self.setWindowTitle('')
        self.lblWord.setText(self.message)
        self.setWindowTitle('Get word')
        model = QStringListModel()
        model.setStringList(self.wordlist)
        self.completer = QCompleter()
        self.completer.setModel(model)
        self.edtWord.setCompleter(self.completer)
        self.layout().setSizeConstraint(QLayout.SetFixedSize) 
Example 13
Project: grap   Author: AirbusCyber   File: QtShim.py    License: MIT License 5 votes vote down vote up
def get_QStringListModel():
    """QStringListModel getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QStringListModel
    except ImportError:
        import PyQt5.QtCore as QtCore
        return QtCore.QStringListModel 
Example 14
Project: pandasgui   Author: adamerose   File: extended_combobox.py    License: MIT License 5 votes vote down vote up
def __init__(self, string_list, parent=None):
        super(ExtendedComboBox, self).__init__(parent)

        self.setFocusPolicy(Qt.StrongFocus)
        self.setEditable(True)

        # add a filter model to filter matching items
        self.pFilterModel = QSortFilterProxyModel(self)
        self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.pFilterModel.setSourceModel(self.model())

        # add a completer, which uses the filter model
        self.completer = QCompleter(self.pFilterModel, self)
        # always show all (filtered) completions
        self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.setCompleter(self.completer)

        # connect signals
        self.lineEdit().textEdited.connect(self.pFilterModel.setFilterFixedString)
        self.completer.activated.connect(self.on_completer_activated)

        # either fill the standard model of the combobox
        self.addItems(string_list)

        # or use another model
        # combo.setModel(QStringListModel(string_list))

    # on selection of an item from the completer, select the corresponding item from combobox 
Example 15
Project: deen   Author: takeshixx   File: core.py    License: Apache License 2.0 5 votes vote down vote up
def fuzzy_search_action(self):
        """Open a dialog for quick access to actions
        with fuzzy search."""
        focussed_widget = QApplication.focusWidget()
        self.fuzzy_search_ui.ui.fuzzy_search_field.setFocus()
        def get_data(model):
            plugins = [x[1].name for x in self.plugins.available_plugins]
            for p in self.plugins.codecs + \
                     self.plugins.compressions +\
                     self.plugins.assemblies:
                plugins.append('-' + p[1].name)
                plugins.extend(['-' + x for x in p[1].aliases])
            for p in self.plugins.available_plugins:
                plugins.extend(p[1].aliases)
            model.setStringList(plugins)
        completer = QCompleter()
        self.fuzzy_search_ui.ui.fuzzy_search_field.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        get_data(model)
        if self.fuzzy_search_ui.exec_() == 0:
            return
        search_data = self.fuzzy_search_ui.ui.fuzzy_search_field.text()
        parent_encoder = self.get_parent_encoder(focussed_widget)
        if parent_encoder:
            parent_encoder.action_fuzzy(search_data)
        else:
            LOGGER.error('Unable to find parent encoder for ' + str(focussed_widget)) 
Example 16
Project: tdm   Author: jziolkowski   File: Console.py    License: GNU General Public License v3.0 5 votes vote down vote up
def command_changed(self, text):
        if text == "":
            self.command.completer().setModel(QStringListModel(sorted(commands))) 
Example 17
Project: controleEstoque   Author: andrersp   File: financeiro.py    License: MIT License 5 votes vote down vote up
def setAutocompleteFinanceiro(self):
        # Setando Auto complete
        self.completer = QCompleter(self)
        self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.completer.setCompletionMode(QCompleter.PopupCompletion)
        self.model = QtCore.QStringListModel(self)
        self.completer.setModel(self.model)
        self.tx_NomeFantasia.setCompleter(self.completer) 
Example 18
Project: controleEstoque   Author: andrersp   File: comercial.py    License: MIT License 5 votes vote down vote up
def setAutocomplete(self):
        # Setando Auto complete
        self.completer = QCompleter(self)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.completer.setCompletionMode(QCompleter.PopupCompletion)
        self.model = QStringListModel(self)
        self.completer.setModel(self.model)
        self.tx_BuscaItem.setCompleter(self.completer)
        self.tx_NomeFantasia.setCompleter(self.completer)

    # AutoComplete Produtos 
Example 19
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: list_models.py    License: MIT License 4 votes vote down vote up
def __init__(self):
        """MainWindow constructor.

        This widget will be our main window.
        We'll define all the UI components in here.
        """
        super().__init__()
        # Main UI code goes here
        self.setLayout(qtw.QVBoxLayout())

        data = [
            'Hamburger', 'Cheeseburger',
            'Chicken Nuggets', 'Hot Dog', 'Fish Sandwich'
        ]

        listwidget = qtw.QListWidget()
        listwidget.addItems(data)
        combobox = qtw.QComboBox()
        combobox.addItems(data)
        self.layout().addWidget(listwidget)
        self.layout().addWidget(combobox)

        # make the list widget editable
        for i in range(listwidget.count()):
            item = listwidget.item(i)
            item.setFlags(item.flags() | qtc.Qt.ItemIsEditable)


        # The same, but with a model

        model = qtc.QStringListModel(data)

        listview = qtw.QListView()
        listview.setModel(model)
        model_combobox = qtw.QComboBox()
        model_combobox.setModel(model)

        self.layout().addWidget(listview)
        self.layout().addWidget(model_combobox)

        # End main UI code
        self.show()