
上QQ阅读APP看书,第一时间看更新
2-6 Widget的共同属性Font
font参数用于设置文字字形,这个参数包含下列内容。
(1)字形family:如Helvetica、Times等,读者可以进入Word内参考所有系统字形。
(2)字号size:单位是px。
(3)weight:例如bold、normal。
(4)slant:例如italic、roman,如果不是italic则是roman。
(5)underline:例如True、False。
(6)overstrike:例如True、False。
程序实例ch2_8.py:重新设计程序实例ch2_4.py,使用Helvetica字形,大小是20,粗体显示。

执行结果

从上图可以看到标签区域相较程序实例ch2_4.py放大了,这是因为程序第8行height和width都是和字号联动的。另外,也可以用元组方式处理第9行的font参数。
程序实例ch2_8_1.py:使用元组重新处理程序实例ch2_8.py第9行的font参数。

执行结果 与程序实例ch2_8.py相同。