1 Star 1 Fork 1

iounce/Python-Cpp-demo

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
utils.py 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
iounce 提交于 2023-08-30 21:52 +08:00 . use Python to gen C++ class -- by PySideFrameless
# -*- coding: utf-8 -*-
import os
import time
from PySide6.QtGui import QColor
from language import Language
from theme import Theme
import wcwidth
# helper
class StringUtils:
@staticmethod
def contains(string, substring):
return string.find(substring) != -1
class FileUtils:
@staticmethod
def get_name(filename):
return os.path.splitext(filename)[0]
@staticmethod
def get_fullname(name, ext = '.xml'):
if ext in name:
return name
return name + ext
class DateUtils:
@staticmethod
def get_year():
return time.strftime('%Y', time.localtime(time.time()))
@staticmethod
def get_date():
return time.strftime('%Y-%m-%d',time.localtime(time.time()))
class ColorUtils:
@staticmethod
def hex2rgb(color):
value = int(color[1:], 16)
rgb_color = QColor(value)
rgb_color = QColor(rgb_color.red(), rgb_color.green(), rgb_color.blue())
return rgb_color.rgb()
class LanguageUtils:
@staticmethod
def validate(language):
languages = [Language.Chinese.value, Language.English.value]
return language in languages
class ThemeUtils:
@staticmethod
def validate(theme):
theme = FileUtils.get_fullname(theme)
return theme in Theme.get_all_themes()
class WidthHelper():
def format_text(text, width=30):
count = wcwidth.wcswidth(text) - len(text)
width = width - count if width >= count else 0
fill = ' '
return '{0:{1}{2}{3}}'.format(text, fill, '^', width)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/iounce_admin/python-cpp-demo.git
git@gitee.com:iounce_admin/python-cpp-demo.git
iounce_admin
python-cpp-demo
Python-Cpp-demo
master

搜索帮助