예제 #1
0
def _copyToClipboard(but, fig):
    #print('CLIP!')
    tmpFile = os.tempnam() + '.jpg'
    fig.savefig(tmpFile, dpi=200)
    pixBuf = gtk.gdk.pixbuf_new_from_file(tmpFile)
    cb = gtk.Clipboard()
    cb.set_image(pixBuf)
    os.remove(tmpFile)
예제 #2
0
 def __init__(self, screen_number=0):
     gobject.GObject.__init__(self)
     self._selection = "_XSETTINGS_S%s" % screen_number
     self._clipboard = gtk.Clipboard(gtk.gdk.display_get_default(), self._selection)
     self._current = None
     self._root = self._clipboard.get_display().get_default_screen().get_root_window()
     add_event_receiver(self._root, self)
     self._add_watch()
 def handle_context_menu(self, menuitem, action, url):
     """Handle activate event for the links' context menu"""
     if action == "open":
         self.open_url(url)
     if action == "copy":
         clipboard = gtk.Clipboard()
         clipboard.set_text(url)
         clipboard.store()
예제 #4
0
파일: net.py 프로젝트: masums/deepin-ui
 def cut_to_clipboard(self):
     '''
     Cut mac address to clipboard.
     '''
     clipboard = gtk.Clipboard()
     clipboard.set_text(self.get_mac())
     self.set_mac(self.default_address)
     self.move_to_start()
예제 #5
0
 def paste_from_clipboard(self):
     '''
     Paste text to entry from clipboard.
     '''
     if self.is_editable():
         with self.monitor_entry_content():
             clipboard = gtk.Clipboard()    
             clipboard.request_text(lambda clipboard, text, data: self.commit_entry(text))
예제 #6
0
 def delete_object(self, object_id):
     cb_object = self._objects.pop(object_id)
     cb_object.destroy()
     if not self._objects:
         gtk_clipboard = gtk.Clipboard()
         gtk_clipboard.clear()
     self.emit('object-deleted', object_id)
     logging.debug('Deleted object with object_id %r', object_id)
예제 #7
0
    def __init__(self):
        gobject.GObject.__init__(self)

        self.clipboard = gtk.Clipboard(gtk.gdk.display_get_default(),
                                       "_REVELATION_ENTRY")
        self.__has_contents = False

        gobject.timeout_add(500, lambda: self.__check_contents())
	def _boton_apretado(self, widget, data=None):

		self.archivo = self._filechooser.get_filename()
		logging.info(self.archivo)
		clipboard = gtk.Clipboard()
		clipboard.set_with_data([('text/uri-list', 0, 0)],
					self._clipboard_get_func_cb,
					self._clipboard_clear_func_cb)
예제 #9
0
	def copy(self, widget=None, data=None):
		text = self.glade.get_widget('lipsum').get_buffer().get_text(
			self.glade.get_widget('lipsum').get_buffer().get_start_iter(),
			self.glade.get_widget('lipsum').get_buffer().get_end_iter(),
			False
		)
		clipboard = gtk.Clipboard()
		clipboard.set_text(text)
예제 #10
0
 def on_copy_permalink(self, *e):
     track = self.dbfm_plugin.get_current_track()
     sid = track.get_tag_raw('sid')[0]
     ssid = track.get_tag_raw('ssid')[0]
     t = DoubanTrack(sid=sid, ssid=ssid)
     url = t.get_uri()
     c = gtk.Clipboard()
     c.set_text(url)
예제 #11
0
 def __init__(self):
     interface = gtk.Builder()
     interface.add_from_file('%s/sp02.glade' % (__cpath__, ))
     interface.connect_signals(self)
     self.interface = interface
     self.assignmap([
         'hbox1', 'hbox3', 'hbox5', 'satl', 'ratel', 'fnopulse',
         'fnofinger', 'signaltxt', 'lsttimetxt', 'lastbeeptobeep', 'beeper',
         'beep2beepavgl', 'beatduration', 'beatrms', 'beatrmsovertime',
         'beatrmsdeoffset'
     ], [
         'hbox1', 'hbox3', 'hbox5', 'sat', 'rate', 'nopulse', 'nofinger',
         'signal', 'timestamp', 'lastbeeptobeep', 'beeper', 'beep2beepavgl',
         'beatduration', 'beatrms', 'beatrmsovertime', 'beatrmsdeoffset'
     ])
     self.createprogressbars('pleth', self.hbox1, 250)
     self.createprogressbars('satp', self.hbox3, 200)
     self.createprogressbars('ratep', self.hbox5, 200)
     #if _experiments_:
     #self.createprogressbars('d_dt_pleth',self.hbox8,250)
     #self.cd_dt_pleth = self.cpleth
     #self.lastcd_dt_pleth = self.lastcpleth
     map(
         lambda k: map(
             lambda sfx: setattr(self, '%s%sl' % (k, sfx),
                                 interface.get_object("%s%s" % (k, sfx))) or
             setattr(self, '%s%sv' % (k, sfx), None), ['max', 'min']),
         ['rate', 'sat', 'beep2beep'])
     self.clipboard = gtk.Clipboard()
     self.crateplwb = 0
     self.cratepupb = 255
     self.crateplocmin = 255
     self.crateplocmax = 0
     self.rdline = ''
     gobject.threads_init()
     self.tjsonuplink = []
     self.exitevent = th.Event()
     if not _experiments_:
         interface.get_object("experiments").set_property('visible', False)
     else:
         self.lastbeep = 0
         self.beep2beep = [0] * 10
         self.beep2beeppt = 0
         self.beep2beepavgv = 0
         self.lasttime = 0
         self.dfplwb = -255
         self.dfpupb = 255
         self.localdfmin = 255
         self.localdfmax = -255
         self.pwrstmark = [False, False, 0, 0]
     self.tjson = th.Thread(target=self.parsejson,
                            kwargs={
                                'uplink': self.tjsonuplink,
                                'onexit': self.exitevent
                            })
     self.tjson.start()
     gobject.timeout_add(10, self.checkjson)
    def _tb_copy_selection(self):
        tb = self.stdout_textview.get_buffer()
        bounds = tb.get_selection_bounds()

        if bounds:
            text = tb.get_text(bounds[0], bounds[1])
            clipboard = gtk.Clipboard()
            clipboard.set_text(text)
            clipboard.store()
예제 #13
0
def test_clipboard():
    clipboard = gtk.Clipboard()
    targets = clipboard.wait_for_targets()
    print "Targets available:", ", ".join(map(str, targets))
    for target in targets:
        print "Trying '%s'..." % str(target)
        contents = clipboard.wait_for_contents(target)
        if contents:
            print contents.data
예제 #14
0
    def copy_to_clipboard(self):
        '''
        Copy select text to clipboard.
        '''
        if self.select_start_index != self.select_end_index:
            cut_text = self.text[self.select_start_index:self.select_end_index]

            clipboard = gtk.Clipboard()
            clipboard.set_text(cut_text)
예제 #15
0
    def save_clipboard(self, pb):
        """
        Save the pixbuf to the clipboard
        escrotum would be alive until the clipboard owner is changed
        """

        clipboard = gtk.Clipboard()
        clipboard.set_image(pb)
        clipboard.connect("owner-change", self.on_owner_change)
예제 #16
0
 def locationToClipboad(self, w=None):
     ## add GPS location latitude/longitude to clipboard
     clipboard = gtk.Clipboard()
     if self.mapsObj.gps and self.mapsObj.gps.gpsfix and \
       self.mapsObj.gps.gpsfix.latitude and self.mapsObj.gps.gpsfix.longitude:
         clipboard.set_text("Latitude=%.6f, Longitude=%.6f" %
                           (self.mapsObj.gps.gpsfix.latitude, self.mapsObj.gps.gpsfix.longitude))
     else:
         clipboard.set_text("No GPS location detected.")
예제 #17
0
 def test_get_display_for(self):
     assert l.get_display_for(self.display) is self.display
     win = self.window()
     assert l.get_display_for(win) is self.display
     assert_raises(TypeError, l.get_display_for, None)
     widg = gtk.Window()
     assert l.get_display_for(widg) is self.display
     clipboard = gtk.Clipboard(self.display, "PRIMARY")
     assert l.get_display_for(clipboard) is self.display
예제 #18
0
	def __init__(self, atom):
		'''Constructor
		@param atom: clipboard name, can be either "CLIPBOARD" or "PRIMARY",
		see C{gtk.Clipboard} for details.
		'''
		assert atom in ('CLIPBOARD', 'PRIMARY')
		self.clipboard = gtk.Clipboard(selection=atom)
		self.store = None
		self._i_am_owner = False
예제 #19
0
 def __init__(self):
     gobject.GObject.__init__(self)
     self._clipboard = gtk.Clipboard(gtk.gdk.display_get_default(),
                                     "_XSETTINGS_S0")
     self._current = None
     self._root = self._clipboard.get_display().get_default_screen(
     ).get_root_window()
     add_event_receiver(self._root, self)
     self._add_watch()
예제 #20
0
    def copy_page_url_selection(self, widget):
        tree = self.treeview.get_selection()
        model, selection = tree.get_selected()
        if not selection:
            return

        url = model.get_value(selection, 0)
        clipboard = gtk.Clipboard()
        clipboard.set_text(url)
예제 #21
0
 def cut_to_clipboard(self):
     '''
     Cut selected text to clipboard.
     '''
     self.buffer.cut_clipboard(gtk.Clipboard(), self.is_editable())
     self.adjust_size()
     if self.is_editable:
         self.emit("changed", self.get_text())
     self.queue_draw()
예제 #22
0
파일: pubdisp.py 프로젝트: pglen/pgpygtk
 def read_tts(self, butt):
     # Running?
     if self.speech_pid:
         self.stop_tts()
         return
     self.butt4.set_label("Stop")
     clip = gtk.Clipboard()
     self.buffer_1.copy_clipboard(clip)
     cstr = clip.wait_for_text()
     gobject.timeout_add(100, self.speak, cstr)
예제 #23
0
    def ctrl_c(self, self2):
        #print "CTRL - C"
        if self2.xsel == -1 or self2.ysel == -1:
            self2.mained.update_statusbar("Nothing selected, copying line.")
            clip = gtk.Clipboard()
            xidx = self2.caret[0] + self2.xpos
            yidx = self2.caret[1] + self2.ypos
            clip.set_text(self2.text[yidx])
            return

        # Normalize
        xssel = min(self2.xsel, self2.xsel2)
        xesel = max(self2.xsel, self2.xsel2)
        yssel = min(self2.ysel, self2.ysel2)
        yesel = max(self2.ysel, self2.ysel2)

        cnt = yssel
        cnt2 = 0
        cumm = ""
        while True:
            if cnt > yesel: break
            self.pad_list(self2, cnt)
            line = self2.text[cnt]
            if self2.colsel:
                frag = line[xssel:xesel]
            else:  # startsel - endsel
                if cnt == yssel and cnt == yesel:  # sel on the same line
                    frag = line[xssel:xesel]
                elif cnt == yssel:  # start line
                    frag = line[xssel:]
                elif cnt == yesel:  # end line
                    frag = line[:xesel]
                else:
                    frag = line[:]

            if cnt2: frag = "\n" + frag
            cumm += frag
            cnt += 1
            cnt2 += 1

        #print "clip:", cumm
        clip = gtk.Clipboard()
        clip.set_text(cumm)
예제 #24
0
    def _copy_to_clipboard(self, recd):
        if recd == None:
            return
        if not recd.isClipboardCopyable():
            return

        media_path = recd.getMediaFilepath()
        tmp_path = utils.getUniqueFilepath(media_path, 0)
        shutil.copyfile(media_path, tmp_path)
        gtk.Clipboard().set_with_data([('text/uri-list', 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path)
예제 #25
0
    def on_copy_clipboard(self, view):
        if not self._column_mode:
            return

        text = self._column_text()

        clipboard = gtk.Clipboard(self._view.get_display())
        clipboard.set_text(text)

        view.stop_emission('copy-clipboard')
예제 #26
0
    def save_snapshot(self, filename=None, filetype='png', clip_flag=True):
        '''
        Save snapshot.
        @param filename: the filename to save, a string type
        @param filetype: the filetype to save, a string type. Default is 'png'
        @param clip_flag: a flag if copy the snapshot to clipboard. Default is False
        '''
        failed_flag = False
        tipContent = ""
#         parent_dir = get_parent_dir(__file__, 1)
        # Save snapshot.
        if self.rect_width == 0 or self.rect_height == 0:
            tipContent = _("The width or height of selected area cannot be 0")
            failed_flag = True
        else:
            self.window.finish_flag = True
            surface = self.make_pic_file(
                self.desktop_background.subpixbuf(*self.get_rectangel_in_monitor()))
            # Save to file
            
            if filename:
                
                try:
                    surface.write_to_png(filename)
#                     SCROT_BUS.emit_finish(1, filename)
                    
                    '''根据文件后缀重新设置文件类型'''
                    str = filename.split('.')
                    imagetype =  str[len(str)-1]
                
                    im = Image.open(filename)
                    
                    if imagetype == 'jpg' or imagetype == 'jpeg':
                        im.save(filename,"jpeg")
                    elif imagetype == 'bmp' or imagetype == 'gif':
                        im.save(filename, imagetype)
                    elif imagetype == 'png':
                        im.save(filename, imagetype)
                    else:
                        im.save(filename.replace(imagetype, 'png'), 'png')
                        os.remove(filename)
                    
                    print filename
                    # 拷贝到剪切板
                    if clip_flag:
                        pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                        clipboard = gtk.Clipboard(selection="CLIPBOARD")
                        clipboard.set_image(pixbuf)
                        clipboard.store()


                except Exception, e:
                    tipContent = "%s:%s" % (_("Failed to save the picture"), str(e))
            # 保存图片到剪切板
            else:
예제 #27
0
    def on_paste_clipboard(self, view):
        if not self._edit_points:
            return

        clipboard = gtk.Clipboard(self._view.get_display())
        self._paste_mark = self._buffer.create_mark(
            None, self._buffer.get_iter_at_mark(self._buffer.get_insert()),
            True)

        clipboard.request_text(self.on_clipboard_text)
        view.stop_emission('paste-clipboard')
예제 #28
0
    def copy_video_url_selection(self, widget):
        tree = self.treeview.get_selection()
        model, selection = tree.get_selected()
        if not selection:
            return

        url = model.get_value(selection, 0)
        thread_id = self.thread_manager.get_thread_id(url)
        thread = self.thread_manager.get_video_thread(thread_id)
        clipboard = gtk.Clipboard()
        clipboard.set_text(thread.video.real_url)
예제 #29
0
    def test_conversion(self):
        m = ManagerSelection(self.display, "WM_S0")
        m.acquire(m.IF_UNOWNED)

        d2 = self.clone_display()
        clipboard = gtk.Clipboard(d2, "WM_S0")
        targets = sorted(clipboard.wait_for_targets())
        assert targets == ["MULTIPLE", "TARGETS", "TIMESTAMP", "VERSION"]
        v_data = clipboard.wait_for_contents("VERSION").data
        assert len(v_data) == 8
        assert struct.unpack("@ii", v_data) == (2, 0)
예제 #30
0
    def on_copy_text_button_clicked(self, widget):
        clip_selection = gtk.Clipboard(selection='PRIMARY')

        def receive_selection_text(clipboard, text, data=None):
            if text:
                clip_clipboard = gtk.Clipboard(selection='CLIPBOARD')
                clip_clipboard.set_text(text)
                self.show_message(_('Text copied to clipboard.'))
            else:
                self.show_message(_('Selection is empty.'))

        clip_selection.request_text(receive_selection_text)