def __copyFilter(self): """ Private slot to copy the current filter to the clipboard. """ item = self.currentItem() if item is not None: QApplication.clipboard().setText(item.text(0))
def editCut(self): """ Public slot to cut the selection. """ if self.__selRect.isValid(): img = self.__getSelectionImage(True) QApplication.clipboard().setImage(img)
def copy_tree(self): """Copy the tree to the clipboard.""" items = [] inval_index = QModelIndex() it = QTreeWidgetItemIterator(self) prev_depth = 0 while it.value(): depth = 0 item = it.value() parent = item.parent() while parent: depth += 1 parent = parent.parent() if depth < prev_depth: items.extend([" |"*depth, "\n"]) if depth: items.extend([" |"*depth, "--", item.text(0), "\n"]) else: items.extend([item.text(0), "\n"]) prev_depth = depth it += 1 QApplication.clipboard().setText("".join(items))
def _copy_nodeid(self): node = self.get_current_node() if node: text = node.nodeid.to_string() else: text = "" QApplication.clipboard().setText(text)
def event(self, e): if e == QKeySequence.Copy or e == QKeySequence.Cut: datamodel = self.model() selected_text = [] current_row = None current_col = None prev_row = None prev_col = None for index in sorted(self.selectionModel().selectedIndexes()): current_row = index.row() current_col = index.column() if prev_row is not None and current_row != prev_row: selected_text.append('\n') elif prev_col is not None and current_col != prev_col: selected_text.append('\t') selected_text.append(datamodel.data(index, Qt.DisplayRole)) prev_row = current_row prev_col = current_col QApplication.clipboard().setText("".join(selected_text)) return True else: return super(SEToolsTableView, self).event(e)
def editCopy(self): """ Public slot to copy the selection. """ if self.__selRect.isValid(): img = self.__getSelectionImage(False) QApplication.clipboard().setImage(img)
def copy(self): """Copy to the clipboard""" data = QMimeData() text = '\n'.join([cursor.selectedText() \ for cursor in self.cursors()]) data.setText(text) data.setData(self.MIME_TYPE, text.encode('utf8')) QApplication.clipboard().setMimeData(data)
def __contextMenuCopyLink(self): """ Private method to copy the download link to the clipboard. """ itm = self.__currentItem() if itm is not None: url = itm.getPageUrl().toString() QApplication.clipboard().setText(url)
def set_clipboard(data, selection=False): """Set the clipboard to some given data.""" if selection and not supports_selection(): raise SelectionUnsupportedError if log_clipboard: what = 'primary selection' if selection else 'clipboard' log.misc.debug("Setting fake {}: {}".format(what, json.dumps(data))) else: mode = QClipboard.Selection if selection else QClipboard.Clipboard QApplication.clipboard().setText(data, mode=mode)
def mouseReleaseEvent(self, event): if self.rubberband.isVisible(): self.selRect = self.rubberband.geometry() self.rubberband.hide() codePix = self.screenPix.copy( self.selRect.x(), self.selRect.y(), self.selRect.width(), self.selRect.height()) QApplication.clipboard().setPixmap(codePix) self.exit() QWidget.mouseReleaseEvent(self, event)
def _yank(self, url): """Yank an element to the clipboard or primary selection. Args: url: The URL to open as a QURL. """ sel = self._context.target == Target.yank_primary mode = QClipboard.Selection if sel else QClipboard.Clipboard urlstr = url.toString(QUrl.FullyEncoded | QUrl.RemovePassword) QApplication.clipboard().setText(urlstr, mode) message.info(self._win_id, "URL yanked to {}".format( "primary selection" if sel else "clipboard"))
def copyPosition(self): view = DocumentManager.instance().currentMapView() if (not view): return globalPos = QCursor.pos() viewportPos = view.viewport().mapFromGlobal(globalPos) scenePos = view.mapToScene(viewportPos) renderer = self.mapDocument().renderer() tilePos = renderer.screenToTileCoords_(scenePos) x = math.floor(tilePos.x()) y = math.floor(tilePos.y()) QApplication.clipboard().setText(str(x) + ", " + str(y))
def __init__(self,indice, fileName=None, parent=None): super(BookEditWindow, self).__init__(parent) self.indice = indice self.setWindowIcon(QIcon(':/images/logo.png')) self.setToolButtonStyle(Qt.ToolButtonFollowStyle) self.setupFileActions() self.setupEditActions() self.setupTextActions() helpMenu = QMenu("Help", self) self.menuBar().addMenu(helpMenu) helpMenu.addAction("About", self.about) helpMenu.addAction("About &Qt", QApplication.instance().aboutQt) self.textEdit = QTextEdit(self) self.textEdit.currentCharFormatChanged.connect( self.currentCharFormatChanged) self.textEdit.cursorPositionChanged.connect(self.cursorPositionChanged) self.setCentralWidget(self.textEdit) self.textEdit.setFocus() self.setCurrentFileName() self.fontChanged(self.textEdit.font()) self.colorChanged(self.textEdit.textColor()) self.alignmentChanged(self.textEdit.alignment()) self.textEdit.document().modificationChanged.connect( self.actionSave.setEnabled) self.textEdit.document().modificationChanged.connect( self.setWindowModified) self.textEdit.document().undoAvailable.connect( self.actionUndo.setEnabled) self.textEdit.document().redoAvailable.connect( self.actionRedo.setEnabled) self.setWindowModified(self.textEdit.document().isModified()) self.actionSave.setEnabled(self.textEdit.document().isModified()) self.actionUndo.setEnabled(self.textEdit.document().isUndoAvailable()) self.actionRedo.setEnabled(self.textEdit.document().isRedoAvailable()) self.actionUndo.triggered.connect(self.textEdit.undo) self.actionRedo.triggered.connect(self.textEdit.redo) self.actionCut.setEnabled(False) self.actionCopy.setEnabled(False) self.actionCut.triggered.connect(self.textEdit.cut) self.actionCopy.triggered.connect(self.textEdit.copy) self.actionPaste.triggered.connect(self.textEdit.paste) self.textEdit.copyAvailable.connect(self.actionCut.setEnabled) self.textEdit.copyAvailable.connect(self.actionCopy.setEnabled) QApplication.clipboard().dataChanged.connect(self.clipboardDataChanged) basepath = os.path.join(Config().instance.settings.value("global/resources_path"),Config().instance.settings.value("global/resources_book")) fileName= os.path.join(basepath,fileName) if not self.load(fileName): self.fileNew() print ('not filename : ',fileName)
def __getPredefinedVars(self): """ Private method to return predefined variables. @return dictionary of predefined variables and their values """ project = e5App().getObject("Project") editor = self.viewmanager.activeWindow() today = datetime.datetime.now().date() sepchar = Preferences.getTemplates("SeparatorChar") keyfmt = sepchar + "{0}" + sepchar varValues = {keyfmt.format('date'): today.isoformat(), keyfmt.format('year'): str(today.year)} if project.name: varValues[keyfmt.format('project_name')] = project.name if project.ppath: varValues[keyfmt.format('project_path')] = project.ppath path_name = editor.getFileName() if path_name: dir_name, file_name = os.path.split(path_name) base_name, ext = os.path.splitext(file_name) if ext: ext = ext[1:] varValues.update({ keyfmt.format('path_name'): path_name, keyfmt.format('dir_name'): dir_name, keyfmt.format('file_name'): file_name, keyfmt.format('base_name'): base_name, keyfmt.format('ext'): ext }) varValues[keyfmt.format('clipboard:ml')] = \ QApplication.clipboard().text() varValues[keyfmt.format('clipboard')] = \ QApplication.clipboard().text() if editor.hasSelectedText(): varValues[keyfmt.format('cur_select:ml')] = editor.selectedText() varValues[keyfmt.format('cur_select')] = editor.selectedText() else: varValues[keyfmt.format('cur_select:ml')] = os.linesep varValues[keyfmt.format('cur_select')] = "" varValues[keyfmt.format('insertion')] = "i_n_s_e_r_t_i_o_n" varValues[keyfmt.format('select_start')] = "s_e_l_e_c_t_s_t_a_r_t" varValues[keyfmt.format('select_end')] = "s_e_l_e_c_t_e_n_d" return varValues
def __init__(self, fileName=None, parent=None): super(TextEdit, self).__init__(parent) self.setWindowIcon(QIcon(':/images/logo.png')) self.setToolButtonStyle(Qt.ToolButtonFollowStyle) self.setupFileActions() self.setupEditActions() self.setupTextActions() helpMenu = QMenu("Help", self) self.menuBar().addMenu(helpMenu) helpMenu.addAction("About", self.about) helpMenu.addAction("About &Qt", QApplication.instance().aboutQt) self.textEdit = QTextEdit(self) self.textEdit.currentCharFormatChanged.connect( self.currentCharFormatChanged) self.textEdit.cursorPositionChanged.connect(self.cursorPositionChanged) self.setCentralWidget(self.textEdit) self.textEdit.setFocus() self.setCurrentFileName() self.fontChanged(self.textEdit.font()) self.colorChanged(self.textEdit.textColor()) self.alignmentChanged(self.textEdit.alignment()) self.textEdit.document().modificationChanged.connect( self.actionSave.setEnabled) self.textEdit.document().modificationChanged.connect( self.setWindowModified) self.textEdit.document().undoAvailable.connect( self.actionUndo.setEnabled) self.textEdit.document().redoAvailable.connect( self.actionRedo.setEnabled) self.setWindowModified(self.textEdit.document().isModified()) self.actionSave.setEnabled(self.textEdit.document().isModified()) self.actionUndo.setEnabled(self.textEdit.document().isUndoAvailable()) self.actionRedo.setEnabled(self.textEdit.document().isRedoAvailable()) self.actionUndo.triggered.connect(self.textEdit.undo) self.actionRedo.triggered.connect(self.textEdit.redo) self.actionCut.setEnabled(False) self.actionCopy.setEnabled(False) self.actionCut.triggered.connect(self.textEdit.cut) self.actionCopy.triggered.connect(self.textEdit.copy) self.actionPaste.triggered.connect(self.textEdit.paste) self.textEdit.copyAvailable.connect(self.actionCut.setEnabled) self.textEdit.copyAvailable.connect(self.actionCopy.setEnabled) QApplication.clipboard().dataChanged.connect(self.clipboardDataChanged) if fileName is None: fileName = ':/example.html' if not self.load(fileName): self.fileNew()
def __copyUrlToClipboard(self): """ Private slot to copy the URL of the selected item to the clipboard. """ itm = self.feedsTree.currentItem() if itm is None: return if self.feedsTree.indexOfTopLevelItem(itm) != -1: return urlString = itm.data(0, FeedsManager.UrlStringRole) if urlString: QApplication.clipboard().setText(urlString)
def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget (QWidget) """ super(IconEditorGrid, self).__init__(parent) self.setAttribute(Qt.WA_StaticContents) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.__curColor = Qt.black self.__zoom = 12 self.__curTool = self.Pencil self.__startPos = QPoint() self.__endPos = QPoint() self.__dirty = False self.__selecting = False self.__selRect = QRect() self.__isPasting = False self.__clipboardSize = QSize() self.__pasteRect = QRect() self.__undoStack = QUndoStack(self) self.__currentUndoCmd = None self.__image = QImage(32, 32, QImage.Format_ARGB32) self.__image.fill(qRgba(0, 0, 0, 0)) self.__markImage = QImage(self.__image) self.__markImage.fill(self.NoMarkColor.rgba()) self.__compositingMode = QPainter.CompositionMode_SourceOver self.__lastPos = (-1, -1) self.__gridEnabled = True self.__selectionAvailable = False self.__initCursors() self.__initUndoTexts() self.setMouseTracking(True) self.__undoStack.canRedoChanged.connect(self.canRedoChanged) self.__undoStack.canUndoChanged.connect(self.canUndoChanged) self.__undoStack.cleanChanged.connect(self.__cleanChanged) self.imageChanged.connect(self.__updatePreviewPixmap) QApplication.clipboard().dataChanged.connect(self.__checkClipboard) self.__checkClipboard()
def __init__(self, parent=None, command="/bin/bash", font_size=14): super().__init__(parent) self._columns = 80 self._rows = 24 self._char_width = [0] * (self._columns + 1) self._char_height = [0] * (self._rows + 1) self.setFocusPolicy(Qt.StrongFocus) self.setAutoFillBackground(False) self.setAttribute(Qt.WA_OpaquePaintEvent, True) self.setCursor(Qt.IBeamCursor) font_name = "Monospace" if sys.platform == 'darwin': font_name = "Courier" font = QFont(font_name) font.setStyleHint(QFont.TypeWriter) font.setPixelSize(font_size) self.setFont(font) self._session = None self._last_update = 0 self._screen = [] self._text = [] self._cursor_rect = None self._cursor_col = 0 self._cursor_row = 0 self._dirty = False self._blink = False self._press_pos = None self._selection = None self._clipboard = QApplication.clipboard() self._pixmap = None
def warning(cls, *args): clip_board = QApplication.clipboard() clip_board.clear() text_ = args[0] if isinstance(args[0], str) else args[2] clip_board.setText(text_) return cls.msgbox("warning", *args)
def copyPixmap(pixmap): global _notificationId clipboard = QApplication.clipboard() clipboard.clear() clipboard.setPixmap(pixmap) _notificationId = notificationsInterface.notify("Deepin Screenshot", _("Picture has been saved to clipboard"))
def play_mv_by_mvid(cls, mvid): mv_model = ControllerApi.api.get_mv_detail(mvid) if not ControllerApi.api.is_response_ok(mv_model): return url_high = mv_model['url_high'] clipboard = QApplication.clipboard() clipboard.setText(url_high) cls.view.ui.STATUS_BAR.showMessage( u"程序已经将视频的播放地址复制到剪切板", 5000) if platform.system() == "Linux": ControllerApi.player.pause() ControllerApi.notify_widget.show_message( "通知", "正在尝试调用VLC视频播放器播放MV") try: subprocess.Popen(['vlc', url_high, '--play-and-exit', '-f']) except: LOG.error('call vlc player failed') elif platform.system().lower() == 'Darwin'.lower(): ControllerApi.player.pause() ControllerApi.notify_widget.show_message( "通知", "准备调用 QuickTime Player 播放mv") try: subprocess.Popen(['open', '-a', 'QuickTime Player', url_high]) except: LOG.error('call quicktime player failed')
def paste(self, sel=False, tab=False, bg=False, window=False): """Open a page from the clipboard. Args: sel: Use the primary selection instead of the clipboard. tab: Open in a new tab. bg: Open in a background tab. window: Open in new window. """ clipboard = QApplication.clipboard() if sel and clipboard.supportsSelection(): mode = QClipboard.Selection target = "Primary selection" else: mode = QClipboard.Clipboard target = "Clipboard" text = clipboard.text(mode) if not text: raise cmdexc.CommandError("{} is empty.".format(target)) log.misc.debug("{} contained: '{}'".format(target, text)) try: url = urlutils.fuzzy_url(text) except urlutils.FuzzyUrlError as e: raise cmdexc.CommandError(e) self._open(url, tab, bg, window)
def json_to_widgets(self, jotason: dict): """Take a json string object return QWidgets.""" dict_of_widgets, row = {}, 0 for titlemotes in tuple(sorted(jotason.items())): tit = str(titlemotes[0]).strip()[:9].title() area = ScrollGroup(tit) layout = area.layout() grid_cols = 2 if tit.lower() == "multichar" else 8 for index, emote in enumerate(tuple(set(list(titlemotes[1])))): button = QPushButton(emote, self) button.clicked.connect(lambda _, c=emote: QApplication.clipboard().setText(c)) button.released.connect(self.hide) button.released.connect(lambda c=emote: self.recentify(c)) button.pressed.connect(lambda c=emote: self.make_preview(c)) button.setToolTip("<center><h1>{0}<br>{1}".format( emote, self.get_description(emote))) button.setFlat(True) font = button.font() font.setPixelSize(50) button.setFont(font) row = row + 1 if not index % grid_cols else row layout.addWidget(button, row, index % grid_cols) dict_of_widgets[tit] = area return dict_of_widgets
def build_submenu(self, char_list, submenu): """Take a list of characters and a submenu and build actions on it.""" for _char in sorted(char_list): action = submenu.addAction(_char.strip()) action.hovered.connect(lambda char=_char: log.debug(char)) action.triggered.connect( lambda _, char=_char: QApplication.clipboard().setText(char))
def mouseDoubleClickEvent(self, event): if event.button() != QtCore.Qt.LeftButton: return self._menuFollow(self._canv_curva) clipboard = QApplication.clipboard() clipboard.setText(hex(self._canv_curva))
def get_clipboard(selection=False, fallback=False): """Get data from the clipboard. Args: selection: Use the primary selection. fallback: Fall back to the clipboard if primary selection is unavailable. """ global fake_clipboard if fallback and not selection: raise ValueError("fallback given without selection!") if selection and not supports_selection(): if fallback: selection = False else: raise SelectionUnsupportedError if fake_clipboard is not None: data = fake_clipboard fake_clipboard = None else: mode = QClipboard.Selection if selection else QClipboard.Clipboard data = QApplication.clipboard().text(mode=mode) target = "Primary selection" if selection else "Clipboard" if not data.strip(): raise ClipboardEmptyError("{} is empty.".format(target)) log.misc.debug("{} contained: {!r}".format(target, data)) return data
def __init__(self, settings, parent=None): super(Form, self).__init__(parent) icon = QtGui.QIcon(":/tcharmap.png") self.setWindowIcon(icon) self.settings = settings self.results = [] self.entries = read_entries() self.lineedit = VLineEdit() self.lineedit.selectAll() self.table = QTableWidget() self.table.installEventFilter(self) self.table.currentCellChanged[int, int, int, int].connect(self.copy_entry_slot) layout = QVBoxLayout() layout.addWidget(self.table) layout.addWidget(self.lineedit) self.setLayout(layout) self.lineedit.textChanged[str].connect(self.update_query) self.lineedit.setFocus() self.setWindowTitle("tcharmap") self.results = self.lookup("") self.table.setColumnCount(3) self.table.horizontalHeader().setStretchLastSection(True) self.table.verticalHeader().setVisible(False) self.table.horizontalHeader().setVisible(False) self.table.setColumnWidth(1, 150) self.clipboard = QApplication.clipboard() self.resize(540, 530) self.update_ui()
def __init__(self, parent=None, *args, **kwargs): """Init class custom tab widget.""" super(TabHtml, self).__init__(self, *args, **kwargs) self.parent = parent self.setParent(parent) added_html_entities, row, index = [], 0, 0 for html_char in tuple(sorted(entities.html5.items())): added_html_entities.append( html_char[0].lower().replace(";", "")) if not html_char[0].lower() in added_html_entities: button = QPushButton(html_char[1], self) button.released.connect(self.parent.hide) button.pressed.connect(lambda ch=html_char: self.parent.make_preview(str(ch))) button.clicked.connect( lambda _, ch=html_char[0]: QApplication.clipboard().setText( "&{html_entity}".format(html_entity=ch))) button.setToolTip("<center><h1>{0}<br>{1}".format( html_char[1], self.parent.get_description(html_char[1]))) button.setFlat(True) font = button.font() font.setPixelSize(50) button.setFont(font) index = index + 1 # cant use enumerate() row = row + 1 if not index % 8 else row self.layout().addWidget(button, row, index % 8)
def __init__(self, parent=None, command="/bin/bash", font_name="Monospace", font_size=18): super(TerminalWidget, self).__init__(parent) self.parent().setTabOrder(self, self) self.setFocusPolicy(Qt.WheelFocus) self.setAutoFillBackground(False) self.setAttribute(Qt.WA_OpaquePaintEvent, True) self.setCursor(Qt.IBeamCursor) font = QFont(font_name) font.setPixelSize(font_size) self.setFont(font) self._session = None self._last_update = None self._screen = [] self._text = [] self._cursor_rect = None self._cursor_col = 0 self._cursor_row = 0 self._dirty = False self._blink = False self._press_pos = None self._selection = None self._clipboard = QApplication.clipboard() QApplication.instance().lastWindowClosed.connect(Session.close_all) if command: self.execute()
def import_heroku(self): clipboard = QApplication.clipboard() url = clipboard.text() if "pyth.herokuapp.com" in url: url = url.replace("+", " ") parameters = re.split("[?=&]", url)[1:] params_dict = {parameters[i]: unquote(parameters[i + 1]) for i in range(0, len(parameters), 2)} if "code" in params_dict: if len(self.code_tabs.currentWidget().toPlainText()): self.add_new_tab() self.code_tabs.currentWidget().setPlainText(params_dict["code"]) if "input" in params_dict: self.input_text_edit.setPlainText(params_dict["input"]) if "test_suite_input" in params_dict: self.test_suite_text_edit.setPlainText(params_dict["test_suite_input"]) if "input_size" in params_dict: self.test_suite_spinbox.setValue(int(params_dict["input_size"])) if "test_suite" in params_dict: self.input_tabs.setCurrentIndex(int(params_dict["test_suite"])) else: self.input_tabs.setCurrentIndex(0) else: QMessageBox().about( self, "Import from Heroku-App", "\n".join(["Copy the Permalink of the Heroku-App.", "The url will be extracted from the Clipboard."]), )
def copyHtml(self): mimeData = QMimeData() mimeData.setHtml('<b>Bold and <font color=red>Red</font></b>') clipboard = QApplication.clipboard() clipboard.setMimeData(mimeData)
def pasteHtml(self): clipboard = QApplication.clipboard() mimeData = clipboard.mimeData() if mimeData.hasHtml(): self.textLabel.setText(mimeData.html())
def copyValueReference(self): """ Copy the value references of the selected variables to the clipboard """ text = '\n'.join( [str(v.valueReference) for v in self.getSelectedVariables()]) QApplication.clipboard().setText(text)
def __init__(self, aPath, parent=None): super(VideoPlayer, self).__init__(parent) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAcceptDrops(True) self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.StreamPlayback) self.mediaPlayer.mediaStatusChanged.connect(self.printMediaData) self.mediaPlayer.setVolume(80) self.videoWidget = QVideoWidget(self) self.lbl = QLineEdit('00:00:00') self.lbl.setReadOnly(True) self.lbl.setFixedWidth(70) self.lbl.setUpdatesEnabled(True) self.lbl.setStyleSheet(stylesheet(self)) self.elbl = QLineEdit('00:00:00') self.elbl.setReadOnly(True) self.elbl.setFixedWidth(70) self.elbl.setUpdatesEnabled(True) self.elbl.setStyleSheet(stylesheet(self)) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setFixedWidth(24) self.playButton.setFixedHeight(24) self.playButton.setStyleSheet( "background-color: black; margin-bottom: 1px;") self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) # VIDE0 POSITION SLIDER self.positionSlider = QSlider(Qt.Horizontal, self) self.positionSlider.setStyleSheet(stylesheet(self)) self.positionSlider.setRange(0, 100) self.positionSlider.sliderMoved.connect(self.setPosition) self.positionSlider.sliderMoved.connect(self.handleLabel) self.positionSlider.setSingleStep(2) self.positionSlider.setPageStep(20) self.positionSlider.setAttribute(Qt.WA_TranslucentBackground, True) # VOLUME ICON self.volumeIcon = QPushButton() self.volumeIcon.setIcon(self.style().standardIcon( QStyle.SP_MediaVolume)) self.volumeIcon.clicked.connect(self.volumeAction) # VOLUME SLIDER self.volumeSlider = QSlider(Qt.Horizontal) self.volumeSlider.setFocusPolicy(Qt.StrongFocus) self.volumeSlider.setTickPosition(QSlider.TicksBothSides) self.volumeSlider.setTickInterval(10) self.volumeSlider.setSingleStep(1) self.volumeSlider.setFixedWidth(120) self.clip = QApplication.clipboard() self.process = QProcess(self) controlLayout = QHBoxLayout() controlLayout.setContentsMargins(5, 0, 5, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.lbl) controlLayout.addWidget(self.positionSlider) controlLayout.addWidget(self.elbl) controlLayout.addWidget(self.volumeIcon) controlLayout.addWidget(self.volumeSlider) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.videoWidget) layout.addLayout(controlLayout) self.setLayout(layout) self.myinfo = "Mouse Wheel = Zoom\nUP = Volume Up\nDOWN = Volume Down\n" + \ "LEFT = < 1 Minute\nRIGHT = > 1 Minute\n" + \ "SHIFT+LEFT = < 10 Minutes\nSHIFT+RIGHT = > 10 Minutes" self.widescreen = True #### shortcuts #### self.shortcut = QShortcut(QKeySequence("q"), self) self.shortcut.activated.connect(self.handleQuit) self.shortcut = QShortcut(QKeySequence("o"), self) self.shortcut.activated.connect(self.openFile) self.shortcut = QShortcut(QKeySequence(" "), self) self.shortcut.activated.connect(self.play) self.shortcut = QShortcut(QKeySequence("f"), self) self.shortcut.activated.connect(self.handleFullscreen) self.shortcut = QShortcut(QKeySequence("i"), self) self.shortcut.activated.connect(self.handleInfo) self.shortcut = QShortcut(QKeySequence("s"), self) self.shortcut.activated.connect(self.toggleSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider) self.shortcut = QShortcut(QKeySequence(Qt.Key_Up), self) self.shortcut.activated.connect(self.volumeUp) self.shortcut = QShortcut(QKeySequence(Qt.Key_Down), self) self.shortcut.activated.connect(self.volumeDown) self.shortcut = QShortcut( QKeySequence(Qt.ShiftModifier + Qt.Key_Right), self) self.shortcut.activated.connect(self.forwardSlider10) self.shortcut = QShortcut(QKeySequence(Qt.ShiftModifier + Qt.Key_Left), self) self.shortcut.activated.connect(self.backSlider10) self.mediaPlayer.setVideoOutput(self.videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.positionChanged.connect(self.handleLabel) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) # self.setToolTip("press 'o' to open file (see context menu for more)") No need for tool tip print("QT5 Player started") print("press 'o' to open file (see context menu for more)") self.suspend_screensaver()
def copy_nodeid(self): node = self.get_current_node() text = node.nodeid.to_string() QApplication.clipboard().setText(text)
def _copy(self): text = self._text.toPlainText() QApplication.clipboard().setText(text)
def copy_to_clipboard(): p = qscreen.grabWindow(qrw.winId()) QApplication.clipboard().setPixmap(p) self.show_message(_("QR code copied to clipboard"))
from PyQt5.QtWidgets import( QApplication, QSystemTrayIcon, QColorDialog, QMenu, QAction ) app = QApplication(sys.argv) app.setQuitOnLastWindowClosed(False) # Create the icon icon = QIcon('bug.png') clipboard = QApplication.clipboard() dialog = QColorDialog() def copy_color_hex(): if dialog.exec_(): color = dialog.currentColor() clipboard.setText(color.name()) def copy_color_rgb(): if dialog.exec_(): color = dialog.currentColor() clipboard.setText("rgb(%d, %d, %d)" %( color.red(), color.green(), color.blue()) ) def copy_color_hsv(): if dialog.exec_():
def copy_to_clipboard(qrw, widget): p = qrw and qrw.grab() if p and not p.isNull(): QApplication.clipboard().setPixmap(p) QToolTip.showText(QCursor.pos(), _("QR code copied to clipboard"), widget)
def export_TOS_img_2clipboard(self): # https://stackoverflow.com/questions/31607458/how-to-add-clipboard-support-to-matplotlib-figures buf = io.BytesIO() self.sc.fig.savefig(buf, bbox_inches='tight') QApplication.clipboard().setImage(QImage.fromData(buf.getvalue())) buf.close()
def pushButton_copy_clicked(self): index = self.tabWidget.currentIndex() textEdit = self.lineEdit_url_list[index] clipboard = QApplication.clipboard() clipboard.setText(textEdit.text())
def pasteImage(self): clipboard = QApplication.clipboard() self.imageLabel.setPixmap(clipboard.pixmap())
def copyImage(self): clipboard = QApplication.clipboard() clipboard.setPixmap(QPixmap(os.path.join(os.path.dirname(__file__), 'python.jgp')))
def copytext(self): clipboard = QApplication.clipboard() clipboard.setText(self.GetFilePath) self.add_log('http url copy success')
def pasteText(self): clipboard = QApplication.clipboard() self.textLabel.setText(clipboard.text())
def copyText(self): clipboard = QApplication.clipboard() clipboard.setText('I\'ve been clipped')
def copy_link(): QApplication.clipboard().setText(link.url())
def copy_path(self): path = self.get_current_path() path_str = ",".join(path) QApplication.clipboard().setText(path_str)
def CopyHashMenuTriggered(self, hash=""): log.info("CopyHashMenuTriggered") clipboard = QApplication.clipboard() clipboard.setText(hash)
def __init__(self): super(window, self).__init__() print("Starting to do things") self.setObjectName( "Mother Window") # print("I am the "+ self.objectName()) self.setAttribute( Qt.WA_QuitOnClose, True ) #Ensures that closing the main window also closes the preferences window self.clip = QApplication.clipboard() #System-wide clipboard self.pickerButton = self.clickButton("Pipette", QColorDialog.getColor) #Configs self.settings = QSettings( "D:\Projects\Python\SwitchBoard\MySwitchboard.cfg", QSettings.IniFormat) self.settings.setPath( QSettings.IniFormat, QSettings.UserScope, "D:\Projects\Python\SwitchBoard\MySwitchboard.cfg") # self.settingsPath = QSettings("D:\Projects\Python\SwitchBoard\MySwitchboard.cfg", QSettings.NativeFormat) # self.settings.setPath(QSettings.IniFormat,QSettings.UserScope,"D:\Projects\Python\SwitchBoard\MySwitchboard.cfg") self.initSettings() # DEBUG: LIST ALL CONFIG KEYS # print("Listing all config keys:" + str(self.settings.allKeys())); print("Config file is" + self.settings.fileName()) # setup window aspects self.setWindowTitle(self.settings.value("cfgWindowTitle")) self.setWindowIcon(QIcon('logo.png')) self.declareActions() self.setStatusBar(QStatusBar(self)) self.XY = QLabel( "Cursor:" ) # TODO: Make this come with something to display the numerical position of the cursor; might involve the timerEvent of QStatusBar # self.statusBar.addPermanentWidget(self.XY) QStatusBar.addPermanentWidget(self.statusBar(), self.XY) #TODO: Check if status bar properly has its QSizeGrip, using isSizeGripEnabled() self.topMenu() self.mainToolBar = QObject self.preferencesDialog = QDialog() self.setupToolBars() #NOTE: for QMainWindow, do a find for things with menu, status, tab, tool pop = self.basicButton('test', self.popup, None, 25, 100) box = self.basicCheckBox(self.editTitle) self.bar = self.progressBar(325, 75, 160, 28) self.doProgress = self.basicButton('Increment Progress', self.progress, "", 200, 75) clearClipboard = self.basicButton( "Clear Clipboard", self.clip.clear) #Button which clears the system clipboard #print(self.clip.text())#print clipboard text Dial = self.dial(1, 100, 300) self.pageBar = QTabWidget(self) # TabWidget is a QWidget self.tab1 = QWidget() # ;self.tab1.adjustSize() self.tab2 = QWidget() # ;self.tab2.adjustSize() tab1Layout = QVBoxLayout() tab1Layout.addStretch(1) tab1Layout.addWidget(pop) tab1Layout.addWidget(clearClipboard) tab1Layout.addWidget(box) tab1Layout.addWidget(Dial) progressBox = QHBoxLayout() progressBox.addStretch(1) progressBox.addWidget(self.doProgress) progressBox.addWidget(self.bar) self.tab1.setLayout(tab1Layout) self.tab2.setLayout(progressBox) #previously took progressBox as param self.pageBar.addTab(self.tab1, "tab1") self.pageBar.addTab(self.tab2, "tab2") # self.mainToolBar # tesT=QVBoxLayout() # tesT.addWidget(self.mainToolBar) # tesT.addWidget(self.pageBar) # self.setLayout(tesT) self.mainToolBar.addWidget(self.pageBar) # self.mainToolBar.addAction(self.actCopy) # self.mainToolBar.setLayout=QHBoxLayout(self) # make the pageBar occupy everything below the toolbar. # anything else being displayed must be part of a tab, # otherwise it will end up being rendered behind the pageBar # self.setCentralWidget() tempPref = self.basicButton('Options', self.appPreferences, None, 300, 300) self.restoreGeometry(self.settings.value("mainWindowGeometry")) print("Window width:" + str(self.width())) print("Window height:" + str(self.height())) print("done init")
def copyLink(self): row = self.tableWidget.selectionModel().currentIndex().row() url = self.tableWidget.video_list[row][1].toString() QApplication.clipboard().setText(url)
def supports_selection(): """Check if the OS supports primary selection.""" return QApplication.clipboard().supportsSelection()
def execute(self,script_variable): cur_filepath = join(script_variable["cur_path"],script_variable["file_list"][0]) clipboard = QApplication.clipboard() clipboard.setText(cur_filepath)
def copyVariableName(self): """ Copy the names of the selected variables to the clipboard """ text = '\n'.join([str(v.name) for v in self.getSelectedVariables()]) QApplication.clipboard().setText(text)
def _set_callbacks(self): self.theory_main.set_callback( "copy_to_clipboard", lambda text: QApplication.clipboard().setText(text))
def __init__(self, yooz_setting, dict): super().__init__() # console arguments and # browser plugin arguments # will passed to main window # with dict! self.dict = dict # settings self.yooz_setting = yooz_setting self.yooz_setting.beginGroup('mainwindow') # toggle action for radio buttons self.radioButton0.toggled.connect( partial(self.radioButtonIsToggled, button=self.radioButton0, number=0)) self.radioButton1.toggled.connect( partial(self.radioButtonIsToggled, button=self.radioButton1, number=1)) self.radioButton2.toggled.connect( partial(self.radioButtonIsToggled, button=self.radioButton2, number=2)) # deactive stopAction self.stopAction.setEnabled(False) # link # check clipboard, if user didn't called yooz with # command line arguments, or browser's plugin, # and set link_lineEdit value. if not ('link' in self.dict.keys()): # check clipboard clipboard = QApplication.clipboard() text = clipboard.text() if (("tp:/" in text[2:6]) or ("tps:/" in text[2:7])): self.link_lineEdit.setText(str(text)) else: # we have link in dict! self.link_lineEdit.setText(dict['link']) # proxy # check dict for proxy value if 'proxy' in self.dict.keys(): global radio_button_number # check 'proxy' radio button self.radioButton2.setChecked(True) radio_button_number = 2 # active proxy_frame self.proxy_frame.setEnabled(True) # extract proxy information # the proxy format must be in this format: # socks5://127.0.0.1:1080/ proxy_dict = dict['proxy'] proxy_split = proxy.split(':') # find ip ip_split = proxy_split[1] ip_split = ip_split.split('//') ip = ip_split[1] # find port port_split = proxy_split[2] port_split = port_split.split('/') port = port_split[0] if 'http' in proxy_split[0]: # http/https proxy http_ip_lineEdit.setText(str(ip)) http_port_spinBox.setValue(int(port)) elif 'socks' in proxy_split[0]: # socks proxy socks_ip_lineEdit.setText(str(ip)) socks_port_spinBox.setValue(int(port)) else: # check yooz_setting for initialization value init_proxy = int(self.yooz_setting.value('proxy', 0)) radio_button_number = init_proxy if init_proxy == 0: # set 'no proxy' checked in radio buttons self.radioButton0.setChecked(True) # deactive proxy_frame self.proxy_frame.setEnabled(False) elif init_proxy == 1: # set 'torify' checked in radio buttons self.radioButton1.setChecked(True) # deactive proxy_frame self.proxy_frame.setEnabled(False) elif init_proxy == 2: # set 'proxy' checked in radio buttons self.radioButton2.setChecked(True) # active proxy_frame self.proxy_frame.setEnabled(True) # set http_ip and http_port and socks_ip # and socks_port by yooz_setting's values http_ip = self.yooz_setting.value('http_ip', None) http_port = self.yooz_setting.value('http_port', None) socks_ip = self.yooz_setting.value('socks_ip', None) socks_port = self.yooz_setting.value('socks_port', None) if http_ip: self.http_ip_lineEdit.setText(str(http_ip)) if http_port: self.http_port_spinBox.setValue(int(http_port)) if socks_port: self.socks_ip_lineEdit.setText(str(socks_ip)) if socks_port: self.socks_port_spinBox.setValue(int(socks_port)) # resolution if 'resolution' in self.dict.keys(): # read resolution value from dict init_resolution = self.dict['resolution'] else: # read resolution value from yooz_setting init_resolution = self.yooz_setting.value('resolution', None) # resolution_index is the number of video height in resolution_comboBox try: resolution_number = int(init_resolution) if resolution_number <= 144: resolution_index = 0 elif resolution_number <= 240: resolution_index = 1 elif resolution_number <= 360: resolution_index = 2 elif resolution_number <= 480: resolution_index = 3 elif resolution_number <= 720: resolution_index = 4 elif resolution_number <= 1080: resolution_index = 5 except: # set resolution for Best quality resolution_index = 6 # set index in resolution_comboBox self.resolution_comboBox.setCurrentIndex(resolution_index) # a list for running AboutWindow self.about_window_list = [] # set window size and position size = self.yooz_setting.value('size', QSize(500, 300)) position = self.yooz_setting.value('position', QPoint(300, 300)) self.resize(size) self.move(position) self.yooz_setting.endGroup() # show window self.show()
def _copy_to_clipboard(self, complete): mime_data = self._get_mime_data(complete) QApplication.clipboard().setMimeData(mime_data)
def yank_text(self): text = QApplication.clipboard().text() self.buffer_widget.eval_js("paste('{}');".format(text))
def copyText(self): text = self.widget().view.surface().selectedText() if text: QApplication.clipboard().setText(text)
def do_clip(self): buf = io.BytesIO() self.fig.savefig(buf) QApplication.clipboard().setImage(QImage.fromData(buf.getvalue())) buf.close()