def __create_filter_ui(self): """ Create filter widgets """ filter_layout = QHBoxLayout() filter_layout.setSpacing(1) filter_layout.setContentsMargins(0, 0, 0, 0) self.filter_reset_btn = QPushButton() icon = QIcon(':/filtersOff.png') self.filter_reset_btn.setIcon(icon) self.filter_reset_btn.setIconSize(QSize(22, 22)) self.filter_reset_btn.setFixedSize(24, 24) self.filter_reset_btn.setToolTip('Reset filter') self.filter_reset_btn.setFlat(True) self.filter_reset_btn.clicked.connect( partial(self.on_filter_set_text, '')) self.filter_line = QLineEdit() self.filter_line.setPlaceholderText('Enter filter string here') self.filter_line.textChanged.connect(self.on_filter_change_text) completer = QCompleter(self) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(QStringListModel([], self)) self.filter_line.setCompleter(completer) filter_layout.addWidget(self.filter_reset_btn) filter_layout.addWidget(self.filter_line) return filter_layout
def init(self, parent): super(_ComboboxEditor, self).init(parent) self.control = control = self.create_combo_box() if self.factory.addable: control = control.combo control.addItems(self.names) QtCore.QObject.connect(control, QtCore.SIGNAL('currentIndexChanged(QString)'), self.update_object) if self.factory.evaluate is not None: control.setEditable(True) if self.factory.auto_set: QtCore.QObject.connect( control, QtCore.SIGNAL('editTextChanged(QString)'), self.update_text_object) else: QtCore.QObject.connect(control.lineEdit(), QtCore.SIGNAL('editingFinished()'), self.update_autoset_text_object) control.setInsertPolicy(QtGui.QComboBox.NoInsert) # self._no_enum_update = 0 self.set_tooltip() control.setCompleter(QCompleter(control)) self.sync_value(self.factory.refresh, 'refresh', 'from') if self.factory.addable: self.control.button.clicked.connect(self.update_add)
def updateCompletion(self, commands): if self.completer: self.completer.activated.disconnect(self.onAutoComplete) self.completer = QCompleter([(self.prefix + name).replace('_', ' ', 1) for name in commands], self) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setWidget(self) self.completer.activated.connect(self.onAutoComplete)
def plot(self): """ Creates a QGraphicScene for the layouted graph in self.gv This function has to be called every time, a node change happened. """ scene = self.graphicsView.scene() scene.clear() self.nodesToQNodes = {} self.qLines = [] for node in self.gv.nodes_iter(): (x, y) = node.attr['pos'].split(',') x = float(x) y = float(y) point = self.graphicsView.mapToScene(int(x), int(y)) qnode = self.createQtNode(node, point.x(), point.y()) scene.addItem(qnode) self.nodesToQNodes[node] = qnode self.completer = QCompleter(list(self.nodesToQNodes.keys())) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setWidget(self.lineEdit) self.lineEdit.setCompleter(self.completer) self.renewplot() self.searchNode(self.lineEdit.text())
def __init__(self, mainwindow): """ Initializes the GraphWidget. """ super(GraphWidget, self).__init__(mainwindow) self.setupUi(self.mw) self.startRelation = None self.abstractGraph = None self.gv = pygraphviz.AGraph(strict=False) self.widget = self.layoutWidget self.log = logging.getLogger('.' + __name__) self.nodesToQNodes = {} self.qLines = [] self.qpens = {} self.completer = QCompleter(list("")) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setWidget(self.lineEdit) self.lastScale = 1 self.initMenu() self.roots = set() self.doubleSpinBox.valueChanged[float].connect(self.changeScale) self.lineEdit.textChanged.connect(self.searchNode) self.rootSelector.insertItem(0, "---") self.rootSelector.currentIndexChanged[str].connect(self.newRoot) self.relations.currentIndexChanged[str].connect(self.newVariant) self.depth.valueChanged.connect(self.newRoot) self._updateActiveOntology() self.graphicsView.setScene(QGraphicsScene())
def setList(self, list): self.clear() self.addItems(list) autoCompleteModel = QStringListModel(list) completer = QCompleter() completer.setModel(autoCompleteModel) completer.setCaseSensitivity(Qt.CaseInsensitive) self.setCompleter(completer)
def initAutocomplete(self): """Inits the QCompleter and gives him a list of words""" self.completer = QCompleter( list( OrderedDict.fromkeys( re.split("\\W", self.plainTextEdit.toPlainText())))) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setWidget(self.getWidget()) self.completer.activated.connect(self.insertCompletion)
def handleServerChanged(self): try: projectList = self.manager.getObsServerProjectList( self.getCurrentServerAlias()) self.__obsNameCompleter = QCompleter(projectList, self.__configDialog) self.__configDialog.projectObsNameLineEdit.setCompleter( self.__obsNameCompleter) except OBSLightBaseError: self.__configDialog.projectObsNameLineEdit.setCompleter(None) self.handleObsNameEditingFinished()
def __init__(self, user_names=None, version=None, parent=None): super(LoginDialog, self).__init__(parent) self.setupUi(self) self.screen_label.setScaledContents(True) if version: self.setWindowTitle("{} v{}".format(self.windowTitle(), version)) self.setFocus() self.setAttribute(Qt.WA_DeleteOnClose) # Show previously entered user names completer = QCompleter(user_names) self.user_name.setCompleter(completer)
def __init__(self, *args, **kwargs): super(RuleTextEdit, self).__init__(*args, **kwargs) self.setAutoFillBackground(True) self.textChanged.connect(self.onTextChange) model = QStringListModel() model.setStringList(['<', '>', '=', 'vasya']) self.completer = QCompleter(model) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.setCompleter(self.completer)
def configure_search_lineedit(self, lineEdit): if not self._configured: # no data received yet. hold on configuration self._search_lineedit = lineEdit else: splitter = lineEdit.column_query_splitter completer = QCompleter([ header + splitter for header in self._headers[1:] ]) # search anything but the image column completer.setCaseSensitivity(Qt.CaseInsensitive) lineEdit.setCompleter(completer) lineEdit.textEdited.connect(self.query) self._column_query_sep = splitter
def __init__(self, history, commands, prefix): self.prefix = prefix self.history_index = 0 self.history = history self.reset_history() super(CommandBox, self).__init__() # Autocompleter self.completer = QCompleter([prefix + name for name in commands], self) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setWidget(self) self.completer.activated.connect(self.onAutoComplete) self.autocompleteStart = None
def _createApiChooserLineedit(self): """ Create the I{QLineEdit }used for selecting API names. This includes a QCompleter to make suggestions based on the keyword database. """ self.api_chooser_lineedit = QLineEdit() self.api_chooser_lineedit.returnPressed.connect(self.populateBrowserWindow) self.api_chooser_lineedit.textChanged.connect(self._updateCompleterModel) completer = QCompleter() completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) completer.setModelSorting(QCompleter.CaseSensitivelySortedModel) self.completer_model = QStringListModel([]) completer.setModel(self.completer_model) self.api_chooser_lineedit.setCompleter(completer)
def __init__(self, parent=None): super(ComboBoxWithTypingSearch, self).__init__(parent) self.setFocusPolicy(Qt.StrongFocus) self.setEditable(True) self.completer = QCompleter(self) # always show all completions self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.pFilterModel = QSortFilterProxyModel(self) self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) self.completer.setPopup(self.view()) self.setCompleter(self.completer) self.lineEdit().textEdited.connect( self.pFilterModel.setFilterFixedString) self.completer.activated.connect(self.setTextIfCompleterIsClicked)
def __init__(self, parent): ''' Create an autocompletion list popup ''' widget = QListWidget() super(Completer, self).__init__(parent) self.setWidget(widget) self.string_list = QStringListModel() self._completer = QCompleter() self.parent = parent self._completer.setCaseSensitivity(Qt.CaseInsensitive) # For some reason the default minimum size is (61,61) # Set it to 0 so that the size of the box is not taken # into account when it is hidden. self.setMinimumSize(0, 0) self.prepareGeometryChange() self.resize(0, 0) self.hide()
def __init__(self, parent, widget, on_change): """Init and connect signals""" self.parent = parent self.app = QApplication.instance() self.widget = widget self.tags_list = map( lambda tag: Tag.from_tuple(tag).name, self.app.provider.list_tags(), ) self.completer = QCompleter() self.completer_model = QStringListModel() self.completer.setModel(self.completer_model) self.completer.activated.connect(self.update_completion) self.update_completion() self.widget.setCompleter(self.completer) self.widget.textChanged.connect(Slot()(on_change)) self.widget.textEdited.connect(self.update_completion)
def createEditor(self,parent,option,index): # Qt takes ownership of the editor # Therefore I have recreate it each time this method is called combo = QComboBox(parent) combo.setModel(self.model) completer = QCompleter(combo) completer.setModel(self.model) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) # PopupCompletion) combo.setCompleter(completer) if option: # This is needed to put the combobox in the right place combo.setGeometry(option.rect) return combo
def __init__(self, parent=None, list=[]): QComboBox.__init__(self, parent) self.setEditable(True) self.setInsertPolicy(QComboBox.NoInsert) self.addItems(list) autoCompleteModel = QStringListModel(list) completer = QCompleter() completer.setModel(autoCompleteModel) completer.setCaseSensitivity(Qt.CaseInsensitive) self.setCompleter(completer) self.setEditText("") self.__textChangeStatus = True self.editTextChanged.connect(self.__onTextChange) shortcut = QShortcut(QKeySequence(Qt.Key_Return), self, self.__onEnter) shortcut = QShortcut(QKeySequence(Qt.Key_Enter), self, self.__onEnter)
def __init__(self): def paste(): loadPath = (self.repository+self.filename_base+"%s.nk")%(self.cb_list.currentText()) print loadPath nuke.nodePaste(loadPath) self.close() self.user = os.environ.get("USERNAME") self.repository = "T://_Nuke_tools//global_clipboard//" self.filename_base = "tempClipBoard_" os.chdir(self.repository) self.items = [] for file in glob.glob("*.nk"): self.items.append(file.split(self.filename_base)[-1].split('.')[0]) super(GlobalClipboard, self).__init__(QtGui.QApplication.activeWindow()) self.setWindowTitle('Global Clipboard') self.hbox=QtGui.QHBoxLayout() self.cb_list=QtGui.QComboBox() self.cb_list.setEditable(True) for item in self.items: self.cb_list.addItem(item) self.completer = QCompleter() self.cb_list.setCompleter(self.completer) self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) model_autocomplete = QStringListModel() self.completer.setModel(model_autocomplete) model_autocomplete.setStringList(self.items) self.description=QtGui.QLabel(self) self.description.setText("Paste from") self.hbox.addWidget(self.description)#desc self.hbox.addWidget(self.cb_list)#menu self.button=QtGui.QPushButton("Paste") self.hbox.addWidget(self.button)#button self.button.clicked.connect(paste) self.setLayout(self.hbox)
def __init__(self, parent): super(SearchBar, self).__init__(parent) self.parent = parent self.setMovable(False) self.setStyleSheet('QToolBar{spacing:5px;}') self.addWidget(QLabel(" ")) self.search = QLineEdit() self.search.setPlaceholderText("Search...") self.completer = QCompleter() self.search.setCompleter(self.completer) self.indexer = QApplication.instance().indexer self.search.selectionChanged.connect(self.changeSelection) self.search.textChanged.connect(self.setCompleterModel) self.addWidget(self.search) searchbtn = QPushButton("Search") searchbtn.clicked.connect(self.searchDocuments) highlighttn = QPushButton("Highlight text") highlighttn.clicked.connect(self.highlightText) self.addWidget(searchbtn) self.addWidget(highlighttn) self.addWidget(QLabel(" "))
class Viz: FRAME_DURATION = 1000/30 # 30 FPS DEFAULT_COLOR = Qt.lightGray def __init__(self): self.loadedPaths = set() self.dataSources = [] self.genes = set() self.loader = QUiLoader() infile = QFile("expressionTopology.ui") infile.open(QFile.ReadOnly) self.window = self.loader.load(infile, None) infile.close() self.updateTimeSliders() # Main view self.multiPanel = multiViewPanel(self.window.graphicsView,self) # Events self.window.categoryTable.cellClicked.connect(self.changeColor) self.window.loadButton.clicked.connect(self.loadData) self.window.quitButton.clicked.connect(self.window.close) self.window.addButton.clicked.connect(self.addGene) self.window.geneBox.editTextChanged.connect(self.editGene) self.window.speedSlider.valueChanged.connect(self.changeSpeed) self.window.timeSlider.valueChanged.connect(self.changeTime) self.window.addButton.setEnabled(False) self.window.showFullScreen() #self.window.show() # Start timer # Update timer self.timer = QTimer(self.window) self.timer.timeout.connect(self.nextFrame) self.timer.start(Viz.FRAME_DURATION) def changeColor(self, row, column): if column == 1: col = QColorDialog.getColor() parametricPulseGraph.COLOR_MAP[self.window.categoryTable.item(row,0).text()] = col self.window.categoryTable.item(row,1).setBackground(col) self.multiPanel.scene.update() def addGene(self): g = self.window.geneBox.currentText() if g in self.genes: t = self.window.addButton.text() if t == 'Add': self.multiPanel.addVariable(g) self.window.addButton.setText('Remove') else: self.multiPanel.removeVariable(g) self.window.addButton.setText('Add') def editGene(self): g = self.window.geneBox.currentText() if g in self.genes: if self.multiPanel.variables.has_key(g): self.window.addButton.setText('Remove') else: self.window.addButton.setText('Add') self.window.addButton.setEnabled(True) else: self.window.addButton.setEnabled(False) def getVectors(self, x, y): vectors = {} for s in self.dataSources: vectors.update(s.getVectors(x,y)) return vectors def nextFrame(self): if parametricPulseGraph.CURRENT_SPEED > 0: parametricPulseGraph.nextFrame() self.window.timeSlider.setSliderPosition(parametricPulseGraph.CURRENT_TIME) self.multiPanel.scene.update() def updateTimeSliders(self): self.window.timeSlider.setMinimum(parametricPulseGraph.TIME_START) self.window.timeSlider.setMaximum(parametricPulseGraph.TIME_END) self.window.timeSlider.setSliderPosition(parametricPulseGraph.CURRENT_TIME) self.window.timeSlider.setSingleStep(1) self.window.timeSlider.setPageStep(parametricPulseGraph.CURRENT_SPEED) self.window.speedSlider.setMinimum(parametricPulseGraph.MIN_SPEED) self.window.speedSlider.setMaximum(parametricPulseGraph.MAX_SPEED) self.window.speedSlider.setSliderPosition(parametricPulseGraph.CURRENT_SPEED) self.window.speedSlider.setSingleStep(1) self.window.speedSlider.setPageStep(int(0.1*parametricPulseGraph.MAX_SPEED)) def changeSpeed(self): parametricPulseGraph.CURRENT_SPEED = self.window.speedSlider.value() def changeTime(self): parametricPulseGraph.CURRENT_TIME = self.window.timeSlider.value() self.multiPanel.scene.update() def loadData(self): fileNames = QFileDialog.getOpenFileNames(caption=u"Open expression data file", filter=u"SOFT (*.soft);;Time Series Data (*.tsd)")[0] #;;Comma separated value (*.csv);;Column separated data (*.dat) if len(fileNames) == 0: return errors = [] for f in fileNames: if f in self.loadedPaths: continue ext = os.path.splitext(f)[1].lower() fObj = None lastLow = parametricPulseGraph.TIME_START lastHigh = parametricPulseGraph.TIME_END try: if ext == '.soft': fObj = SoftFile(f) elif ext == '.tsd': fObj = TsdFile(f) #elif ext == '.csv': # self.dataSources.append(CsvFile(f)) #elif ext == '.dat': # self.dataSources.append(DatFile(f)) else: continue self.dataSources.append(fObj) if len(self.loadedPaths) == 0: low,high = fObj.timeRange() parametricPulseGraph.updateTimes(low,high) else: low,high = fObj.timeRange() parametricPulseGraph.updateTimes(min(low,parametricPulseGraph.TIME_START),max(high,parametricPulseGraph.TIME_END)) self.updateTimeSliders() self.loadedPaths.add(f) except Exception, e: errors.append((f,str(e))) self.dataSources.remove(fObj) parametricPulseGraph.updateTimes(lastLow,lastHigh) self.updateTimeSliders() continue if len(errors) > 0: msgBox = QMessageBox() msgBox.setText("%i error%s occurred while trying to load data." % (len(errors), '' if len(errors) == 1 else 's')) msgBox.setIcon(QMessageBox.Critical) details = "" for p,e in errors: details += "%s:\n-----\n%s\n\n" % (p,e) msgBox.setDetailedText(details) msgBox.exec_() # Update gene box self.genes = set() for s in self.dataSources: self.genes.update(s.geneList()) geneList = list(self.genes) self.window.geneBox.clear() self.window.geneBox.addItems(geneList) completer = QCompleter(geneList) completer.setCaseSensitivity(Qt.CaseInsensitive) self.window.geneBox.setCompleter(completer) # Update class table parametricPulseGraph.COLOR_MAP = {} for r in xrange(self.window.categoryTable.rowCount()): parametricPulseGraph.COLOR_MAP[self.window.categoryTable.item(r,0).text()] = self.window.categoryTable.item(r,1).background().color() for s in self.dataSources: for c in s.classList(): if not parametricPulseGraph.COLOR_MAP.has_key(c): parametricPulseGraph.COLOR_MAP[c] = Viz.DEFAULT_COLOR self.window.categoryTable.clear() self.window.categoryTable.setRowCount(len(parametricPulseGraph.COLOR_MAP)) self.window.categoryTable.setColumnCount(2) for r,(t,c) in enumerate(sorted(parametricPulseGraph.COLOR_MAP.iteritems())): self.window.categoryTable.setItem(r,0,QTableWidgetItem(t)) cItem = QTableWidgetItem("") cItem.setBackground(c) self.window.categoryTable.setItem(r,1,cItem)
def __init__(self, parent=None): super(RobocompDslGui, self).__init__(parent) self.setWindowTitle("Create new component") # self._idsl_paths = [] self._communications = { "implements": [], "requires": [], "subscribesTo": [], "publishes": [] } self._interfaces = {} self._cdsl_doc = CDSLDocument() self._command_process = QProcess() self._main_widget = QWidget() self._main_layout = QVBoxLayout() self.setCentralWidget(self._main_widget) self._name_layout = QHBoxLayout() self._name_line_edit = QLineEdit() self._name_line_edit.textEdited.connect(self.update_component_name) self._name_line_edit.setPlaceholderText("New component name") self._name_layout.addWidget(self._name_line_edit) self._name_layout.addStretch() # DIRECTORY SELECTION self._dir_line_edit = QLineEdit() # self._dir_line_edit.textEdited.connect(self.update_completer) self._dir_completer = QCompleter() self._dir_completer_model = QFileSystemModel() if os.path.isdir(ROBOCOMP_COMP_DIR): self._dir_line_edit.setText(ROBOCOMP_COMP_DIR) self._dir_completer_model.setRootPath(ROBOCOMP_COMP_DIR) self._dir_completer.setModel(self._dir_completer_model) self._dir_line_edit.setCompleter(self._dir_completer) self._dir_button = QPushButton("Select directory") self._dir_button.clicked.connect(self.set_output_directory) self._dir_layout = QHBoxLayout() self._dir_layout.addWidget(self._dir_line_edit) self._dir_layout.addWidget(self._dir_button) # LIST OF ROBOCOMP INTERFACES self._interface_list = QListWidget() self._interface_list.setSelectionMode( QAbstractItemView.ExtendedSelection) self._interface_list.itemSelectionChanged.connect( self.set_comunication) # LIST OF CONNECTION TyPES self._type_combo_box = QComboBox() self._type_combo_box.addItems( ["publishes", "implements", "subscribesTo", "requires"]) self._type_combo_box.currentIndexChanged.connect( self.reselect_existing) # BUTTON TO ADD A NEW CONNECTION # self._add_connection_button = QPushButton("Add") # self._add_connection_button.clicked.connect(self.add_new_comunication) self._add_connection_layout = QHBoxLayout() # self._add_connection_layout.addWidget(self._add_connection_button) self._language_combo_box = QComboBox() self._language_combo_box.addItems(["Python", "Cpp", "Cpp11"]) self._language_combo_box.currentIndexChanged.connect( self.update_language) self._add_connection_layout.addWidget(self._language_combo_box) self._add_connection_layout.addStretch() self._gui_check_box = QCheckBox() self._gui_check_box.stateChanged.connect(self.update_gui_selection) self._gui_label = QLabel("Use Qt GUI") self._add_connection_layout.addWidget(self._gui_label) self._add_connection_layout.addWidget(self._gui_check_box) # WIDGET CONTAINING INTERFACES AND TYPES self._selection_layout = QVBoxLayout() self._selection_layout.addWidget(self._type_combo_box) self._selection_layout.addWidget(self._interface_list) self._selection_layout.addLayout(self._add_connection_layout) self._selection_widget = QWidget() self._selection_widget.setLayout(self._selection_layout) # TEXT EDITOR WITH THE RESULTING CDSL CODE self._editor = QTextEdit(self) self._editor.setHtml("") self._document = self._editor.document() self._component_directory = None # SPLITTER WITH THE SELECTION AND THE CODE self._body_splitter = QSplitter(Qt.Horizontal) self._body_splitter.addWidget(self._selection_widget) self._body_splitter.addWidget(self._editor) self._body_splitter.setStretchFactor(0, 2) self._body_splitter.setStretchFactor(1, 9) # CREATION BUTTONS self._create_button = QPushButton("Create .cdsl") self._create_button.clicked.connect(self.write_cdsl_file) self._creation_layout = QHBoxLayout() self._creation_layout.addStretch() self._creation_layout.addWidget(self._create_button) self._console = QConsole() self._command_process.readyReadStandardOutput.connect( self._console.standard_output) self._command_process.readyReadStandardError.connect( self._console.error_output) # ADDING WIDGETS TO MAIN LAYOUT self._main_widget.setLayout(self._main_layout) self._main_layout.addLayout(self._name_layout) self._main_layout.addLayout(self._dir_layout) self._main_layout.addWidget(self._body_splitter) self._main_layout.addLayout(self._creation_layout) self._main_layout.addWidget(self._console) self.setMinimumSize(800, 500) self._editor.setText(self._cdsl_doc.generate_doc())