凡 星 2022-03-23 21:24 采纳率: 100%
浏览 572
已结题

Python里使用ttkbootstrap怎么修改文字

我在代码里使用ttkbootstrap中的Label和Button等,但是不懂怎么改变里面输入的text的字体大小,请问怎么改变?

  • 写回答

2条回答 默认 最新

  • 关注

    参考代码如下:

    import ttkbootstrap as ttk
    from ttkbootstrap import Style as StyleBs
    
    if __name__ ==  "__main__" :
        root = ttk.Window()  # 使用 ttkbootstrap 创建窗口对象
        style = StyleBs("darkly")
    
        style.configure('TLabel', font=('Times New Roman', 40), foreground = "blue")   # foreground is changed, but font is not
        style.configure('TButton', font=('Times New Roman', 30), foreground = "red")  # foreground is changed, font too
    
        button = ttk.Button(root, style="TLabel", text="Label 12345" ).grid(row=0, column = 0)
        label = ttk.Label(root, style="TButton", text="Button 12345" ).grid(row=1, column = 0)
    
        root.mainloop()
    

    img

    如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月1日
  • 已采纳回答 3月24日
  • 创建了问题 3月23日