load_ui.py 文件源码

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

项目:quite 作者: SF-Zhou 项目源码 文件源码
def process_scaling(ui_content: str, ratio: float) -> str:
    tree = ElementTree.fromstring(ui_content)
    for child in tree.iter('width'):
        if child.text != '16777215':
            child.text = str(int(int(child.text) * ratio))
    for child in tree.iter('height'):
        if child.text != '16777215':
            child.text = str(int(int(child.text) * ratio))
    for child in tree.iter("property"):
        name = child.attrib.get('name', None)
        if name == 'spacing' or name[-6:] == 'Margin' and len(child):
            number = child[0]
            number.text = str(int(int(number.text) * ratio))
    ui_content = ElementTree.tostring(tree, encoding='unicode')
    ui_content = ui_content.replace(' />\n', '/>\n')
    return '<?xml version="1.0" encoding="UTF-8"?>\n' + ui_content + '\n'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号