__init__.py 文件源码

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

项目:cryptogram 作者: xinmingzhang 项目源码 文件源码
def _set_text_property(self, name, value, allow_utf8=True):
        atom = xlib.XInternAtom(self._x_display, asbytes(name), False)
        if not atom:
            raise XlibException('Undefined atom "%s"' % name)
        assert isinstance(value, basestring)
        property = xlib.XTextProperty()
        if _have_utf8 and allow_utf8:
            buf = create_string_buffer(value.encode('utf8'))
            result = xlib.Xutf8TextListToTextProperty(self._x_display,
                cast(pointer(buf), c_char_p), 1, xlib.XUTF8StringStyle, 
                byref(property))
            if result < 0:
                raise XlibException('Could not create UTF8 text property')
        else:
            buf = create_string_buffer(value.encode('ascii', 'ignore'))
            result = xlib.XStringListToTextProperty(
                cast(pointer(buf), c_char_p), 1, byref(property))
            if result < 0:
                raise XlibException('Could not create text property')
        xlib.XSetTextProperty(self._x_display,
            self._window, byref(property), atom)
        # XXX <rj> Xlib doesn't like us freeing this
        #xlib.XFree(property.value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号