clock.py 文件源码

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

项目:mTasks 作者: theodox 项目源码 文件源码
def update_time():
    '''
    update the clock display.  This will be called once very second by the repeat task.  It
    does need to yield at the end to allow time-slicing, however
    '''
    now = datetime.datetime.now().time()
    time_string = now.strftime("%-I:%M %S %p")

    hours, seconds, ampm = time_string.split()

    hour_style = "font-size:64px; font-family: Impact; color: #8A0F21"
    sec_style = "font-size:18px; font-family:Arial Black; color: #8A0F21"
    am_style = "font-size:24px; font-family:Arial Black; font-weight:900; color: #700D21"

    def set_control (ctl, value, style):
        def make_text(text, style):
            return '<span style="{0}">{1}</span>'.format(style, text)
        cmds.text(ctl, e=True, label = make_text(value, style))

    set_control(hour, hours, hour_style)
    set_control(secs, seconds, sec_style)
    set_control(am, ampm, am_style)
    yield

# set up the update job to repeat every second
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号