def __init__(self, gui=True, **argv): """ gui: whether to show webkit window or run headless """ super(AjaxBrowser, self).__init__() self.argv = argv self.stats = stats.RenderStats() # use grid layout to hold widgets self.grid = QVBoxLayout() self.url_input = UrlInput(self.load_url) self.grid.addWidget(self.url_input) self._view = None # create status box self.status_table = StatusTable() self.grid.addWidget(self.status_table) # create results table self.records_table = ResultsTable() self.grid.addWidget(self.records_table) self.setLayout(self.grid) # log all responses response_filename = os.path.join(webkit.OUTPUT_DIR, 'responses.csv') self.response_writer = csv.writer(open(response_filename, 'w')) self.response_writer.writerow( ['URL', 'Content-Type', 'Referer', 'Size']) # Define keyboard shortcuts for convenient interaction QShortcut(QKeySequence.Close, self, self.close) QShortcut(QKeySequence.Quit, self, self.close) QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F), self, self.fullscreen) if gui: self.showMaximized() self.raise_() # give focus to this browser window
def _initShortcuts(self): mgr = ShortcutManager() shortcutGroupName = "Predictions" togglePredictions = QShortcut( QKeySequence("p"), self, member=self._viewerControlUi.checkShowPredictions.click) mgr.register(shortcutGroupName, "Toggle Prediction Layer Visibility", togglePredictions, self._viewerControlUi.checkShowPredictions) toggleSegmentation = QShortcut( QKeySequence("s"), self, member=self._viewerControlUi.checkShowSegmentation.click) mgr.register(shortcutGroupName, "Toggle Segmentaton Layer Visibility", toggleSegmentation, self._viewerControlUi.checkShowSegmentation) toggleLivePredict = QShortcut( QKeySequence("l"), self, member=self.labelingDrawerUi.liveUpdateButton.toggle) mgr.register(shortcutGroupName, "Toggle Live Prediction Mode", toggleLivePredict, self.labelingDrawerUi.liveUpdateButton)
def __init__(self, com, nLanes=4): Kronoz.__init__(self) QWidget.__init__(self) gui_MainWindow.__init__(self) self.setupUi(self) self.lanes = [GUILane(i) for i in range(nLanes)] for l in self.lanes: self.laneList.addWidget(l) self.com = com self.btStart.clicked.connect(self.on_start) self.btStop.clicked.connect(self.on_stop) self.btSave.clicked.connect(self.save_results) self.btOpen.clicked.connect(self.open_res_file) self.btBrowse.clicked.connect(self.browse_res_folder) self.shortcuts = (QShortcut(QKeySequence('1'), self.btStart, self.btStart.click), QShortcut(QKeySequence('2'), self.btStop, self.btStop.click), QShortcut(QKeySequence('3'), self.btSave, self.btSave.click), QShortcut(QKeySequence('4'), self.btOpen, self.btOpen.click), QShortcut(QKeySequence('5'), self.btBrowse, self.btBrowse.click)) if com is not None: self.timer = QTimer() self.timer.timeout.connect(self.poll_timer) self.timer.start(self.poll_interval) self.set_state(Kronoz.Connecting) else: self.timer = None self.set_state(Kronoz.Disconnected)
def _vincular_atajos_de_teclado(self): QShortcut(QKeySequence("F5"), self, self.cuando_pulsa_el_boton_ejecutar) QShortcut(QKeySequence("Ctrl+r"), self, self.cuando_pulsa_el_boton_ejecutar) # Solo en MacOS informa que la tecla Command sustituye a CTRL. if sys.platform == 'darwin': self.boton_ejecutar.setToolTip(u"Ejecutar el código actual (F5 o ⌘R)")
def __init__(self, parent=None): QFrame.__init__(self, parent=parent) DegenPrimerGUI.load_ui(self._ui_file, self) self.editor = self.findChild(QTextEdit, 'ReportTextEdit') self.search = self.findChild(QLineEdit, 'SearchLineEdit') self.search.textChanged.connect(self.find_text) self.search.returnPressed.connect(self.find_next) QShortcut(QKeySequence(Qt.Key_F3), self, self.find_next) QShortcut(QKeySequence(Qt.Key_F2), self, self.find_prev) self.term = ''
def __init__(self, setList, config, dbConf): QDialog.__init__(self) self.sl = setList self.config = config self.form = Ui_Dialog() self.form.setupUi(self) sf = self.form self.ansChoices = [ sf.answerA, sf.answerB, sf.answerC, sf.answerD, sf.answerE ] # get buttons into proper state of enablement self.listEnabled = True self._disableList() self._enableList() # fill with content self.populateSets() self.setupQuestions() # connect buttons self.form.newButton.clicked.connect(self.onNew) self.form.deleteButton.clicked.connect(self.onDelete) self.form.importButton.clicked.connect(self.onImport) self.form.exportButton.clicked.connect(self.onExport) self.form.genQuizButton.clicked.connect(self.onGenerate) self.form.randomizeButton.clicked.connect(self.onRandomize) self.form.moveDownButton.clicked.connect(self.onMoveDown) self.form.moveUpButton.clicked.connect(self.onMoveUp) self.form.saveButton.clicked.connect(self.onSaveQuestion) self.form.cancelButton.clicked.connect(self.onDiscard) self.form.closeButton.clicked.connect(self.reject) # connect changed events and shortcuts self.form.correctAnswerCombo.activated.connect( self.onCorrectAnswerChoice) self.form.jumpCombo.activated.connect(self.onJumpToSet) self.form.questionList.itemSelectionChanged.connect( self.onQuestionChange) qlShortcut = QShortcut(QKeySequence("Alt+L"), self.form.questionList) qlShortcut.connect(qlShortcut, QtCore.SIGNAL("activated()"), self.form.questionList.setFocus) saveShortcut = QShortcut(QKeySequence("Ctrl+S"), self.form.saveButton) saveShortcut.connect(saveShortcut, QtCore.SIGNAL("activated()"), self.onSaveQuestion) self.form.questionList.model().rowsMoved.connect(self.onDragDrop) self.form.questionBox.textChanged.connect(self.updateListQuestion) self.form.answerA.textEdited.connect(self._disableList) self.form.answerB.textEdited.connect(self._disableList) self.form.answerC.textEdited.connect(self._disableList) self.form.answerD.textEdited.connect(self._disableList) self.form.answerE.textEdited.connect(self._disableList) self.form.correctAnswerCombo.activated.connect(self._disableList)
def install_shortcuts(obj, actions, ide): short = resources.get_shortcut for action in actions: short_key = action.get("shortcut", None) action_data = action.get("action", None) connect = action.get("connect", None) shortcut = None item_ui = None func = None if connect: func = getattr(obj, connect, None) if short_key and not action_data: if isinstance(short_key, QKeySequence): shortcut = QShortcut(short_key, ide) else: shortcut = QShortcut(short(short_key), ide) shortcut.setContext(Qt.ApplicationShortcut) if isinstance(func, collections.Callable): ide.connect(shortcut, SIGNAL("activated()"), func) if action_data: is_menu = action_data.get('is_menu', False) if is_menu: item_ui = QMenu(action_data['text'], ide) else: item_ui = QAction(action_data['text'], ide) object_name = "%s.%s" % (obj.__class__.__name__, connect) item_ui.setObjectName(object_name) image_name = action_data.get('image', None) section = action_data.get('section', None) weight = action_data.get('weight', None) keysequence = action_data.get('keysequence', None) if image_name: if isinstance(image_name, int): icon = ide.style().standardIcon(image_name) item_ui.setIcon(icon) elif isinstance(image_name, str): icon = QIcon(":img/" + image_name) item_ui.setIcon(icon) if short_key and not is_menu: item_ui.setShortcut(short(short_key)) item_ui.setShortcutContext(Qt.ApplicationShortcut) elif keysequence and not is_menu: item_ui.setShortcut(short(keysequence)) item_ui.setShortcutContext(Qt.ApplicationShortcut) if isinstance(func, collections.Callable) and not is_menu: ide.connect(item_ui, SIGNAL("triggered()"), func) if section and section[0] is not None and weight: ide.register_menuitem(item_ui, section, weight) if image_name and not is_menu: ide.register_toolbar(item_ui, section, weight) if short_key and shortcut: ide.register_shortcut(short_key, shortcut, item_ui)
def __init__(self, config, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.app = app # search history is a list of patterns which have been searched self.search_history = self.loadSearchHistory() self.updateCompletion() self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search) self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId) self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"), self.typeComboChanged) count = self.config.get('settings', 'maxresultsnumber') self.ui.countSpin.setValue(int(count)) showT = self.config.get('settings', 'showthumbnails') self.ui.showTCheck.setChecked(showT == '1') self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess) self.ui.stopButton.hide() self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self) self.connect(q, SIGNAL("activated()"), self.close) n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self) self.connect(n, SIGNAL("activated()"), self.nextTab) p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self) self.connect(p, SIGNAL("activated()"), self.prevTab) w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self) self.connect(w, SIGNAL("activated()"), self.closeCurrentTab) l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.setFocus) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.selectAll) self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"), self.closeTab) self.loadBackendsList() if self.ui.backendEdit.count() == 0: self.backendsConfig() langs = sorted(LANGUAGE_CONV.keys()) for lang in langs: self.ui.langCombo.addItem(lang) self.ui.langCombo.hide() self.ui.langLabel.hide()
def __init__(self, fileBrowser): QTreeView.__init__(self, fileBrowser) self._fileBrowser = fileBrowser self.setAttribute(Qt.WA_MacShowFocusRect, False) self.setAttribute(Qt.WA_MacSmallSize) self.setContextMenuPolicy(Qt.ActionsContextMenu) self.setHeaderHidden(True) self.setUniformRowHeights(True) self.setTextElideMode(Qt.ElideMiddle) # dir model self._dirsModel = _FileSystemModel(self) self._dirsModel.setNameFilterDisables(False) self._dirsModel.setFilter(QDir.AllDirs | QDir.AllEntries | QDir.CaseSensitive | QDir.NoDotAndDotDot) # self._dirsModel.directoryLoaded.connect(self.setFocus) TODO don't have this signal in my Qt version # create proxy model self._filteredModel = FileBrowserFilteredModel(self) self._filteredModel.setSourceModel(self._dirsModel) self.setModel(self._filteredModel) if not sys.platform.startswith('win'): self._dirsModel.setRootPath("/") else: self._dirsModel.setRootPath('') # shortcut accessible only when self._tree has focus self._upShortcut = QShortcut(QKeySequence("BackSpace"), self) self._upShortcut.setContext(Qt.WidgetShortcut) self._upShortcut.activated.connect(self.moveUp) # shortcut accessible only when self._tree has focus self._homeShortcut = QShortcut(QKeySequence("`"), self) self._homeShortcut.setContext(Qt.WidgetShortcut) self._homeShortcut.activated.connect(self._goUserHomeDir) # shortcut accessible only when self._tree has focus self._homeShortcut = QShortcut(QKeySequence("."), self) self._homeShortcut.setContext(Qt.WidgetShortcut) self._homeShortcut.activated.connect(self._goCurrentDir) self.activated.connect(self._onActivated) self._fileActivated.connect(fileBrowser.fileActivated) # QDirModel loads item asynchronously, therefore we need timer for setting focus to the first item self._setFocusTimer = QTimer() self._setFocusTimer.timeout.connect(self._setFirstItemAsCurrent) self._setFocusTimer.setInterval(50) self.destroyed.connect(self._setFocusTimer.stop) self._timerAttempts = 0
def atalho_teclado(self): shortcut1 = QShortcut(QKeySequence(Qt.Key_1), self.iface.mainWindow()) shortcut1.setContext(Qt.ApplicationShortcut) shortcut1.activated.connect(self.setVerifica1) shortcut2 = QShortcut(QKeySequence(Qt.Key_2), self.iface.mainWindow()) shortcut2.setContext(Qt.ApplicationShortcut) shortcut2.activated.connect(self.setVerifica2) shortcut3 = QShortcut(QKeySequence(Qt.Key_3), self.iface.mainWindow()) shortcut3.setContext(Qt.ApplicationShortcut) shortcut3.activated.connect(self.setVerifica3)
def __new__(cls, *args, captionTitle=None, **kwargs): self = super().__new__(cls, None, cls.get_flags()) QDialog.__init__(self, None, self.get_flags()) WidgetMessagesMixin.__init__(self) stored_settings = kwargs.get('stored_settings', None) if self.settingsHandler: self.settingsHandler.initialize(self, stored_settings) self.signalManager = kwargs.get('signal_manager', None) self.__env = _asmappingproxy(kwargs.get("env", {})) setattr(self, gui.CONTROLLED_ATTRIBUTES, ControlledAttributesDict(self)) self.graphButton = None self.report_button = None OWWidget.widget_id += 1 self.widget_id = OWWidget.widget_id captionTitle = self.name if captionTitle is None else captionTitle # must be set without invoking setCaption self.captionTitle = captionTitle self.setWindowTitle(captionTitle) self.setFocusPolicy(Qt.StrongFocus) self.__blocking = False # flag indicating if the widget's position was already restored self.__was_restored = False self.__statusMessage = "" self.__msgwidget = None self.__msgchoice = 0 self.left_side = None self.controlArea = self.mainArea = self.buttonsArea = None self.splitter = None if self.want_basic_layout: self.set_basic_layout() sc = QShortcut(QKeySequence(Qt.ShiftModifier | Qt.Key_F1), self) sc.activated.connect(self.__quicktip) sc = QShortcut(QKeySequence.Copy, self) sc.activated.connect(self.copy_to_clipboard) if self.controlArea is not None: # Otherwise, the first control has focus self.controlArea.setFocus(Qt.ActiveWindowFocusReason) return self
def __init__(self): super(WrapperTable, self).__init__() QShortcut(QKeySequence.Close, self, self.close) QShortcut(QKeySequence.Quit, self, self.close) self.wrapper_name = None header = 'Website', 'HTTP method', 'Response format', 'Category', 'Notes', 'Run' font = QFont('Times New Roman', 16) self.setFont(font) self.setColumnCount(len(header)) self.setHorizontalHeaderLabels(header) font.setBold(True) self.horizontalHeader().setFont(font) self.setVerticalHeaderLabels([]) for wrapper_name in get_wrappers(): wrapper = load_wrapper(wrapper_name) try: if not wrapper.enabled: continue # ignore this disabled wrapper except AttributeError: pass num_rows = self.rowCount() self.insertRow(num_rows) self.setItem( num_rows, 0, QTableWidgetItem(wrapper_name.replace('_', ' ').title())) for i, attr in enumerate( ['http_method', 'response_format', 'category', 'notes']): try: value = getattr(wrapper, attr) except AttributeError: pass else: if attr == 'notes': # add line breaks value = value.replace('.', '.\n') self.setItem(num_rows, i + 1, QTableWidgetItem(value)) # add button to activate wrapper button = QPushButton('Go') button.clicked.connect(self.select_wrapper(wrapper_name)) self.setCellWidget(num_rows, len(header) - 1, button) self.setVerticalHeaderItem(num_rows, QTableWidgetItem('')) self.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) self.showMaximized() self.setSortingEnabled(True) self.sortItems(0) self.raise_()
def registerShortcuts(mgr): scA = QShortcut(QKeySequence("1"), mainWindow, member=partial(trigger, "A")) mgr.register("Group 1", "Shortcut 1A", scA, None) scB = QShortcut(QKeySequence("2"), mainWindow, member=partial(trigger, "B")) mgr.register("Group 1", "Shortcut 1B", scB, None) scC = QShortcut(QKeySequence("3"), mainWindow, member=partial(trigger, "C")) mgr.register("Group 2", "Shortcut 2C", scC, None)
def __init__(self): super(Demo, self).__init__() self.code_editor = CodeEditor(self) self.code_editor.setup_editor( language = "python", font = QFont("Courier New") ) run_sc = QShortcut(QKeySequence("F5"), self, self.run) self.shell = InternalShell(self, {"demo":self}, multithreaded = False, max_line_count = 3000, font = QFont("Courier new", 10), message='caonima' ) self.dict_editor = DictEditorWidget(self, {}) self.dict_editor.editor.set_filter(self.filter_namespace) self.dict_editor.set_data(self.shell.interpreter.namespace) vbox = QVBoxLayout() vbox.addWidget(self.code_editor) vbox.addWidget(self.shell) hbox = QHBoxLayout() hbox.addWidget(self.dict_editor) hbox.addLayout(vbox) self.setLayout(hbox) self.resize(800, 600)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.secs = None self.recording = False self.flashMillisecs = 1000 self.flashTimes = [0, 250, 500, 750] self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) self.talkInfoFont = QFont('Serif', 50, QFont.Light) self.countdownFont = QFont('Serif', 300, QFont.Light) self.talkInfoString = QLabel() self.mainLayout.addWidget(self.talkInfoString) self.talkInfoString.setFont(self.talkInfoFont) self.talkInfoString.setAlignment(Qt.AlignCenter) self.talkInfoString.setStyleSheet( "QLabel { background-color : white; color : black; }") self.countdownString = QLabel() self.mainLayout.addWidget(self.countdownString) self.countdownString.setFont(self.countdownFont) self.countdownString.setAlignment(Qt.AlignCenter) self.countdownString.setStyleSheet( "QLabel { background-color : white; color : black; }") self.countdownTimer = QTimer() self.countdownTimer.timeout.connect(self.timertick) self.flashTimer = QTimer() self.flashTimer.timeout.connect(self.flash_display_text) QShortcut(QKeySequence("Esc"), self, self.showNormal)
def __init__(self, parent): QDialog.__init__(self) self.form = Ui_Dialog() self.form.setupUi(self) self.form.tableView.horizontalHeader().setMovable(True) self.form.addButton.clicked.connect(self.onAdd) self.form.deleteButton.clicked.connect(self.onDelete) self.form.importButton.clicked.connect(self.onImport) self.form.exportButton.clicked.connect(self.onExport) self.form.closeButton.clicked.connect(self.reject) self.form.fastEditBox.toggled.connect(self.onChangeFastEdit) self.onChangeFastEdit() # set up initial state self.setupClassCombo() self.tableModel = StudentTableModel(self) self.form.tableView.setModel(self.tableModel) self.sm = self.form.tableView.selectionModel() self.sm.selectionChanged.connect(self.checkButtonEnablement) self.reFillStudents() self.form.classCombo.activated.connect(self.reFillStudents) self.tableModel.valueRejected.connect(self.onValueRejected) self.tableModel.rowsRemoved.connect(self._updateStudentTotal) self.tableModel.rowsInserted.connect(self._updateStudentTotal) self.tableModel.modelReset.connect(self._updateStudentTotal) self._updateStudentTotal() qlShortcut = QShortcut(QKeySequence("Alt+L"), self.form.tableView) qlShortcut.connect(qlShortcut, QtCore.SIGNAL("activated()"), lambda: self.form.tableView.setFocus())
def __init__(self, parent=None): super(SearchMenu, self).__init__(parent) self.ui = Ui_SearchMenu() self.ui.setupUi(self) self.ui.shortcutFind = QShortcut(QKeySequence("Ctrl+F"), self) self.ui.shortcutFind.activated.connect(self.select_query) self.ui.txtQuery.setCompleter(None) self.ui.txtQuery.setMaxCount(25) self.ui.txtQuery.setMaxVisibleItems(25) self.ui.txtQuery.setInsertPolicy(QtGui.QComboBox.NoInsert) self.ui.txtQuery.view().setTextElideMode(Qt.Qt.ElideNone) self.ui.txtQuery.currentIndexChanged.connect(self.select_query) self.ui.btnFilterSelAll.clicked.connect(lambda: self.filterSetAll(True)) self.ui.btnFilterSelNone.clicked.connect(lambda: self.filterSetAll(False)) # Unchecked is easier to work with, # since it searches everything if nothing's given. self.filterSetAll(False) self.ui.treeResults.setHeaderLabel("Results (0)") self.ui.actionCopyPath = QtGui.QAction("Copy path", None, triggered = self.copyPath) self.ui.treeResults.addAction(self.ui.actionCopyPath) self.query_re = None self.re_flags = re.UNICODE | re.MULTILINE
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setRenderHint(QPainter.Antialiasing) self.setRenderHint(QPainter.TextAntialiasing) self.__layoutMode = ThumbnailView.AutoReflow self.__columnCount = -1 self.__grid = GraphicsThumbnailGrid() self.__grid.currentThumbnailChanged.connect( self.__onCurrentThumbnailChanged ) self.__previewWidget = None scene = GraphicsScene(self) scene.addItem(self.__grid) scene.selectionRectPointChanged.connect( self.__ensureVisible, Qt.QueuedConnection ) self.setScene(scene) sh = QShortcut(Qt.Key_Space, self, context=Qt.WidgetWithChildrenShortcut) sh.activated.connect(self.__previewToogle) self.__grid.geometryChanged.connect(self.__updateSceneRect)
def __init__(self, parentObject, windowTitle, windowIcon=QIcon(), shortcut=None): QDockWidget.__init__(self, parentObject) self._showAction = None self.setObjectName(str(self.__class__)) self.setWindowTitle(windowTitle) self.setFeatures(self.features() & (~QDockWidget.DockWidgetFloatable)) if not windowIcon.isNull(): self.setWindowIcon(windowIcon) if shortcut is not None: self.showAction().setShortcut(shortcut) self._titleBar = _TitleBar(self) self.setTitleBarWidget(self._titleBar) if shortcut is not None: toolTip = "Move focus with <b>%s</b>,<br/>close with <b>Esc</b>" % shortcut else: toolTip = "Close with <b>Esc</b>" self._titleBar.setToolTip(toolTip) self._closeShortcut = QShortcut(QKeySequence("Esc"), self) self._closeShortcut.setContext(Qt.WidgetWithChildrenShortcut) self._closeShortcut.activated.connect(self._close)
def __init__(self, parent=None): super(SearchMenu, self).__init__(parent) self.ui = Ui_SearchMenu() self.ui.setupUi(self) #self.setAttribute(QtCore.Qt.WA_DeleteOnClose) # Feels herpy. #self.ui.buttonBox.accepted.connect(self.open_clicked.emit) self.ui.shortcutFind = QShortcut(QKeySequence("Ctrl+F"), self) self.ui.shortcutFind.activated.connect(self.highlight_query) self.ui.btnFilterSelAll.clicked.connect(lambda: self.filterSetAll(True)) self.ui.btnFilterSelNone.clicked.connect(lambda: self.filterSetAll(False)) # Unchecked is easier to work with, # since it searches everything if nothing's given. self.filterSetAll(False) self.ui.treeResults.setHeaderLabel("Results (0)") self.ui.actionCopyPath = QtGui.QAction("Copy path", None, triggered = self.copyPath) self.ui.treeResults.addAction(self.ui.actionCopyPath) self.transHighlighter = KeywordHighlighter(self.ui.txtTranslated.document()) self.origHighlighter = KeywordHighlighter(self.ui.txtOriginal.document()) self.commHighlighter = KeywordHighlighter(self.ui.txtComments.document()) self.re_flags = re.UNICODE | re.MULTILINE
def __init__(self): super(_StatusBar, self).__init__() self.current_status = _STATUSBAR_STATE_SEARCH self._widgetStatus = QWidget() vbox = QVBoxLayout(self._widgetStatus) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) #Search Layout self._searchWidget = SearchWidget() vbox.addWidget(self._searchWidget) #Replace Layout self._replaceWidget = ReplaceWidget() vbox.addWidget(self._replaceWidget) self._replaceWidget.setVisible(False) #Code Locator self._codeLocator = locator.CodeLocatorWidget() vbox.addWidget(self._codeLocator) self._codeLocator.setVisible(False) #File system completer self._fileSystemOpener = FileSystemOpener() vbox.addWidget(self._fileSystemOpener) self._fileSystemOpener.setVisible(False) self.addWidget(self._widgetStatus) # Not Configurable Shortcuts shortEscStatus = QShortcut(QKeySequence(Qt.Key_Escape), self) self.connect(shortEscStatus, SIGNAL("activated()"), self.hide_status) self.connect(self._searchWidget._btnClose, SIGNAL("clicked()"), self.hide_status) self.connect(self._replaceWidget._btnCloseReplace, SIGNAL("clicked()"), lambda: self._replaceWidget.setVisible(False)) self.connect(self._fileSystemOpener.btnClose, SIGNAL("clicked()"), self.hide_status) self.connect(self._fileSystemOpener, SIGNAL("requestHide()"), self.hide_status) self.connect(self._codeLocator, SIGNAL("hidden()"), self.hide_status) #Register signals connections connections = ( { 'target': 'main_container', 'signal_name': 'currentEditorChanged(QString)', 'slot': self._handle_tab_changed }, { 'target': 'main_container', 'signal_name': 'updateLocator(QString)', 'slot': self._explore_file_code }, { 'target': 'projects_explorer', 'signal_name': 'updateLocator()', 'slot': self._explore_code }, ) IDE.register_signals('status_bar', connections) IDE.register_service('status_bar', self)
def setupUi(self): super(MainWindow, self).setupUi(self) self.search_box.shortcut = QShortcut(self.search_box) self.search_box.shortcut.setKey('Ctrl+F') self.output_devices_group = QActionGroup(self) self.input_devices_group = QActionGroup(self) self.alert_devices_group = QActionGroup(self) self.video_devices_group = QActionGroup(self) self.request_screen_action = QAction('Request screen', self, triggered=self._AH_RequestScreenActionTriggered) self.share_my_screen_action = QAction('Share my screen', self, triggered=self._AH_ShareMyScreenActionTriggered) self.screen_sharing_button.addAction(self.request_screen_action) self.screen_sharing_button.addAction(self.share_my_screen_action) # adjust search box height depending on theme as the value set in designer isn't suited for all themes search_box = self.search_box option = QStyleOptionFrameV2() search_box.initStyleOption(option) frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box) if frame_width < 4: search_box.setMinimumHeight(20 + 2*frame_width) # adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04) option = QStyleOptionComboBox() self.identity.initStyleOption(option) wide_padding = self.identity.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.identity).height() < 10 self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
def __init__(self, parent, cls, zid): """ Arguments: parent: parent widget cls: the Class this quiz belongs to zid: the Quiz to display results for """ QDialog.__init__(self) self.form = Ui_Dialog() self.form.setupUi(self) self.parent = parent self.cls = cls self.zid = zid self.form.closeButton.clicked.connect(self.reject) self.form.viewQuizButton.clicked.connect(self.onViewQuiz) self.form.deleteResultsButton.clicked.connect(self.onDeleteResults) self.tableModel = AnswersTableModel(self) self.form.stuAnswersTable.setModel(self.tableModel) self.form.studentsTable.itemSelectionChanged.connect( self.displayStudent) qlShortcut = QShortcut(QKeySequence("Alt+L"), self.form.studentsTable) qlShortcut.connect(qlShortcut, QtCore.SIGNAL("activated()"), self.form.studentsTable.setFocus) # initialize lists self.setupStudentList() self.setupSummaryData() self.form.studentsTable.setCurrentRow(0) self.displayStudent()
def _firstLetterShortcut(self, button, text): """ Provide first-letter only shortcuts (not Alt+first letter which is already present because of the & before letters) for a button. button - One of self.buttonBox.[Discard/Cancel/Save] text - Text for this button's label. The letter following the & will have a shortcut created for it. Return value: the shortcut for the given button. """ # Set the text of the button, which automatically provides an Alt+letter # shortcut. self.buttonBox.button(button).setText(self.tr(text)) # Get the letter after the ampersand (there should be exactly one # ampersand in the string). assert text.count('&') == 1 letter = text[text.index('&') + 1] # Create a first-letter only shortcut, which clicks the button when # the letter is typed. shortcut = QShortcut(QKeySequence(letter), self) shortcut.activated.connect(self.buttonBox.button(button).click) return shortcut
def create_dockwidget(self): """Add to parent QMainWindow as a dock widget""" # This is not clear yet why the following do not work... # (see Issue #880) ## # Using Qt.Window window flags solves Issue #880 (detached dockwidgets ## # are not painted after restarting Spyder and restoring their hexstate) ## # but it does not work with PyQt <=v4.7 (dockwidgets can't be docked) ## # or non-Windows platforms (lot of warnings are printed out) ## # (so in those cases, we use the default window flags: Qt.Widget): ## flags = Qt.Widget if is_old_pyqt or os.name != 'nt' else Qt.Window dock = QDockWidget(self.get_plugin_title(), self.main) #, flags) dock.setObjectName(self.__class__.__name__ + "_dw") dock.setAllowedAreas(self.ALLOWED_AREAS) dock.setFeatures(self.FEATURES) dock.setWidget(self) self.update_margins() self.connect(dock, SIGNAL('visibilityChanged(bool)'), self.visibility_changed) self.dockwidget = dock short = self.get_option("shortcut", None) if short is not None: shortcut = QShortcut(QKeySequence(short), self.main, self.switch_to_plugin) self.register_shortcut(shortcut, "_", "Switch to %s" % self.CONF_SECTION, default=short) return (dock, self.LOCATION)
def __init__(self, parent=None): super(PyboritaWidget, self).__init__(parent) self.parent = parent main_container = QVBoxLayout(self) ## Información puntaje box_score = QHBoxLayout() self._score = "<h2>Puntaje: %s</h2>" self.lbl_score = QLabel(self._score % 0) self.lbl_score.setStyleSheet("background: #232729") self.lbl_score.setAlignment(Qt.AlignCenter) box_score.addWidget(self.lbl_score) self._max_score = "<h2>Máximo Puntaje: %s</h2>" self.lbl_max_score = QLabel(self._max_score % 0) self.lbl_max_score.setStyleSheet("background: #232729") self.lbl_max_score.setAlignment(Qt.AlignCenter) box_score.addWidget(self.lbl_max_score) main_container.addLayout(box_score) # Snake self.frame_snake = pyborita.Pyborita() main_container.addWidget(self.frame_snake) main_container.setAlignment(Qt.AlignCenter) tecla_escape = QShortcut(QKeySequence(Qt.Key_Escape), self) # Conexiones tecla_escape.activated.connect(self._mostrar_dialogo) self.frame_snake.scoreChanged[int].connect(self.update_score) self.frame_snake.highscoreChanged[int].connect(self.update_max_score)
def addLabelClass(self, label_config): # Check label configuration if 'attributes' not in label_config: raise ImproperlyConfigured("Label with no 'attributes' dict found") attrs = label_config['attributes'] if 'class' not in attrs: raise ImproperlyConfigured("Labels must have an attribute 'class'") label_class = attrs['class'] if label_class in self._class_config: raise ImproperlyConfigured("Label with class '%s' defined more than once" % label_class) # Store config self._class_config[label_class] = label_config # Parse configuration and create handlers and item self.parseConfiguration(label_class, label_config) # Add label class button button = QPushButton(label_class, self) button.setCheckable(True) button.setFlat(True) button.clicked.connect(bind(self.onClassButtonPressed, label_class)) self._class_buttons[label_class] = button self._classbox_layout.addWidget(button) # Add hotkey if 'hotkey' in label_config: hotkey = QShortcut(QKeySequence(label_config['hotkey']), self) hotkey.activated.connect(button.click) self._class_shortcuts[label_class] = hotkey
def __init__(self, parent=None): super(ShowPresets, self).__init__(parent) self.original_presets_file = '/usr/share/ffmulticonverter/presets.xml' self.config_folder = os.getenv('HOME') + '/.config/ffmulticonverter/' self.current_presets_file = self.config_folder + 'presets.xml' self.presListWidget = QListWidget() labelLabel = QLabel(self.tr('Preset label')) self.labelLineEdit = QLineEdit() self.labelLineEdit.setReadOnly(True) commandLabel = QLabel(self.tr('Preset command line parameters')) self.commandLineEdit = QLineEdit() self.commandLineEdit.setReadOnly(True) extLabel = QLabel(self.tr('Output file extension')) self.extLineEdit = QLineEdit() self.extLineEdit.setReadOnly(True) addButton = QPushButton(self.tr('Add')) self.deleteButton = QPushButton(self.tr('Delete')) self.delete_allButton = QPushButton(self.tr('Delete all')) self.editButton = QPushButton(self.tr('Edit')) searchLabel = QLabel(self.tr('Search')) self.searchLineEdit = QLineEdit() okButton = QPushButton(self.tr('OK')) okButton.setDefault(True) spc1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) spc2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) spc3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) grid = pyqttools.add_to_grid( QGridLayout(), [self.delete_allButton, addButton, spc1], [self.deleteButton, self.editButton, spc2]) hlayout = pyqttools.add_to_layout(QHBoxLayout(), searchLabel, self.searchLineEdit, None, okButton) final_layout = pyqttools.add_to_layout( QVBoxLayout(), self.presListWidget, labelLabel, self.labelLineEdit, commandLabel, self.commandLineEdit, extLabel, self.extLineEdit, grid, spc3, hlayout) self.setLayout(final_layout) okButton.clicked.connect(self.accept) self.presListWidget.currentRowChanged.connect(self.show_preset) addButton.clicked.connect(self.add_preset) self.deleteButton.clicked.connect(self.delete_preset) self.delete_allButton.clicked.connect(self.delete_all_presets) self.editButton.clicked.connect(self.edit_preset) self.searchLineEdit.textEdited.connect(self.search) del_shortcut = QShortcut(self) del_shortcut.setKey(Qt.Key_Delete) del_shortcut.activated.connect(self.delete_preset) self.resize(430, 480) self.setWindowTitle(self.tr('Edit Presets')) QTimer.singleShot(0, self.load_xml) QTimer.singleShot(0, self.fill_presListWidget)
def __init__(self, parent, dbConf, qConf): QDialog.__init__(self) self.form = Ui_Dialog() self.form.setupUi(self) self.dbConf = dbConf self.qConf = qConf self.form.tableView.horizontalHeader().setMovable(True) self.form.closeButton.clicked.connect(self.reject) self.form.viewQuizButton.clicked.connect(self.onViewQuiz) self.form.emailResultsButton.clicked.connect(self.onEmailResults) self.form.importResultsButton.clicked.connect(self.onImportResults) self.form.viewResultsButton.clicked.connect(self.onViewResults) self.setupClassCombo() self.tableModel = HistoryTableModel(self) self.form.tableView.setModel(self.tableModel) self.sm = self.form.tableView.selectionModel() self.sm.selectionChanged.connect(self.checkButtonEnablement) self.reFillHistory() self.form.classCombo.activated.connect(self.reFillHistory) qlShortcut = QShortcut(QKeySequence("Alt+L"), self.form.tableView) qlShortcut.connect(qlShortcut, QtCore.SIGNAL("activated()"), lambda: self.form.tableView.setFocus())
def initGui(self): for keyseq, slot in ( (Qt.CTRL + Qt.ALT + Qt.Key_K, self.__create_group), (Qt.CTRL + Qt.ALT + Qt.Key_S, self.__select_next_group), (Qt.CTRL + Qt.ALT + Qt.Key_N, self.__next_section), (Qt.CTRL + Qt.ALT + Qt.Key_B, self.__previous_section), ): short = QShortcut(QKeySequence(keyseq), self.__iface.mainWindow()) short.setContext(Qt.ApplicationShortcut) short.activated.connect(slot) self.__shortcuts.append(short) self.__menu = QMenu("Albion") self.__menu.aboutToShow.connect(self.__create_menu_entries) self.__iface.mainWindow().menuBar().addMenu(self.__menu) self.__toolbar = QToolBar("Albion") self.__iface.addToolBar(self.__toolbar) self.__toolbar.addAction(icon("log_strati.svg"), "stratigraphic log").triggered.connect( self.__log_strati_clicked) self.__toolbar.addWidget(self.__current_graph) self.__current_graph.currentIndexChanged[unicode].connect( self.__current_graph_changed) self.__toolbar.addWidget(self.__current_section) self.__current_section.currentIndexChanged[unicode].connect( self.__current_section_changed) self.__toolbar.addAction( icon("previous_line.svg"), "previous section (Ctrl+Alt+b)").triggered.connect( self.__previous_section) self.__toolbar.addAction( icon("next_line.svg"), "next section (Ctrl+Alt+n)").triggered.connect(self.__next_section) self.__toolbar.addAction(icon("line_from_selected.svg"), "create temporary section").triggered.connect( self.__section_from_selection) self.__viewer3d = QDockWidget("3D") self.__viewer3d.setWidget(Viewer3d()) self.__iface.addDockWidget(Qt.LeftDockWidgetArea, self.__viewer3d) self.__iface.mainWindow().tabifyDockWidget( self.__iface.mainWindow().findChild(QDockWidget, "Layers"), self.__viewer3d) self.__viewer3d_ctrl = QToolBar("3D controls") self.__viewer3d_ctrl.addWidget(ViewerControls( self.__viewer3d.widget())) self.__iface.addToolBar(self.__viewer3d_ctrl) QgsProject.instance().readProject.connect(self.__qgis__project__loaded) self.__qgis__project__loaded() # case of reload