clipboard.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:nom 作者: frnsys 项目源码 文件源码
def get_clipboard_html():
    """returns html in clipboard, if any"""
    if 'darwin' in sys.platform:
        if NSPasteboard is None:
            raise Exception('AppKit not found, first run `pip install pyobjc`')
        pb = NSPasteboard.generalPasteboard()
        return pb.stringForType_('public.html')

    elif 'linux' in sys.platform:
        if Gtk is None:
            raise Exception('Could not import GTK, is it installed on this system?')
        cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        html_target = Gdk.Atom.intern('text/html', False)
        targets = cb.wait_for_targets()[1]
        if html_target not in targets:
            return None
        return cb.wait_for_contents(html_target).get_data()

    else:
        raise Exception('Platform "{}" is not supported'.format(sys.platform))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号