python窗体设置italic_Python cairo.FONT_SLANT_ITALIC属性代码示例

# 需要导入模块: import cairo [as 别名]

# 或者: from cairo import FONT_SLANT_ITALIC [as 别名]

def draw_grid(ctx, date):

"""

Draws the whole grid of 52x90 squares

"""

start_date = date

pos_x = X_MARGIN / 4

pos_y = pos_x

# Draw the key for box colours

ctx.set_font_size(TINYFONT_SIZE)

ctx.select_font_face(FONT, cairo.FONT_SLANT_NORMAL,

cairo.FONT_WEIGHT_NORMAL)

pos_x = draw_key_item(ctx, pos_x, pos_y, KEY_BIRTHDAY_DESC, BIRTHDAY_COLOUR)

draw_key_item(ctx, pos_x, pos_y, KEY_NEWYEAR_DESC, NEWYEAR_COLOUR)

# draw week numbers above top row

ctx.set_font_size(TINYFONT_SIZE)

ctx.select_font_face(FONT, cairo.FONT_SLANT_NORMAL,

cairo.FONT_WEIGHT_NORMAL)

pos_x = X_MARGIN

pos_y = Y_MARGIN

for i in range(NUM_COLUMNS):

text = str(i + 1)

w, h = text_size(ctx, text)

ctx.move_to(pos_x + (BOX_SIZE / 2) - (w / 2), pos_y - BOX_SIZE)

ctx.show_text(text)

pos_x += BOX_SIZE + BOX_MARGIN

ctx.set_font_size(TINYFONT_SIZE)

ctx.select_font_face(FONT, cairo.FONT_SLANT_ITALIC,

cairo.FONT_WEIGHT_NORMAL)

for i in range(NUM_ROWS):

# Generate string for current date

ctx.set_source_rgb(0, 0, 0)

date_str = date.strftime('%d %b, %Y')

w, h = text_size(ctx, date_str)

# Draw it in front of the current row

ctx.move_to(X_MARGIN - w - BOX_SIZE,

pos_y + ((BOX_SIZE / 2) + (h / 2)))

ctx.show_text(date_str)

# Draw the current row

draw_row(ctx, pos_y, start_date, date)

# Increment y position and current date by 1 row/year

pos_y += BOX_SIZE + BOX_MARGIN

date += datetime.timedelta(weeks=52)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值