def _insert_hyperlink(self, title=None): cursor = self.textCursor() current_pos = cursor.position() if title is not None: link_title = title else: link_title = 'Link Title' link_address = 'http://www.example.com' start_pos = current_pos + 1 end_pos = start_pos + len(link_title) clipboard_text = QtGui.QClipboard().text() if len(grab_urls(clipboard_text)) > 0: link_address = clipboard_text text, ret = QtGui.QInputDialog.getText(self, 'Insert Link', 'Link address:', QtGui.QLineEdit.Normal, link_address) if cursor.hasSelection(): start_pos = cursor.selectionEnd() + 3 end_pos = start_pos + len(link_address) if ret: if text != '': link_address = text cursor.insertHtml('[{0}](<a href="{1}">{1}</a>)'.format(link_title, link_address)) cursor.setPosition(start_pos) cursor.setPosition(end_pos, QtGui.QTextCursor.KeepAnchor) self.setTextCursor(cursor)
def copy_to_clipboard(self): cb = QtGui.QClipboard() cb.setText(self.lineEdit.text()) self.pushButton.setText(u"Copié !") self.label_clipboard_copy.setText( u"Le code est copié dans le presse papier.\nColler le à l'aide d'un clic droit ou du raccourcis clavier CTRL+V." )
def basic_Execute(self, msg, flags): try: scene = modo.Scene() clipboard = QtGui.QClipboard() # The QtGui.QClipboard gives you access # to your operating system's Copy/Paste Clipboard text = None if len(scene.selected) == 0: # If you have nothing selected, don't do anything pass elif len(scene.selected) == 1: # If you have a single item selected text = scene.selected[0].name # set text to that item's name elif len(scene.selected) > 1: # If you have more than one item selected selItemsAsNames = [item.name for item in scene.selected] # Create a list and grab just the names # This join command allows you to take a list text = ', '.join(selItemsAsNames) # and turn it in to a single long string. # Very useful for displaying lists in a non-python way if text is not None: # Only the above elifs were accessed, will this be true clipboard.setText(text) lx.out('Text copied to clipboard: %s' %(text)) except Exception as e: lx.out(e)
def copy_to_clipboard(self, nodes=None): nodes = nodes or self.selected_nodes() if not nodes: return pipes = self.get_pipes_from_nodes(nodes) serializer = SessionSerializer(nodes, pipes) clipboard = QtGui.QClipboard() clipboard.setText(serializer.serialize_to_str())
def initVars(self): self.byte_strings = {} self._bytestring_table = QtGui.QTableWidget() self._bytestring_table.setRowCount(1) self._bytestring_table.setColumnCount(3) self._bytestring_table.setHorizontalHeaderLabels( ("Address", "Function", "String")) self._clipboard = QtGui.QClipboard()
def __init__(self): super(MainWindow, self).__init__() self.guiMutex = QtCore.QMutex() self.setWindowTitle("mEDI's Elite Tools") self.setDockOptions(QtGui.QMainWindow.AnimatedDocks | QtGui.QMainWindow.AllowNestedDocks | QtGui.QMainWindow.AllowTabbedDocks) self.setStatusBar("Welcome to mEDI's Elite Tools (Version: %s, %s)" % (__version__, __builddate__)) self.setMinimumSize(600, 400) self.setWindowIcon(QtGui.QIcon(QtGui.QPixmap("img/logo.png"))) self.addProgressBarStatusBar() self.clipboard = QtGui.QClipboard() self.mydb = elite.db(guiMode=True) self.mydb.cleanIgnorePriceTemp() self.mydb.startStreamUpdater() self.dbworker = gui.dbworker.new(self) self.location = elite.location(self.mydb) self.createActions() self.createMenus() self.createTimer() self.myPlugins = [ gui.multihoproute, gui.deals_from_to, gui.commodities_finder, gui.shipyard_finder, gui.power_control_finder, gui.flylog, gui.bookmarks, gui.rares_finder, gui.profit_calculator, gui.outfitting_finder, gui.data_status ] self.addTool(gui.multihoproute, self.multiHopRouteWidget) self.addTool(gui.deals_from_to, self.dealsFromToWidget) self.addTool(gui.commodities_finder, self.commoditiesFinderWidget) self.addTool(gui.shipyard_finder, self.shipyardFinderWidget) self.addTool(gui.power_control_finder, self.powerControlFinderWidget) self.addTool(gui.flylog, self.flyLogWidget) self.addTool(gui.bookmarks, self.BookmarksWidget) self.addTool(gui.rares_finder, self.raresFinderWidget) self.addTool(gui.profit_calculator, self.profitCalculatorWidget) self.addTool(gui.outfitting_finder, self.outfittingFinderWidget) self.addTool(gui.data_status, self.dataStatusWidget) gui.statistics.initRun(self) gui.edit_permit.initRun(self) gui.add_edit_items.initRun(self) self.show() self.loadLastWindowsOptions()
def CopyEA(): myModuleName = idc.GetInputFile() MyModuleShortName = re.sub(r'\.[^.]*$','',myModuleName) myModuleBase = idaapi.get_imagebase() myOffset = idc.ScreenEA() - myModuleBase clippy = QtGui.QClipboard() pasteStr = "bp !%s + 0x%x" % (MyModuleShortName, myOffset) print pasteStr clippy.setText(pasteStr)
def __init__(self, floating): """Initialize the ScripterPanel widget.""" super(ScripterView, self).__init__() self.floating = floating self.language = "py" self.clipboard = QtGui.QClipboard() self.set_up() self.build_ui()
def copy_to_clipboard(self): cb = QtGui.QClipboard() cb.setText(self.lineEdit.text()) self.pushButton.setText( QtWidgets.QApplication.translate("FreeCADGraderResults", "Copié !", None, -1)) self.label_clipboard_copy.setText( QtWidgets.QApplication.translate( "FreeCADGraderResults", "Le code est copié dans le presse papier.\nColler le à l'aide d'un clic droit ou du raccourcis clavier CTRL+V.", None, -1))
def OnCreate(self, form): self.parent = self.FormToPySideWidget(form) self.byte_strings = {} self.table = QtGui.QTableWidget() self.table.setRowCount(1) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(("Address", "Function", "String")) layout = QtGui.QVBoxLayout() layout.addWidget(self.table) self.clipboard = QtGui.QClipboard() self.Create() self.parent.setLayout(layout)
def RunOrTest(self, b_run): sel = Gui.Selection.getSelection() if len(sel) != 1: raise CommandError( self, u"Please select one object. Currently selected {n}".format( n=len(sel))) if b_run: from PartOMagic.Base import LinkTools as LT uses = LT.findLinksTo(sel[0]) uses_str = '\n'.join([ (rel.linking_object.Name + '.' + rel.linking_property + ' (' + rel.kind + ')') for rel in uses ]) if len(uses_str) == 0: uses_str = "(nothing)" links = LT.getDependencies(sel[0]) links_str = '\n'.join([ (rel.linked_object.Name + " as " + rel.linking_property + ' (' + rel.kind + ')') for rel in links ]) if len(links_str) == 0: links_str = "(nothing)" msg = (u"==== {obj} uses: ====\n" "{links_str}\n\n" "====Links to {obj}:====\n" "{uses_str}").format(obj=sel[0].Label, uses_str=uses_str, links_str=links_str) from PySide import QtGui mb = QtGui.QMessageBox() mb.setIcon(mb.Icon.Information) mb.setText(msg) mb.setWindowTitle("Used by who?") btnClose = mb.addButton(QtGui.QMessageBox.StandardButton.Close) btnCopy = mb.addButton("Copy to clipboard", QtGui.QMessageBox.ButtonRole.ActionRole) btnSelect = mb.addButton("Select dependent objects", QtGui.QMessageBox.ButtonRole.ActionRole) mb.setDefaultButton(btnClose) mb.exec_() if mb.clickedButton() is btnCopy: cb = QtGui.QClipboard() cb.setText(msg) if mb.clickedButton() is btnSelect: objs = set([rel.linking_object for rel in uses]) Gui.Selection.clearSelection() for obj in objs: Gui.Selection.addSelection(obj)
def share(self, service): #page = urllib.urlopen(self.share_url.replace(' ','+')).read() #soup = BeautifulSoup(page) if service == 'diaspora': try: pod_url = preferences['targets']['diaspora']['pod'] if pod_url == None or len(pod_url) == 0: raise Exception() settings['targets'][service]['url'] = settings['targets'][ service]['url'].replace('{{pod}}', pod_url) except: settings['targets'][service][ 'url'] = 'http://sharetodiaspora.github.com/?url={{url}}&title={{title}}¬es={{tags}}{{text}}&shorten=no' if service == 'clipboard': share_url = settings['targets'][service]['url'].replace( '{{url}}', self.process_url(service)).replace( '{{title}}', self.process_title(service)).replace( '{{tags}}', self.process_tags(service)).replace( '{{text}}', self.process_notes(service)) clipboard = QtGui.QClipboard() clipboard.setText(share_url) return "Copied to clipboard" else: try: share_url = settings['targets'][service]['url'].replace( '{{url}}', urllib.quote(self.process_url(service))).replace( '{{title}}', urllib.quote(self.process_title(service))).replace( '{{tags}}', urllib.quote(self.process_tags(service))).replace( '{{text}}', urllib.quote(self.process_notes(service))) except: share_url = preferences['custom_targets'][ service]['url'].replace( '{{url}}', urllib.quote(self.process_url(service))).replace( '{{title}}', urllib.quote(self.process_title(service))).replace( '{{tags}}', urllib.quote( self.process_tags(service))).replace( '{{text}}', urllib.quote( self.process_notes(service))) QtGui.QDesktopServices.openUrl(share_url) if service == 'diaspora': # reload settings settings.reload() return "Opening window for sharing"
def msgError(err = None, message = u'{errmsg}'): import sys if err is None: err = sys.exc_info()[1] if type(err) is CancelError: return # doesn't work! Why! if hasattr(err, "isCancelError") and err.isCancelError: return #workaround # can we get a traceback? b_tb = err is sys.exc_info()[1] if b_tb: import traceback tb = traceback.format_exc() import FreeCAD as App App.Console.PrintError(tb+'\n') #make messagebox object from PySide import QtGui mb = QtGui.QMessageBox() mb.setIcon(mb.Icon.Warning) #fill in message errmsg = '' if hasattr(err,'message'): if isinstance(err.message, dict): errmsg = err.message['swhat'] elif len(err.message) > 0: errmsg = err.message else: errmsg = str(err) else: errmsg = str(err) mb.setText(message.format(errmsg= errmsg, err= err)) # fill in title if hasattr(err, "title"): mb.setWindowTitle(err.title) else: mb.setWindowTitle("Error") #add traceback button if b_tb: btnClose = mb.addButton(QtGui.QMessageBox.StandardButton.Close) btnCopy = mb.addButton("Copy traceback", QtGui.QMessageBox.ButtonRole.ActionRole) mb.setDefaultButton(btnClose) mb.exec_() if b_tb: if mb.clickedButton() is btnCopy: cb = QtGui.QClipboard() cb.setText(tb)
def copySelectedNodeName( ): sel = cmds.ls( sl=True ) sel_text = None if len( sel ) == 1: sel_text = sel[0] elif len( sel ) > 1: ls = [str( i ) for i in sel] sel_text = '\n'.join( ls ) if sel_text is not None: clip = QtGui.QClipboard( ) clip.setText( sel_text ) om.MGlobal.displayInfo( 'In Clipboard:\n%s' % (sel_text) )
def initVars(self): self._import_table = QtGui.QTableWidget() self._import_table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self._import_table.setRowCount(0) self._import_table.setColumnCount(6) self._import_table.setHorizontalHeaderLabels(["Address","DLL","ProcName","ProcAddress","Type","IDA Name"]) self._import_table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) copyAction = QtGui.QAction(self._import_table) copyAction.setText("Copy Cell Value") copyAction.triggered.connect(self.copyToClipboard) self._import_table.addAction(copyAction) renameAction = QtGui.QAction(self._import_table) renameAction.setText("Rename DWORDs to Proc Name") renameAction.triggered.connect(self.renameDword) self._import_table.addAction(renameAction) self.clipboard = QtGui.QClipboard()
def initVars(self): self._call_table = QtGui.QTableWidget() self._call_table.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self._call_table.setRowCount(0) self._call_table.setColumnCount(6) self._call_table.setHorizontalHeaderLabels( ["Category", "Caller", "Parent Caller", "API", "Return", "Args"]) self.clipboard = QtGui.QClipboard() self.setupTableContextMenu() self._marked_up = set() self._checkbox_map = {} # call color picker setup self._color_picker = QtGui.QColorDialog() self._color_picker.setCurrentColor(QtGui.QColor(0xff, 165, 0x0)) self._color_picker.blockSignals(True) self._color_picker.currentColorChanged.connect(self.chooseColor) self._color_picker.blockSignals(False) self._color_button = QtGui.QPushButton("") self._color_button.setStyleSheet( "font-size:15px;background-color:#ffa500; border: 2px solid #222222" ) self._color_button.setFixedSize(15, 15) self._color_button.clicked.connect(self._color_picker.open) # func color picker setup self._func_color_picker = QtGui.QColorDialog() self._func_color_picker.setCurrentColor(QtGui.QColor(0xff, 0xff, 0xff)) self._func_color_picker.blockSignals(True) self._func_color_picker.currentColorChanged.connect( self.chooseFuncColor) self._func_color_picker.blockSignals(False) self._func_color_button = QtGui.QPushButton("") self._func_color_button.setStyleSheet( "font-size:15px;background-color:#ffffff; border: 2px solid #222222" ) self._func_color_button.setFixedSize(15, 15) self._func_color_button.clicked.connect(self._func_color_picker.open)
def setClipText(txt): clip = QtGui.QClipboard() clip.setText(txt)
def getClipText(): clip = QtGui.QClipboard() return clip.text(QtGui.QClipboard.Clipboard)
def paste_from_clipboard(self): clipboard = QtGui.QClipboard() data_string = clipboard.text() self.load_nodes_data(data_string)
def qclipboard(): return QtGui.QClipboard()
def copyPathToClipboard(self): selectedItem = self.gscene.selectedItems()[-1] imagePath = selectedItem.data(32) QtGui.QClipboard().setText(imagePath, QtGui.QClipboard.Clipboard)
def set_clipboard_text(text): from PySide import QtGui clippy = QtGui.QClipboard() clippy.setText(text)